totoro: prometheus: remove valveindexinstock, add snmp

This commit is contained in:
Luke Granger-Brown 2021-03-14 01:13:37 +00:00
parent a71f4a47f9
commit b51cf06282
2 changed files with 27 additions and 32 deletions

View file

@ -51,7 +51,7 @@ let
};
}];
};
stockExporters = lib.mapAttrsToList (exporterName: exporter: mkExporter exporterName exporter.port) (lib.filterAttrs (_: exporter: exporter.enable) sys.config.services.prometheus.exporters);
stockExporters = lib.mapAttrsToList (exporterName: exporter: mkExporter exporterName exporter.port) (lib.filterAttrs (exporterName: exporter: exporterName != "snmp" && exporter.enable) sys.config.services.prometheus.exporters);
customExporters = lib.mapAttrsToList mkExporter sys.config.my.prometheus.additionalExporterPorts;
in
stockExporters ++ customExporters;

View file

@ -196,25 +196,30 @@ in {
targets = ["localhost:${toString config.services.prometheus.alertmanager.port}"];
}];
}];
scrapeConfigs = builtins.attrValues depot.ops.nixos.systemExporters;
scrapeConfigs = (builtins.attrValues depot.ops.nixos.systemExporters) ++ [{
job_name = "blade-oa/snmp";
metrics_path = "/snmp";
params = {
module = ["hpe"];
};
static_configs = [{
targets = ["10.100.1.200"];
}];
relabel_configs = [{
source_labels = ["__address__"];
target_label = "__param_target";
} {
source_labels = ["__param_target"];
target_label = "instance";
} {
target_label = "__address__";
replacement = "totoro:${toString config.services.prometheus.exporters.snmp.port}";
}];
}];
pushgateway.enable = true;
rules = [
''
groups:
- name: valve_index
rules:
- alert: ValveIndexInStock
expr: valve_index_in_stock > 0
for: 1s
labels:
severity: page
annotations:
summary: "Valve Index in Stock!"
description: "The Valve Index is back in stock."
''
];
rules = [];
alertmanager = {
enable = true;
@ -231,6 +236,11 @@ in {
}];
};
};
exporters.snmp = {
enable = true;
configurationPath = depot.nix.pkgs.prometheus-snmp-config;
};
};
services.grafana = {
enable = true;
@ -279,21 +289,6 @@ in {
};
};
systemd.services.valveindexinstock = {
enable = true;
serviceConfig = {
ExecStart = "${depot.py.valveindexinstock}/bin/valveindexinstock";
DynamicUser = true;
MountAPIVFS = true;
PrivateTmp = true;
PrivateUsers = true;
ProtectControlGroups = true;
ProtectKernelModules = true;
ProtectKernelTunables = true;
};
};
my.prometheus.additionalExporterPorts.valveindexinstock = 9998;
systemd.services.alertmanager-discord = {
enable = true;
serviceConfig = {