Add YAML config loading with validation, env overrides for secrets, and a web dashboard exposing health, stats, and recent events.
42 lines
1.1 KiB
V
42 lines
1.1 KiB
V
module main
|
|
|
|
import sources
|
|
|
|
fn test_transform_uptime_kuma_down() {
|
|
raw := '{"monitor":{"name":"Gitea"},"heartbeat":{"status":"down","msg":"503","time":"14:32"}}'
|
|
src := sources.UptimeKumaSource{
|
|
name: 'Critical'
|
|
webhook_path: '/webhooks/kuma'
|
|
topic: 'alerts'
|
|
state_map: {
|
|
'down': sources.UptimeKumaState{
|
|
priority: 5
|
|
tags: ['rotating_light']
|
|
}
|
|
}
|
|
}
|
|
event := sources.transform_uptime_kuma(raw, src) or { panic(err) }
|
|
assert event.source == 'uptime_kuma'
|
|
assert event.priority == 5
|
|
assert event.message.contains('Gitea')
|
|
assert event.message.contains('DOWN')
|
|
}
|
|
|
|
fn test_transform_uptime_kuma_up() {
|
|
raw := '{"monitor":{"name":"Gitea"},"heartbeat":{"status":"up"}}'
|
|
src := sources.UptimeKumaSource{
|
|
name: 'Critical'
|
|
webhook_path: '/webhooks/kuma'
|
|
topic: 'alerts'
|
|
state_map: {
|
|
'up': sources.UptimeKumaState{
|
|
priority: 1
|
|
tags: ['white_check_mark']
|
|
}
|
|
}
|
|
}
|
|
event := sources.transform_uptime_kuma(raw, src) or { panic(err) }
|
|
assert event.priority == 1
|
|
assert event.message.contains('UP')
|
|
}
|