prometheus module: add varnishExporter

Corbin 1b839a58 51b247bf

Changed files
+54 -1
nixos
modules
services
monitoring
+3 -1
nixos/modules/module-list.nix
···
./services/monitoring/munin.nix
./services/monitoring/nagios.nix
./services/monitoring/prometheus/default.nix
+
./services/monitoring/prometheus/alertmanager.nix
./services/monitoring/prometheus/nginx-exporter.nix
./services/monitoring/prometheus/node-exporter.nix
-
./services/monitoring/prometheus/alertmanager.nix
+
./services/monitoring/prometheus/snmp-exporter.nix
+
./services/monitoring/prometheus/varnish-exporter.nix
./services/monitoring/riemann.nix
./services/monitoring/riemann-dash.nix
./services/monitoring/riemann-tools.nix
+51
nixos/modules/services/monitoring/prometheus/varnish-exporter.nix
···
+
{ config, pkgs, lib, ... }:
+
+
# Shamelessly cribbed from nginx-exporter.nix. ~ C.
+
with lib;
+
+
let
+
cfg = config.services.prometheus.varnishExporter;
+
in {
+
options = {
+
services.prometheus.varnishExporter = {
+
enable = mkEnableOption "prometheus Varnish exporter";
+
+
port = mkOption {
+
type = types.int;
+
default = 9131;
+
description = ''
+
Port to listen on.
+
'';
+
};
+
+
extraFlags = mkOption {
+
type = types.listOf types.str;
+
default = [];
+
description = ''
+
Extra commandline options when launching the Varnish exporter.
+
'';
+
};
+
};
+
};
+
+
config = mkIf cfg.enable {
+
systemd.services.prometheus-varnish-exporter = {
+
description = "Prometheus exporter for Varnish metrics";
+
unitConfig.Documentation = "https://github.com/jonnenauha/prometheus_varnish_exporter";
+
wantedBy = [ "multi-user.target" ];
+
path = [ pkgs.varnish ];
+
script = ''
+
exec ${pkgs.prometheus-varnish-exporter}/bin/prometheus_varnish_exporter \
+
-web.listen-address :${toString cfg.port} \
+
${concatStringsSep " \\\n " cfg.extraFlags}
+
'';
+
serviceConfig = {
+
User = "nobody";
+
Restart = "always";
+
PrivateTmp = true;
+
WorkingDirectory = /tmp;
+
ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
+
};
+
};
+
};
+
}