misc: add a simpler example config

This commit is contained in:
lyc8503 committed 2025-11-05 22:52:53 +08:00
1 parent 8e4fa94886
commit 9401202575
2 files changed
+225 -89

No files matched your search

+23 -89
View File
@@ -1,3 +1,8 @@
// This is a simplified example config file for quickstart
// Some not frequently used features are omitted/commented out here
// For a full-featured example, please refer to `uptime.config.full.ts`
// Don't edit this line
import { MaintenanceConfig, PageConfig, WorkerConfig } from './types/config'
const pageConfig: PageConfig = {
@@ -8,29 +13,12 @@ const pageConfig: PageConfig = {
{ link: 'https://github.com/lyc8503', label: 'GitHub' },
{ link: 'https://blog.lyc8503.net/', label: 'Blog' },
{ link: 'mailto:[email protected]', label: 'Email Me', highlight: true },
],
// [OPTIONAL] Group your monitors
// If not specified, all monitors will be shown in a single list
// If specified, monitors will be grouped and ordered, not-listed monitors will be invisble (but still monitored)
group: {
'🌐 Public (example group name)': ['foo_monitor', 'bar_monitor', 'more monitor ids...'],
'🔐 Private': ['test_tcp_monitor'],
},
// [OPTIONAL] Set the path to your favicon, default to '/favicon.png' if not specified
favicon: 'https://example.com/favicon.ico',
// [OPTIONAL] Maintenance related settings
maintenances: {
// [OPTIONAL] The color of upcoming maintenance alerts, default to 'gray'
// Active alerts will always use the color specified in the MaintenanceConfig
upcomingColor: 'gray',
},
]
}
const workerConfig: WorkerConfig = {
// Write KV at most every 3 minutes unless the status changed
kvWriteCooldownMinutes: 3,
// Enable HTTP Basic auth for status page & API by uncommenting the line below, format `<USERNAME>:<PASSWORD>`
// passwordProtection: 'username:password',
// Define all your monitors here
monitors: [
// Example HTTP Monitor
@@ -40,15 +28,13 @@ const workerConfig: WorkerConfig = {
// `name` is used at status page and callback message
name: 'My API Monitor',
// `method` should be a valid HTTP Method
method: 'POST',
method: 'GET',
// `target` is a valid URL
target: 'https://example.com',
// [OPTIONAL] `tooltip` is ONLY used at status page to show a tooltip
tooltip: 'This is a tooltip for this monitor',
// [OPTIONAL] `statusPageLink` is ONLY used for clickable link at status page
statusPageLink: 'https://example.com',
// [OPTIONAL] `hideLatencyChart` will hide status page latency chart if set to true
hideLatencyChart: false,
// [OPTIONAL] `expectedCodes` is an array of acceptable HTTP response codes, if not specified, default to 2xx
expectedCodes: [200],
// [OPTIONAL] `timeout` in millisecond, if not specified, default to 10000
@@ -58,18 +44,18 @@ const workerConfig: WorkerConfig = {
'User-Agent': 'Uptimeflare',
Authorization: 'Bearer YOUR_TOKEN_HERE',
},
// [OPTIONAL] body to be sent
body: 'Hello, world!',
// [OPTIONAL] body to be sent (require POST/PUT/PATCH method)
// body: 'Hello, world!',
// [OPTIONAL] if specified, the response must contains the keyword to be considered as operational.
responseKeyword: 'success',
// responseKeyword: 'success',
// [OPTIONAL] if specified, the response must NOT contains the keyword to be considered as operational.
responseForbiddenKeyword: 'bad gateway',
// responseForbiddenKeyword: 'bad gateway',
// [OPTIONAL] if specified, will call the check proxy to check the monitor, mainly for geo-specific checks
// refer to docs https://github.com/lyc8503/UptimeFlare/wiki/Check-proxy-setup before setting this value
// currently supports `worker://`, `globalping://` and `http(s)://` proxies
checkProxy: 'https://xxx.example.com OR worker://weur',
// checkProxy: 'worker://weur',
// [OPTIONAL] if true, the check will fallback to local if the specified proxy is down
checkProxyFallback: true,
// checkProxyFallback: true,
},
// Example TCP Monitor
{
@@ -92,11 +78,11 @@ const workerConfig: WorkerConfig = {
// [Required] webhook URL (example: Telegram Bot API)
url: 'https://api.telegram.org/bot123456:ABCDEF/sendMessage',
// [Optional] HTTP method, default to 'GET' for payloadType=param, 'POST' otherwise
method: 'POST',
// method: 'POST',
// [Optional] headers to be sent
headers: {
foo: 'bar',
},
// headers: {
// foo: 'bar',
// },
// [Required] Specify how to encode the payload
// Should be one of 'param', 'json' or 'x-www-form-urlencoded'
// 'param': append url-encoded payload to URL search parameters
@@ -118,43 +104,16 @@ const workerConfig: WorkerConfig = {
// notification will be sent only if the monitor is down for N continuous checks after the initial failure
// if not specified, notification will be sent immediately
gracePeriod: 5,
// [Optional] disable notification for monitors with specified ids
skipNotificationIds: ['foo_monitor', 'bar_monitor'],
// [Optional] suppress extra notifications for error reason changes during an incident, default to false
skipErrorChangeNotification: true,
},
callbacks: {
onStatusChange: async (
env: any,
monitor: any,
isUp: boolean,
timeIncidentStart: number,
timeNow: number,
reason: string
) => {
// This callback will be called when there's a status change for any monitor
// Write any TypeScript code here
// This will not follow the grace period settings and will be called immediately when the status changes
// You need to handle the grace period manually if you want to implement it
},
onIncident: async (
env: any,
monitor: any,
timeIncidentStart: number,
timeNow: number,
reason: string
) => {
// This callback will be called EVERY 1 MINTUE if there's an on-going incident for any monitor
// Write any TypeScript code here
},
},
}
}
// You can define multiple maintenances here
// During maintenance, an alert will be shown at status page
// Also, related downtime notifications will be skipped (if any)
// Of course, you can leave it empty if you don't need this feature
// const maintenances: MaintenanceConfig[] = []
const maintenances: MaintenanceConfig[] = [
{
// [Optional] Monitor IDs to be affected by this maintenance
@@ -164,39 +123,14 @@ const maintenances: MaintenanceConfig[] = [
// Description of the maintenance, will be shown at status page
body: 'This is a test maintenance, server software upgrade',
// Start time of the maintenance, in UNIX timestamp or ISO 8601 format
start: '2025-04-27T00:00:00+08:00',
start: '2020-01-01T00:00:00+08:00',
// [Optional] end time of the maintenance, in UNIX timestamp or ISO 8601 format
// if not specified, the maintenance will be considered as on-going
end: '2025-04-30T00:00:00+08:00',
end: '2050-01-01T00:00:00+08:00',
// [Optional] color of the maintenance alert at status page, default to "yellow"
color: 'blue',
},
// As this config file is a TypeScript file, you can even use IIFE to generate scheduled maintenances
// The following example shows a scheduled maintenance from 2 AM to 4 AM on the 15th of every month (UTC+8)
// This COULD BE DANGEROUS, as generating too many maintenance entries can lead to performance problems
// Undeterministic outputs may also lead to bugs or unexpected behavior
// If you don't know how to DEBUG, use this approach WITH CAUTION
...(function () {
const schedules = []
const today = new Date()
for (let i = -1; i <= 1; i++) {
// JavaScript's Date object will automatically handle year rollovers
const date = new Date(today.getFullYear(), today.getMonth() + i, 15)
const year = date.getFullYear()
const month = String(date.getMonth() + 1).padStart(2, '0')
schedules.push({
title: `${year}/${parseInt(month)} - Test scheduled maintenance`,
monitors: ['foo_monitor'],
body: 'Monthly scheduled maintenance',
start: `${year}-${month}-15T02:00:00.000+08:00`,
end: `${year}-${month}-15T04:00:00.000+08:00`,
})
}
return schedules
})(),
]
// Don't forget this, otherwise compilation fails.
// Don't edit this line
export { maintenances, pageConfig, workerConfig }