mirror of
https://forgejo.altau.su/lego/lego-monitoring.git
synced 2026-03-10 12:45:19 +00:00
add slugs to checks, enabling sending them to healthchecks
This commit is contained in:
parent
be7b3dbeed
commit
5c57e1765e
8 changed files with 87 additions and 7 deletions
|
|
@ -54,9 +54,28 @@ async def send_alert(alert: Alert, note: str = "") -> None:
|
|||
# if temp_client:
|
||||
# await client.close()
|
||||
|
||||
# TODO ping healthchecks if enabled
|
||||
if alert.healthchecks_slug is not None:
|
||||
raise NotImplementedError
|
||||
|
||||
async def send_healthchecks_status(alert: Alert) -> None:
|
||||
def get_pinging_key(keys: dict[str, str]):
|
||||
if alert.healthchecks_slug in keys:
|
||||
return keys[alert.healthchecks_slug]
|
||||
else:
|
||||
return keys["default"]
|
||||
|
||||
if alert.healthchecks_slug is None:
|
||||
return
|
||||
try:
|
||||
hc_client = cvars.healthchecks_client.get()
|
||||
except LookupError:
|
||||
raise NotImplementedError # TODO
|
||||
if hc_client is None:
|
||||
return
|
||||
config = cvars.config.get()
|
||||
key = get_pinging_key(config.alert_channels.healthchecks.pinging_keys)
|
||||
if alert.severity == Severity.OK:
|
||||
await hc_client.success(key, alert.healthchecks_slug, create=True, log=alert.plain_message)
|
||||
else:
|
||||
await hc_client.failure(key, alert.healthchecks_slug, create=True, log=alert.plain_message)
|
||||
|
||||
|
||||
# TODO service itself has to be monitored like everything else - with regular pinging - if we're
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue