feat(snmp_exporter): enable snmp exporter for network monitoring
fix(snmp_exporter): increase scrape_timeout
This commit is contained in:
parent
0d13b5cd69
commit
44a6b658a1
2 changed files with 69 additions and 0 deletions
|
@ -5,5 +5,6 @@
|
|||
{
|
||||
imports = [
|
||||
./victorialogs.nix
|
||||
./snmp.nix
|
||||
];
|
||||
}
|
||||
|
|
68
machines/nixos/vault01/monitoring/snmp.nix
Normal file
68
machines/nixos/vault01/monitoring/snmp.nix
Normal 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";
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue