diff --git a/hosts/metrics/default.nix b/hosts/metrics/default.nix index b416c08..91853c1 100644 --- a/hosts/metrics/default.nix +++ b/hosts/metrics/default.nix @@ -21,6 +21,12 @@ in file = ../../secrets/grafana-secret-auth.age; owner = "grafana"; }; + searx-prometheus-secret = { + file = ../../secrets/searx-prometheus-secret.age; + owner = config.users.users."prometheus".name; + group = config.users.groups."prometheus".name; + mode = "0644"; + }; }; my = { @@ -48,7 +54,23 @@ in }; proxy.domain = p.domains.public; }; - prometheus.enable = true; + prometheus = { + enable = true; + extraScrapeConfigs = [ + { + job_name = "caddy"; + static_configs = [ { targets = [ "${p.hosts.caddy}:2024" ]; } ]; + } + { + job_name = "searxng"; + static_configs = [ { targets = [ "${p.hosts.caddy}:8080" ]; } ]; + basic_auth = { + username = "searxng"; + password_file = config.age.secrets.searx-prometheus-secret.path; + }; + } + ]; + }; loki.enable = true; }; diff --git a/modules/monitoring/prometheus.nix b/modules/monitoring/prometheus.nix index 7d3a45f..5bc4575 100644 --- a/modules/monitoring/prometheus.nix +++ b/modules/monitoring/prometheus.nix @@ -15,6 +15,14 @@ in options.my.monitoring.prometheus = { enable = lib.mkEnableOption "Enable prometheus as a data scraper"; + extraScrapeConfigs = lib.mkOption { + default = [ ]; + type = lib.types.listOf lib.types.attrs; + description = '' + Additional scrape configurations to add to Prometheus. + ''; + }; + proxy = { enable = lib.mkEnableOption "Set the proxy entry for this service"; @@ -49,13 +57,6 @@ in config = lib.mkMerge [ (lib.mkIf cfg.enable { - age.secrets.searx-prometheus-secret = { - file = ../../secrets/searx-prometheus-secret.age; - owner = config.users.users."prometheus".name; - group = config.users.groups."prometheus".name; - mode = "0644"; - }; - services.prometheus = { enable = true; scrapeConfigs = [ @@ -73,19 +74,7 @@ in } ]; } - { - job_name = "caddy"; - static_configs = [ { targets = [ "caddy.internal:2024" ]; } ]; - } - { - job_name = "searxng"; - static_configs = [ { targets = [ "caddy.internal:8080" ]; } ]; - basic_auth = { - username = "searxng"; - password_file = config.age.secrets.searx-prometheus-secret.path; - }; - } - ]; + ] ++ cfg.extraScrapeConfigs; }; services.grafana = {