Add YAML config loading with validation, env overrides for secrets, and a web dashboard exposing health, stats, and recent events.
38 lines
741 B
V
38 lines
741 B
V
module sources
|
|
|
|
pub fn transform_http_down(check HttpCheck, err string) Event {
|
|
mut message := ''
|
|
if check.template != '' {
|
|
vars := {
|
|
'url': check.url
|
|
'error': err
|
|
'status': ''
|
|
}
|
|
message = render_source_template(check.template, vars)
|
|
} else {
|
|
message = '❌ ${check.url} → ${err}'
|
|
}
|
|
return Event{
|
|
source: 'http_poll'
|
|
name: check.url
|
|
topic: check.topic
|
|
priority: check.priority
|
|
tags: ['x']
|
|
message: message
|
|
raw: err
|
|
}
|
|
}
|
|
|
|
pub fn transform_http_up(check HttpCheck) Event {
|
|
message := '✅ ${check.url} is UP'
|
|
return Event{
|
|
source: 'http_poll'
|
|
name: check.url
|
|
topic: check.topic
|
|
priority: 1
|
|
tags: ['white_check_mark']
|
|
message: message
|
|
raw: ''
|
|
}
|
|
}
|