Enable Mimir Alertmanager, add example alert #33

Merged
k900 merged 6 commits from alertmanager into main 2024-07-08 06:35:33 +00:00
4 changed files with 18 additions and 18 deletions
Showing only changes of commit 8d2a367e92 - Show all commits

View file

@ -13,14 +13,20 @@ in
enable = (mkEnableOption "Grafana Agent") // { default = true; }; enable = (mkEnableOption "Grafana Agent") // { default = true; };
exporters = mkOption { exporters = mkOption {
description = "List of all exporters to scrape"; description = ''
type = types.listOf (types.submodule { Set of additional exporters to scrape.
The attribute name will be used as `job_name`
internally, which ends up exported as `job` label
on all metrics of that exporter.
'';
type = types.attrsOf (types.submodule {
options.port = mkOption { options.port = mkOption {
description = "Exporter port"; description = "Exporter port";
type = types.int; type = types.int;
}; };
}); });
default = []; default = {};
}; };
}; };
@ -45,14 +51,12 @@ in
configs = [ configs = [
{ {
name = config.networking.hostName; name = config.networking.hostName;
scrape_configs = [ scrape_configs = lib.mapAttrsToList (name: value: {
{ job_name = name;
job_name = config.networking.hostName;
static_configs = [ static_configs = [
{ targets = map (e: "localhost:" + (toString e.port)) config.bagel.monitoring.grafana-agent.exporters; } { targets = "localhost:" + (toString value.port); }
];
}
]; ];
}) config.bagel.monitoring.grafana-agent.exporters;
} }
]; ];
}; };

View file

@ -17,6 +17,6 @@ in
listenAddress = "0.0.0.0"; listenAddress = "0.0.0.0";
}; };
bagel.monitoring.grafana-agent.exporters = [ { port = 9102; } ]; bagel.monitoring.grafana-agent.exporters.cadvisor.port = 9102;
}; };
} }

View file

@ -30,8 +30,6 @@ in
]; ];
}; };
bagel.monitoring.grafana-agent.exporters = [ bagel.monitoring.grafana-agent.exporters.nginxlog.port = 9103;
{ port = 9103; }
];
}; };
} }

View file

@ -24,8 +24,6 @@ in
services.postgresql.settings.shared_preload_libraries = "pg_stat_statements"; services.postgresql.settings.shared_preload_libraries = "pg_stat_statements";
bagel.monitoring.grafana-agent.exporters = [ bagel.monitoring.grafana-agent.exporters.postgres.port = 9104;
{ port = 9104; }
];
}; };
} }