From af7ac78b9715b37dc3b887c0ebb16ba36f0ec227 Mon Sep 17 00:00:00 2001 From: Kjetil Orbekk Date: Mon, 8 Mar 2021 23:38:44 -0500 Subject: ap2 scrape --- modules/monitoring.nix | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/monitoring.nix b/modules/monitoring.nix index 4530dd2..9f7287e 100644 --- a/modules/monitoring.nix +++ b/modules/monitoring.nix @@ -23,6 +23,14 @@ in type = lib.types.int; default = aliases.services.prometheus-exporter.port; }; + prometheus-snmp-exporter-port = lib.mkOption { + type = lib.types.int; + default = aliases.services.prometheus-snmp-exporter.port; + }; + snmp-targets = lib.mkOption { + type = lib.types.listOf lib.types.str; + default = [ aliases.ip.ap2 ]; + }; }; }; @@ -56,8 +64,21 @@ in scrapeConfigs = [ { job_name = "self"; + static_configs = [ + { targets = ["127.0.0.1:${toString cfg.prometheus-exporter-port}"]; } + ]; + } + { + job_name = "snmp"; + metrics_path = "/snmp"; + params = { module = [ "if_mib" ]; }; + relabel_configs = [ + { source_labels = ["__address__"]; target_label = "__param_target"; } + { source_labels = ["__param_target"]; target_label = "instance"; } + { source_labels = []; target_label = "__address__"; replacement = "localhost:${toString cfg.prometheus-snmp-exporter-port}"; } + ]; static_configs = [{ - targets = ["127.0.0.1:${toString cfg.prometheus-exporter-port}"]; + targets = cfg.snmp-targets; }]; } ]; @@ -68,6 +89,11 @@ in enabledCollectors = [ "systemd" ]; port = cfg.prometheus-exporter-port; }; + snmp = { + enable = true; + configurationPath = "${pkgs.prometheus-snmp-exporter.src}/snmp.yml"; + port = cfg.prometheus-snmp-exporter-port; + }; }; }; -- cgit v1.2.3