feat(snmp_exporter): enable snmp exporter for network monitoring

fix(snmp_exporter): increase scrape_timeout
This commit is contained in:
catvayor 2025-06-08 20:57:11 +02:00
parent 0d13b5cd69
commit 44a6b658a1
Signed by: lbailly
GPG key ID: CE3E645251AC63F3
2 changed files with 69 additions and 0 deletions

View file

@ -5,5 +5,6 @@
{
imports = [
./victorialogs.nix
./snmp.nix
];
}

View file

@ -0,0 +1,68 @@
# SPDX-FileCopyrightText: 2025 Lubin Bailly <lubin@dgnum.eu>
#
# SPDX-License-Identifier: EUPL-1.2
{
pkgs,
lib,
meta,
...
}:
let
inherit (lib) elem filterAttrs mapAttrsToList;
port = 9004;
in
{
dgn-monitoring = {
exporters.ports.snmp = port;
scrapeConfigs = {
"switches" = {
static_configs =
mapAttrsToList
(hostname: cfg: {
targets = [ cfg.deployment.targetHost ];
labels = { inherit hostname; };
})
(
filterAttrs (
_: cfg:
cfg.nixpkgs.system == "netconf"
&& elem cfg.site [
"pot01"
"hyp01"
"hyp02"
]
) meta.nodes
);
scrape_timeout = "30s";
metrics_path = "/snmp";
params = {
auth = [ "public_v2" ];
module = [ "if_mib" ];
};
relabel_configs = [
{
target_label = "__param_target";
source_labels = [ "__address__" ];
}
{
target_label = "instance";
source_labels = [ "__param_target" ];
}
{
target_label = "__address__";
replacement = "localhost:${toString port}";
}
];
};
};
};
services.prometheus.exporters.snmp = {
enable = true;
enableConfigCheck = false;
configurationPath = pkgs.prometheus-snmp-exporter.src + "/snmp.yml";
};
}