prepare config for healthchecks integration

This commit is contained in:
Alex Tau 2025-08-13 16:59:23 +03:00
parent 4558cf9e6f
commit c01ab8303c
8 changed files with 89 additions and 34 deletions

View file

@ -31,9 +31,15 @@ package:
serviceConfigFile = json.generate "config.json" {
enabled_check_sets = cfg.enabledCheckSets;
log_level = cfg.logLevel;
telegram = with cfg.telegram; {
creds_secret_path = credsSecretPath;
room_id = roomId;
alert_channels = {
telegram = with cfg.alertChannels.telegram; if enable then
{
creds_secret_path = credsSecretPath;
room_id = roomId;
} else null;
healthchecks = with cfg.alertChannels.healthchecks; if enable then {
pinging_keys_secret_path = pingingKeysSecretPath;
} else null;
};
checks = {
temp.sensors = lib.mapAttrs (_: sensorCfg: {

View file

@ -50,14 +50,32 @@ in
* vulnix -- periodically scans system for known CVEs, alerts if any are found (NixOS only)'';
};
telegram = {
credsSecretPath = lib.mkOption {
type = lib.types.str;
description = "Path to a file containing Telegram api_id, api_hash, and bot token, separated by the `,` character.";
alertChannels = {
telegram = {
enable = lib.mkEnableOption "Telegram notification channel";
credsSecretPath = lib.mkOption {
type = lib.types.str;
default = "";
description = "Path to a file containing Telegram api_id, api_hash, and bot token, separated by the `,` character.";
};
roomId = lib.mkOption {
type = lib.types.int;
default = 0;
description = "ID of chat where to send alerts.";
};
};
roomId = lib.mkOption {
type = lib.types.int;
description = "ID of chat where to send alerts.";
healthchecks = {
enable = lib.mkEnableOption "[Healthchecks](https://healthchecks.io) notification channel";
pingingKeysSecretPath = lib.mkOption {
type = lib.types.str;
default = "";
description = ''
Path to a file containing the pinging keys in a `slug:key` format, one on each line (ex: `lego-cpu:aaaaaaaaaaaaaaaaaaaaaa`).
Specify `default` as the slug to use this key for check types that don't have a key explicitly assigned to them.
If you are unsure of the exact slug a check will generate, it is recommended to try it out with the default key first, before
assigning a specific one.'';
};
};
};