modules/nixos/monitoring: import hosts from knownHosts

This commit is contained in:
zowoq 2024-11-03 12:16:44 +10:00
parent cf9f6100a9
commit 06c99f6ef1
3 changed files with 10 additions and 16 deletions
modules/nixos/monitoring

View file

@ -1,4 +1,4 @@
{ pkgs, ... }:
{ inputs, pkgs, ... }:
{
systemd.services.prometheus.after = pkgs.lib.mkForce [ "network-online.target" ];
systemd.services.prometheus.wants = [ "network-online.target" ];
@ -19,11 +19,13 @@
metrics_path = "/metrics";
static_configs =
let
hosts = import ./hosts.nix;
hosts = (import "${inputs.self}/modules/shared/known-hosts.nix").programs.ssh.knownHosts;
in
[
{
targets = map (host: "${host}:9273") hosts ++ [ "localhost:9273" ];
targets = builtins.concatMap (host: map (name: "${name}:9273") host.hostNames) (
builtins.attrValues hosts
);
labels.org = "nix-community";
}
];