Merge pull request #172084 from priegger/prometheus-statsd-exporter

Sandro bf46d7b6 8a011883

Changed files
+39
nixos
modules
services
monitoring
prometheus
tests
+1
nixos/modules/services/monitoring/prometheus/exporters.nix
···
"smartctl"
"smokeping"
"sql"
+
"statsd"
"surfboard"
"systemd"
"tor"
+19
nixos/modules/services/monitoring/prometheus/exporters/statsd.nix
···
+
{ config, lib, pkgs, options }:
+
+
with lib;
+
+
let
+
cfg = config.services.prometheus.exporters.statsd;
+
in
+
{
+
port = 9102;
+
serviceOpts = {
+
serviceConfig = {
+
ExecStart = ''
+
${pkgs.prometheus-statsd-exporter}/bin/statsd_exporter \
+
--web.listen-address ${cfg.listenAddress}:${toString cfg.port} \
+
${concatStringsSep " \\\n " cfg.extraFlags}
+
'';
+
};
+
};
+
}
+19
nixos/tests/prometheus-exporters.nix
···
'';
};
+
statsd = {
+
exporterConfig = {
+
enable = true;
+
};
+
exporterTest = ''
+
wait_for_unit("prometheus-statsd-exporter.service")
+
wait_for_open_port(9102)
+
succeed("curl http://localhost:9102/metrics | grep 'statsd_exporter_build_info{'")
+
succeed(
+
"echo 'test.udp:1|c' > /dev/udp/localhost/9125",
+
"curl http://localhost:9102/metrics | grep 'test_udp 1'",
+
)
+
succeed(
+
"echo 'test.tcp:1|c' > /dev/tcp/localhost/9125",
+
"curl http://localhost:9102/metrics | grep 'test_tcp 1'",
+
)
+
'';
+
};
+
surfboard = {
exporterConfig = {
enable = true;