Rollback versionning of services.prometheus.{exporters, alertmanager}.

This commit is contained in:
Jean-Baptiste Giraudeau 2019-03-22 17:03:00 +01:00
parent e17b464a43
commit bfbae97cfa
No known key found for this signature in database
GPG Key ID: E96EF57FD501B961
19 changed files with 848 additions and 903 deletions

View File

@ -4,33 +4,31 @@ with lib;
let let
cfg = config.services.prometheus.alertmanager; cfg = config.services.prometheus.alertmanager;
cfg2 = config.services.prometheus2.alertmanager; mkConfigFile = pkgs.writeText "alertmanager.yml" (builtins.toJSON cfg.configuration);
mkConfigFile = amCfg:
pkgs.writeText "alertmanager.yml" (builtins.toJSON amCfg.configuration);
mkAlertmanagerYml = amCfg: let checkedConfig = file: pkgs.runCommand "checked-config" { buildInputs = [ cfg.package ]; } ''
checkedConfig = file: ln -s ${file} $out
pkgs.runCommand "checked-config" { buildInputs = [ amCfg.package ]; } '' amtool check-config $out
ln -s ${file} $out '';
amtool check-config $out
'';
yml = if amCfg.configText != null then
pkgs.writeText "alertmanager.yml" amCfg.configText
else mkConfigFile amCfg;
in
checkedConfig yml;
mkCmdlineArgs = amCfg: alertmanagerYml = let
amCfg.extraFlags ++ [ yml = if cfg.configText != null then
"--config.file ${mkAlertmanagerYml amCfg}" pkgs.writeText "alertmanager.yml" cfg.configText
"--web.listen-address ${amCfg.listenAddress}:${toString amCfg.port}" else mkConfigFile;
"--log.level ${amCfg.logLevel}" in checkedConfig yml;
] ++ (optional (amCfg.webExternalUrl != null)
"--web.external-url ${amCfg.webExternalUrl}" cmdlineArgs = cfg.extraFlags ++ [
) ++ (optional (amCfg.logFormat != null) "--config.file ${alertmanagerYml}"
"--log.format ${amCfg.logFormat}" "--web.listen-address ${cfg.listenAddress}:${toString cfg.port}"
); "--log.level ${cfg.logLevel}"
amOptions = { ] ++ (optional (cfg.webExternalUrl != null)
"--web.external-url ${cfg.webExternalUrl}"
) ++ (optional (cfg.logFormat != null)
"--log.format ${cfg.logFormat}"
);
in {
options = {
services.prometheus.alertmanager = {
enable = mkEnableOption "Prometheus Alertmanager"; enable = mkEnableOption "Prometheus Alertmanager";
package = mkOption { package = mkOption {
@ -137,40 +135,36 @@ let
''; '';
}; };
}; };
mkAMConfig = amCfg: amVersion: [
(mkIf amCfg.enable {
assertions = singleton {
assertion = amCfg.configuration != null || amCfg.configText != null;
message = "Can not enable alertmanager without a configuration. "
+ "Set either the `configuration` or `configText` attribute.";
};
})
(mkIf amCfg.enable {
networking.firewall.allowedTCPPorts = optional amCfg.openFirewall amCfg.port;
systemd.services."alertmanager${amVersion}" = {
wantedBy = [ "multi-user.target" ];
after = [ "network.target" ];
script = ''
${amCfg.package}/bin/alertmanager \
${concatStringsSep " \\\n " (mkCmdlineArgs amCfg)}
'';
serviceConfig = {
User = amCfg.user;
Group = amCfg.group;
Restart = "always";
PrivateTmp = true;
WorkingDirectory = "/tmp";
ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
};
};
})
];
in {
options = {
services.prometheus.alertmanager = amOptions;
services.prometheus2.alertmanager = amOptions;
}; };
config = mkMerge ((mkAMConfig cfg "") ++ (mkAMConfig cfg2 "2")); config = mkMerge [
(mkIf cfg.enable {
assertions = singleton {
assertion = cfg.configuration != null || cfg.configText != null;
message = "Can not enable alertmanager without a configuration. "
+ "Set either the `configuration` or `configText` attribute.";
};
})
(mkIf cfg.enable {
networking.firewall.allowedTCPPorts = optional cfg.openFirewall cfg.port;
systemd.services.alertmanager = {
wantedBy = [ "multi-user.target" ];
after = [ "network.target" ];
script = ''
${cfg.package}/bin/alertmanager \
${concatStringsSep " \\\n " cmdlineArgs}
'';
serviceConfig = {
User = cfg.user;
Group = cfg.group;
Restart = "always";
PrivateTmp = true;
WorkingDirectory = "/tmp";
ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
};
};
})
];
} }

View File

@ -7,8 +7,6 @@ let
cfg2 = config.services.prometheus2; cfg2 = config.services.prometheus2;
promUser = "prometheus"; promUser = "prometheus";
promGroup = "prometheus"; promGroup = "prometheus";
prom2User = "prometheus2";
prom2Group = "prometheus2";
# Get a submodule without any embedded metadata: # Get a submodule without any embedded metadata:
_filter = x: filterAttrs (k: v: k != "_module") x; _filter = x: filterAttrs (k: v: k != "_module") x;
@ -693,11 +691,11 @@ in {
}; };
}) })
(mkIf cfg2.enable { (mkIf cfg2.enable {
users.groups.${prom2Group}.gid = config.ids.gids.prometheus2; users.groups.${promGroup}.gid = config.ids.gids.prometheus2;
users.users.${prom2User} = { users.users.${promUser} = {
description = "Prometheus2 daemon user"; description = "Prometheus2 daemon user";
uid = config.ids.uids.prometheus2; uid = config.ids.uids.prometheus2;
group = prom2Group; group = promGroup;
home = cfg2.dataDir; home = cfg2.dataDir;
createHome = true; createHome = true;
}; };
@ -710,7 +708,7 @@ in {
${concatStringsSep " \\\n " cmdlineArgs2} ${concatStringsSep " \\\n " cmdlineArgs2}
''; '';
serviceConfig = { serviceConfig = {
User = prom2User; User = promUser;
Restart = "always"; Restart = "always";
WorkingDirectory = cfg2.dataDir; WorkingDirectory = cfg2.dataDir;
}; };

View File

@ -4,10 +4,8 @@ with lib;
let let
cfg = config.services.prometheus.exporters; cfg = config.services.prometheus.exporters;
cfg2 = config.services.prometheus2.exporters;
# each attribute in `exporterOpts` is a function that when executed # each attribute in `exporterOpts` is expected to have specified:
# with `cfg` or `cfg2` as parameter is expected to have specified:
# - port (types.int): port on which the exporter listens # - port (types.int): port on which the exporter listens
# - serviceOpts (types.attrs): config that is merged with the # - serviceOpts (types.attrs): config that is merged with the
# default definition of the exporter's # default definition of the exporter's
@ -110,18 +108,13 @@ let
}; };
}; };
mkSubModules = exCfg: mkSubModules = (foldl' (a: b: a//b) {}
(foldl' (a: b: a//b) {} (mapAttrsToList (name: opts: mkSubModule {
(mapAttrsToList (name: confGen: inherit name;
let inherit (opts) port serviceOpts;
conf = (confGen exCfg); extraOpts = opts.extraOpts or {};
in }) exporterOpts)
mkSubModule { );
inherit name;
inherit (conf) port serviceOpts;
extraOpts = conf.extraOpts or {};
}) exporterOpts)
);
mkExporterConf = { name, conf, serviceOpts }: mkExporterConf = { name, conf, serviceOpts }:
mkIf conf.enable { mkIf conf.enable {
@ -140,36 +133,11 @@ let
serviceConfig.Group = conf.group; serviceConfig.Group = conf.group;
}); });
}; };
mkExportersConfig = exCfg: promVersion:
([{
assertions = [{
assertion = (exCfg.snmp.configurationPath == null) != (exCfg.snmp.configuration == null);
message = ''
Please ensure you have either `services.prometheus.exporters.snmp.configuration'
or `services.prometheus${promVersion}.exporters.snmp.configurationPath' set!
'';
}];
}] ++ [(mkIf config.services.minio.enable {
services."prometheus${promVersion}".exporters.minio = {
minioAddress = mkDefault "http://localhost:9000";
minioAccessKey = mkDefault config.services.minio.accessKey;
minioAccessSecret = mkDefault config.services.minio.secretKey;
};
})] ++ (mapAttrsToList (name: confGen:
let
conf = (confGen exCfg);
in
mkExporterConf {
inherit name;
inherit (conf) serviceOpts;
conf = exCfg.${name};
}) exporterOpts)
);
in in
{ {
options.services.prometheus.exporters = mkOption { options.services.prometheus.exporters = mkOption {
type = types.submodule { type = types.submodule {
options = (mkSubModules cfg); options = (mkSubModules);
}; };
description = "Prometheus exporter configuration"; description = "Prometheus exporter configuration";
default = {}; default = {};
@ -184,24 +152,25 @@ in
''; '';
}; };
options.services.prometheus2.exporters = mkOption { config = mkMerge ([{
type = types.submodule { assertions = [{
options = (mkSubModules cfg2); assertion = (cfg.snmp.configurationPath == null) != (cfg.snmp.configuration == null);
}; message = ''
description = "Prometheus 2 exporter configuration"; Please ensure you have either `services.prometheus.exporters.snmp.configuration'
default = {}; or `services.prometheus.exporters.snmp.configurationPath' set!
example = literalExample '' '';
{ }];
node = { }] ++ [(mkIf config.services.minio.enable {
enable = true; services.prometheus.exporters.minio.minioAddress = mkDefault "http://localhost:9000";
enabledCollectors = [ "systemd" ]; services.prometheus.exporters.minio.minioAccessKey = mkDefault config.services.minio.accessKey;
}; services.prometheus.exporters.minio.minioAccessSecret = mkDefault config.services.minio.secretKey;
varnish.enable = true; })] ++ (mapAttrsToList (name: conf:
} mkExporterConf {
''; inherit name;
}; inherit (conf) serviceOpts;
conf = cfg.${name};
config = mkMerge ((mkExportersConfig cfg "") ++ (mkExportersConfig cfg2 "2")); }) exporterOpts)
);
meta = { meta = {
doc = ./exporters.xml; doc = ./exporters.xml;

View File

@ -2,55 +2,54 @@
with lib; with lib;
baseCfg: let
let cfg = config.services.prometheus.exporters.bind;
cfg = baseCfg.bind; in
in {
{ port = 9119;
port = 9119; extraOpts = {
extraOpts = { bindURI = mkOption {
bindURI = mkOption { type = types.str;
type = types.str; default = "http://localhost:8053/";
default = "http://localhost:8053/"; description = ''
description = '' HTTP XML API address of an Bind server.
HTTP XML API address of an Bind server. '';
'';
};
bindTimeout = mkOption {
type = types.str;
default = "10s";
description = ''
Timeout for trying to get stats from Bind.
'';
};
bindVersion = mkOption {
type = types.enum [ "xml.v2" "xml.v3" "auto" ];
default = "auto";
description = ''
BIND statistics version. Can be detected automatically.
'';
};
bindGroups = mkOption {
type = types.listOf (types.enum [ "server" "view" "tasks" ]);
default = [ "server" "view" ];
description = ''
List of statistics to collect. Available: [server, view, tasks]
'';
};
}; };
serviceOpts = { bindTimeout = mkOption {
serviceConfig = { type = types.str;
DynamicUser = true; default = "10s";
ExecStart = '' description = ''
${pkgs.prometheus-bind-exporter}/bin/bind_exporter \ Timeout for trying to get stats from Bind.
-web.listen-address ${cfg.listenAddress}:${toString cfg.port} \ '';
-bind.pid-file /var/run/named/named.pid \
-bind.timeout ${toString cfg.bindTimeout} \
-bind.stats-url ${cfg.bindURI} \
-bind.stats-version ${cfg.bindVersion} \
-bind.stats-groups ${concatStringsSep "," cfg.bindGroups} \
${concatStringsSep " \\\n " cfg.extraFlags}
'';
};
}; };
} bindVersion = mkOption {
type = types.enum [ "xml.v2" "xml.v3" "auto" ];
default = "auto";
description = ''
BIND statistics version. Can be detected automatically.
'';
};
bindGroups = mkOption {
type = types.listOf (types.enum [ "server" "view" "tasks" ]);
default = [ "server" "view" ];
description = ''
List of statistics to collect. Available: [server, view, tasks]
'';
};
};
serviceOpts = {
serviceConfig = {
DynamicUser = true;
ExecStart = ''
${pkgs.prometheus-bind-exporter}/bin/bind_exporter \
-web.listen-address ${cfg.listenAddress}:${toString cfg.port} \
-bind.pid-file /var/run/named/named.pid \
-bind.timeout ${toString cfg.bindTimeout} \
-bind.stats-url ${cfg.bindURI} \
-bind.stats-version ${cfg.bindVersion} \
-bind.stats-groups ${concatStringsSep "," cfg.bindGroups} \
${concatStringsSep " \\\n " cfg.extraFlags}
'';
};
};
}

View File

@ -2,31 +2,30 @@
with lib; with lib;
baseCfg: let
let cfg = config.services.prometheus.exporters.blackbox;
cfg = baseCfg.blackbox; in
in {
{ port = 9115;
port = 9115; extraOpts = {
extraOpts = { configFile = mkOption {
configFile = mkOption { type = types.path;
type = types.path; description = ''
description = '' Path to configuration file.
Path to configuration file. '';
'';
};
}; };
serviceOpts = { };
serviceConfig = { serviceOpts = {
AmbientCapabilities = [ "CAP_NET_RAW" ]; # for ping probes serviceConfig = {
DynamicUser = true; AmbientCapabilities = [ "CAP_NET_RAW" ]; # for ping probes
ExecStart = '' DynamicUser = true;
${pkgs.prometheus-blackbox-exporter}/bin/blackbox_exporter \ ExecStart = ''
--web.listen-address ${cfg.listenAddress}:${toString cfg.port} \ ${pkgs.prometheus-blackbox-exporter}/bin/blackbox_exporter \
--config.file ${cfg.configFile} \ --web.listen-address ${cfg.listenAddress}:${toString cfg.port} \
${concatStringsSep " \\\n " cfg.extraFlags} --config.file ${cfg.configFile} \
''; ${concatStringsSep " \\\n " cfg.extraFlags}
ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID"; '';
}; ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
}; };
} };
}

View File

@ -2,78 +2,77 @@
with lib; with lib;
baseCfg: let
let cfg = config.services.prometheus.exporters.collectd;
cfg = baseCfg.collectd; in
in {
{ port = 9103;
port = 9103; extraOpts = {
extraOpts = { collectdBinary = {
collectdBinary = { enable = mkEnableOption "collectd binary protocol receiver";
enable = mkEnableOption "collectd binary protocol receiver";
authFile = mkOption { authFile = mkOption {
default = null; default = null;
type = types.nullOr types.path; type = types.nullOr types.path;
description = "File mapping user names to pre-shared keys (passwords)."; description = "File mapping user names to pre-shared keys (passwords).";
};
port = mkOption {
type = types.int;
default = 25826;
description = ''Network address on which to accept collectd binary network packets.'';
};
listenAddress = mkOption {
type = types.str;
default = "0.0.0.0";
description = ''
Address to listen on for binary network packets.
'';
};
securityLevel = mkOption {
type = types.enum ["None" "Sign" "Encrypt"];
default = "None";
description = ''
Minimum required security level for accepted packets.
'';
};
}; };
logFormat = mkOption { port = mkOption {
type = types.int;
default = 25826;
description = ''Network address on which to accept collectd binary network packets.'';
};
listenAddress = mkOption {
type = types.str; type = types.str;
default = "logger:stderr"; default = "0.0.0.0";
example = "logger:syslog?appname=bob&local=7 or logger:stdout?json=true";
description = '' description = ''
Set the log target and format. Address to listen on for binary network packets.
''; '';
}; };
logLevel = mkOption { securityLevel = mkOption {
type = types.enum ["debug" "info" "warn" "error" "fatal"]; type = types.enum ["None" "Sign" "Encrypt"];
default = "info"; default = "None";
description = '' description = ''
Only log messages with the given severity or above. Minimum required security level for accepted packets.
''; '';
}; };
}; };
serviceOpts = let
collectSettingsArgs = if (cfg.collectdBinary.enable) then '' logFormat = mkOption {
-collectd.listen-address ${cfg.collectdBinary.listenAddress}:${toString cfg.collectdBinary.port} \ type = types.str;
-collectd.security-level ${cfg.collectdBinary.securityLevel} \ default = "logger:stderr";
'' else ""; example = "logger:syslog?appname=bob&local=7 or logger:stdout?json=true";
in { description = ''
serviceConfig = { Set the log target and format.
DynamicUser = true; '';
ExecStart = ''
${pkgs.prometheus-collectd-exporter}/bin/collectd_exporter \
-log.format ${cfg.logFormat} \
-log.level ${cfg.logLevel} \
-web.listen-address ${cfg.listenAddress}:${toString cfg.port} \
${collectSettingsArgs} \
${concatStringsSep " \\\n " cfg.extraFlags}
'';
};
}; };
}
logLevel = mkOption {
type = types.enum ["debug" "info" "warn" "error" "fatal"];
default = "info";
description = ''
Only log messages with the given severity or above.
'';
};
};
serviceOpts = let
collectSettingsArgs = if (cfg.collectdBinary.enable) then ''
-collectd.listen-address ${cfg.collectdBinary.listenAddress}:${toString cfg.collectdBinary.port} \
-collectd.security-level ${cfg.collectdBinary.securityLevel} \
'' else "";
in {
serviceConfig = {
DynamicUser = true;
ExecStart = ''
${pkgs.prometheus-collectd-exporter}/bin/collectd_exporter \
-log.format ${cfg.logFormat} \
-log.level ${cfg.logLevel} \
-web.listen-address ${cfg.listenAddress}:${toString cfg.port} \
${collectSettingsArgs} \
${concatStringsSep " \\\n " cfg.extraFlags}
'';
};
};
}

View File

@ -2,39 +2,38 @@
with lib; with lib;
baseCfg: let
let cfg = config.services.prometheus.exporters.dnsmasq;
cfg = baseCfg.dnsmasq; in
in {
{ port = 9153;
port = 9153; extraOpts = {
extraOpts = { dnsmasqListenAddress = mkOption {
dnsmasqListenAddress = mkOption { type = types.str;
type = types.str; default = "localhost:53";
default = "localhost:53"; description = ''
description = '' Address on which dnsmasq listens.
Address on which dnsmasq listens. '';
'';
};
leasesPath = mkOption {
type = types.path;
default = "/var/lib/misc/dnsmasq.leases";
example = "/var/lib/dnsmasq/dnsmasq.leases";
description = ''
Path to the <literal>dnsmasq.leases</literal> file.
'';
};
}; };
serviceOpts = { leasesPath = mkOption {
serviceConfig = { type = types.path;
DynamicUser = true; default = "/var/lib/misc/dnsmasq.leases";
ExecStart = '' example = "/var/lib/dnsmasq/dnsmasq.leases";
${pkgs.prometheus-dnsmasq-exporter}/bin/dnsmasq_exporter \ description = ''
--listen ${cfg.listenAddress}:${toString cfg.port} \ Path to the <literal>dnsmasq.leases</literal> file.
--dnsmasq ${cfg.dnsmasqListenAddress} \ '';
--leases_path ${cfg.leasesPath} \
${concatStringsSep " \\\n " cfg.extraFlags}
'';
};
}; };
} };
serviceOpts = {
serviceConfig = {
DynamicUser = true;
ExecStart = ''
${pkgs.prometheus-dnsmasq-exporter}/bin/dnsmasq_exporter \
--listen ${cfg.listenAddress}:${toString cfg.port} \
--dnsmasq ${cfg.dnsmasqListenAddress} \
--leases_path ${cfg.leasesPath} \
${concatStringsSep " \\\n " cfg.extraFlags}
'';
};
};
}

View File

@ -2,72 +2,71 @@
with lib; with lib;
baseCfg: let
let cfg = config.services.prometheus.exporters.dovecot;
cfg = baseCfg.dovecot; in
in {
{ port = 9166;
port = 9166; extraOpts = {
extraOpts = { telemetryPath = mkOption {
telemetryPath = mkOption { type = types.str;
type = types.str; default = "/metrics";
default = "/metrics"; description = ''
description = '' Path under which to expose metrics.
Path under which to expose metrics. '';
''; };
}; socketPath = mkOption {
socketPath = mkOption { type = types.path;
type = types.path; default = "/var/run/dovecot/stats";
default = "/var/run/dovecot/stats"; example = "/var/run/dovecot2/old-stats";
example = "/var/run/dovecot2/old-stats"; description = ''
description = '' Path under which the stats socket is placed.
Path under which the stats socket is placed. The user/group under which the exporter runs,
The user/group under which the exporter runs, should be able to access the socket in order
should be able to access the socket in order to scrape the metrics successfully.
to scrape the metrics successfully.
Please keep in mind that the stats module has changed in Please keep in mind that the stats module has changed in
<link xlink:href="https://wiki2.dovecot.org/Upgrading/2.3">Dovecot 2.3+</link> which <link xlink:href="https://wiki2.dovecot.org/Upgrading/2.3">Dovecot 2.3+</link> which
is not <link xlink:href="https://github.com/kumina/dovecot_exporter/issues/8">compatible with this exporter</link>. is not <link xlink:href="https://github.com/kumina/dovecot_exporter/issues/8">compatible with this exporter</link>.
The following extra config has to be passed to Dovecot to ensure that recent versions The following extra config has to be passed to Dovecot to ensure that recent versions
work with this exporter: work with this exporter:
<programlisting> <programlisting>
{ {
<xref linkend="opt-services.prometheus.exporters.dovecot.enable" /> = true; <xref linkend="opt-services.prometheus.exporters.dovecot.enable" /> = true;
<xref linkend="opt-services.prometheus.exporters.dovecot.socketPath" /> = "/var/run/dovecot2/old-stats"; <xref linkend="opt-services.prometheus.exporters.dovecot.socketPath" /> = "/var/run/dovecot2/old-stats";
<xref linkend="opt-services.dovecot2.extraConfig" /> = ''' <xref linkend="opt-services.dovecot2.extraConfig" /> = '''
mail_plugins = $mail_plugins old_stats mail_plugins = $mail_plugins old_stats
service old-stats { service old-stats {
unix_listener old-stats { unix_listener old-stats {
user = nobody user = nobody
group = nobody group = nobody
}
} }
'''; }
} ''';
</programlisting> }
''; </programlisting>
}; '';
scopes = mkOption {
type = types.listOf types.str;
default = [ "user" ];
example = [ "user" "global" ];
description = ''
Stats scopes to query.
'';
};
}; };
serviceOpts = { scopes = mkOption {
serviceConfig = { type = types.listOf types.str;
ExecStart = '' default = [ "user" ];
${pkgs.prometheus-dovecot-exporter}/bin/dovecot_exporter \ example = [ "user" "global" ];
--web.listen-address ${cfg.listenAddress}:${toString cfg.port} \ description = ''
--web.telemetry-path ${cfg.telemetryPath} \ Stats scopes to query.
--dovecot.socket-path ${cfg.socketPath} \ '';
--dovecot.scopes ${concatStringsSep "," cfg.scopes} \
${concatStringsSep " \\\n " cfg.extraFlags}
'';
};
}; };
} };
serviceOpts = {
serviceConfig = {
ExecStart = ''
${pkgs.prometheus-dovecot-exporter}/bin/dovecot_exporter \
--web.listen-address ${cfg.listenAddress}:${toString cfg.port} \
--web.telemetry-path ${cfg.telemetryPath} \
--dovecot.socket-path ${cfg.socketPath} \
--dovecot.scopes ${concatStringsSep "," cfg.scopes} \
${concatStringsSep " \\\n " cfg.extraFlags}
'';
};
};
}

View File

@ -2,39 +2,38 @@
with lib; with lib;
baseCfg: let
let cfg = config.services.prometheus.exporters.fritzbox;
cfg = baseCfg.fritzbox; in
in {
{ port = 9133;
port = 9133; extraOpts = {
extraOpts = { gatewayAddress = mkOption {
gatewayAddress = mkOption { type = types.str;
type = types.str; default = "fritz.box";
default = "fritz.box"; description = ''
description = '' The hostname or IP of the FRITZ!Box.
The hostname or IP of the FRITZ!Box. '';
''; };
};
gatewayPort = mkOption { gatewayPort = mkOption {
type = types.int; type = types.int;
default = 49000; default = 49000;
description = '' description = ''
The port of the FRITZ!Box UPnP service. The port of the FRITZ!Box UPnP service.
''; '';
};
}; };
serviceOpts = { };
serviceConfig = { serviceOpts = {
DynamicUser = true; serviceConfig = {
ExecStart = '' DynamicUser = true;
${pkgs.prometheus-fritzbox-exporter}/bin/fritzbox_exporter \ ExecStart = ''
-listen-address ${cfg.listenAddress}:${toString cfg.port} \ ${pkgs.prometheus-fritzbox-exporter}/bin/fritzbox_exporter \
-gateway-address ${cfg.gatewayAddress} \ -listen-address ${cfg.listenAddress}:${toString cfg.port} \
-gateway-port ${toString cfg.gatewayPort} \ -gateway-address ${cfg.gatewayAddress} \
${concatStringsSep " \\\n " cfg.extraFlags} -gateway-port ${toString cfg.gatewayPort} \
''; ${concatStringsSep " \\\n " cfg.extraFlags}
}; '';
}; };
} };
}

View File

@ -2,36 +2,35 @@
with lib; with lib;
baseCfg: let
let cfg = config.services.prometheus.exporters.json;
cfg = baseCfg.json; in
in {
{ port = 7979;
port = 7979; extraOpts = {
extraOpts = { url = mkOption {
url = mkOption { type = types.str;
type = types.str; description = ''
description = '' URL to scrape JSON from.
URL to scrape JSON from. '';
'';
};
configFile = mkOption {
type = types.path;
description = ''
Path to configuration file.
'';
};
listenAddress = {}; # not used
}; };
serviceOpts = { configFile = mkOption {
serviceConfig = { type = types.path;
DynamicUser = true; description = ''
ExecStart = '' Path to configuration file.
${pkgs.prometheus-json-exporter}/bin/prometheus-json-exporter \ '';
--port ${toString cfg.port} \
${cfg.url} ${cfg.configFile} \
${concatStringsSep " \\\n " cfg.extraFlags}
'';
};
}; };
} listenAddress = {}; # not used
};
serviceOpts = {
serviceConfig = {
DynamicUser = true;
ExecStart = ''
${pkgs.prometheus-json-exporter}/bin/prometheus-json-exporter \
--port ${toString cfg.port} \
${cfg.url} ${cfg.configFile} \
${concatStringsSep " \\\n " cfg.extraFlags}
'';
};
};
}

View File

@ -2,65 +2,64 @@
with lib; with lib;
baseCfg: let
let cfg = config.services.prometheus.exporters.minio;
cfg = baseCfg.minio; in
in {
{ port = 9290;
port = 9290; extraOpts = {
extraOpts = { minioAddress = mkOption {
minioAddress = mkOption { type = types.str;
type = types.str; example = "https://10.0.0.1:9000";
example = "https://10.0.0.1:9000"; description = ''
description = '' The URL of the minio server.
The URL of the minio server. Use HTTPS if Minio accepts secure connections only.
Use HTTPS if Minio accepts secure connections only. By default this connects to the local minio server if enabled.
By default this connects to the local minio server if enabled. '';
'';
};
minioAccessKey = mkOption {
type = types.str;
example = "yourMinioAccessKey";
description = ''
The value of the Minio access key.
It is required in order to connect to the server.
By default this uses the one from the local minio server if enabled
and <literal>config.services.minio.accessKey</literal>.
'';
};
minioAccessSecret = mkOption {
type = types.str;
description = ''
The value of the Minio access secret.
It is required in order to connect to the server.
By default this uses the one from the local minio server if enabled
and <literal>config.services.minio.secretKey</literal>.
'';
};
minioBucketStats = mkOption {
type = types.bool;
default = false;
description = ''
Collect statistics about the buckets and files in buckets.
It requires more computation, use it carefully in case of large buckets..
'';
};
}; };
serviceOpts = {
serviceConfig = { minioAccessKey = mkOption {
DynamicUser = true; type = types.str;
ExecStart = '' example = "yourMinioAccessKey";
${pkgs.prometheus-minio-exporter}/bin/minio-exporter \ description = ''
-web.listen-address ${cfg.listenAddress}:${toString cfg.port} \ The value of the Minio access key.
-minio.server ${cfg.minioAddress} \ It is required in order to connect to the server.
-minio.access-key ${cfg.minioAccessKey} \ By default this uses the one from the local minio server if enabled
-minio.access-secret ${cfg.minioAccessSecret} \ and <literal>config.services.minio.accessKey</literal>.
${optionalString cfg.minioBucketStats "-minio.bucket-stats"} \ '';
${concatStringsSep " \\\n " cfg.extraFlags}
'';
};
}; };
}
minioAccessSecret = mkOption {
type = types.str;
description = ''
The value of the Minio access secret.
It is required in order to connect to the server.
By default this uses the one from the local minio server if enabled
and <literal>config.services.minio.secretKey</literal>.
'';
};
minioBucketStats = mkOption {
type = types.bool;
default = false;
description = ''
Collect statistics about the buckets and files in buckets.
It requires more computation, use it carefully in case of large buckets..
'';
};
};
serviceOpts = {
serviceConfig = {
DynamicUser = true;
ExecStart = ''
${pkgs.prometheus-minio-exporter}/bin/minio-exporter \
-web.listen-address ${cfg.listenAddress}:${toString cfg.port} \
-minio.server ${cfg.minioAddress} \
-minio.access-key ${cfg.minioAccessKey} \
-minio.access-secret ${cfg.minioAccessSecret} \
${optionalString cfg.minioBucketStats "-minio.bucket-stats"} \
${concatStringsSep " \\\n " cfg.extraFlags}
'';
};
};
}

View File

@ -2,47 +2,46 @@
with lib; with lib;
baseCfg: let
let cfg = config.services.prometheus.exporters.nginx;
cfg = baseCfg.nginx; in
in {
{ port = 9113;
port = 9113; extraOpts = {
extraOpts = { scrapeUri = mkOption {
scrapeUri = mkOption { type = types.str;
type = types.str; default = "http://localhost/nginx_status";
default = "http://localhost/nginx_status"; description = ''
description = '' Address to access the nginx status page.
Address to access the nginx status page. Can be enabled with services.nginx.statusPage = true.
Can be enabled with services.nginx.statusPage = true. '';
'';
};
telemetryEndpoint = mkOption {
type = types.str;
default = "/metrics";
description = ''
Path under which to expose metrics.
'';
};
insecure = mkOption {
type = types.bool;
default = true;
description = ''
Ignore server certificate if using https.
'';
};
}; };
serviceOpts = { telemetryEndpoint = mkOption {
serviceConfig = { type = types.str;
DynamicUser = true; default = "/metrics";
ExecStart = '' description = ''
${pkgs.prometheus-nginx-exporter}/bin/nginx_exporter \ Path under which to expose metrics.
--nginx.scrape_uri '${cfg.scrapeUri}' \ '';
--telemetry.address ${cfg.listenAddress}:${toString cfg.port} \
--telemetry.endpoint ${cfg.telemetryEndpoint} \
--insecure ${toString cfg.insecure} \
${concatStringsSep " \\\n " cfg.extraFlags}
'';
};
}; };
} insecure = mkOption {
type = types.bool;
default = true;
description = ''
Ignore server certificate if using https.
'';
};
};
serviceOpts = {
serviceConfig = {
DynamicUser = true;
ExecStart = ''
${pkgs.prometheus-nginx-exporter}/bin/nginx_exporter \
--nginx.scrape_uri '${cfg.scrapeUri}' \
--telemetry.address ${cfg.listenAddress}:${toString cfg.port} \
--telemetry.endpoint ${cfg.telemetryEndpoint} \
--insecure ${toString cfg.insecure} \
${concatStringsSep " \\\n " cfg.extraFlags}
'';
};
};
}

View File

@ -2,40 +2,39 @@
with lib; with lib;
baseCfg: let
let cfg = config.services.prometheus.exporters.node;
cfg = baseCfg.node; in
in {
{ port = 9100;
port = 9100; extraOpts = {
extraOpts = { enabledCollectors = mkOption {
enabledCollectors = mkOption { type = types.listOf types.string;
type = types.listOf types.string; default = [];
default = []; example = ''[ "systemd" ]'';
example = ''[ "systemd" ]''; description = ''
description = '' Collectors to enable. The collectors listed here are enabled in addition to the default ones.
Collectors to enable. The collectors listed here are enabled in addition to the default ones. '';
'';
};
disabledCollectors = mkOption {
type = types.listOf types.str;
default = [];
example = ''[ "timex" ]'';
description = ''
Collectors to disable which are enabled by default.
'';
};
}; };
serviceOpts = { disabledCollectors = mkOption {
serviceConfig = { type = types.listOf types.str;
RuntimeDirectory = "prometheus-node-exporter"; default = [];
ExecStart = '' example = ''[ "timex" ]'';
${pkgs.prometheus-node-exporter}/bin/node_exporter \ description = ''
${concatMapStringsSep " " (x: "--collector." + x) cfg.enabledCollectors} \ Collectors to disable which are enabled by default.
${concatMapStringsSep " " (x: "--no-collector." + x) cfg.disabledCollectors} \ '';
--web.listen-address ${cfg.listenAddress}:${toString cfg.port} \
${concatStringsSep " \\\n " cfg.extraFlags}
'';
};
}; };
} };
serviceOpts = {
serviceConfig = {
RuntimeDirectory = "prometheus-node-exporter";
ExecStart = ''
${pkgs.prometheus-node-exporter}/bin/node_exporter \
${concatMapStringsSep " " (x: "--collector." + x) cfg.enabledCollectors} \
${concatMapStringsSep " " (x: "--no-collector." + x) cfg.disabledCollectors} \
--web.listen-address ${cfg.listenAddress}:${toString cfg.port} \
${concatStringsSep " \\\n " cfg.extraFlags}
'';
};
};
}

View File

@ -2,81 +2,80 @@
with lib; with lib;
baseCfg: let
let cfg = config.services.prometheus.exporters.postfix;
cfg = baseCfg.postfix; in
in {
{ port = 9154;
port = 9154; extraOpts = {
extraOpts = { telemetryPath = mkOption {
telemetryPath = mkOption { type = types.str;
default = "/metrics";
description = ''
Path under which to expose metrics.
'';
};
logfilePath = mkOption {
type = types.path;
default = "/var/log/postfix_exporter_input.log";
example = "/var/log/mail.log";
description = ''
Path where Postfix writes log entries.
This file will be truncated by this exporter!
'';
};
showqPath = mkOption {
type = types.path;
default = "/var/spool/postfix/public/showq";
example = "/var/lib/postfix/queue/public/showq";
description = ''
Path where Postfix places it's showq socket.
'';
};
systemd = {
enable = mkEnableOption ''
reading metrics from the systemd-journal instead of from a logfile
'';
unit = mkOption {
type = types.str; type = types.str;
default = "/metrics"; default = "postfix.service";
description = '' description = ''
Path under which to expose metrics. Name of the postfix systemd unit.
''; '';
}; };
logfilePath = mkOption { slice = mkOption {
type = types.path; type = types.nullOr types.str;
default = "/var/log/postfix_exporter_input.log"; default = null;
example = "/var/log/mail.log";
description = '' description = ''
Path where Postfix writes log entries. Name of the postfix systemd slice.
This file will be truncated by this exporter! This overrides the <option>systemd.unit</option>.
''; '';
}; };
showqPath = mkOption { journalPath = mkOption {
type = types.path; type = types.nullOr types.path;
default = "/var/spool/postfix/public/showq"; default = null;
example = "/var/lib/postfix/queue/public/showq";
description = '' description = ''
Path where Postfix places it's showq socket. Path to the systemd journal.
'';
};
systemd = {
enable = mkEnableOption ''
reading metrics from the systemd-journal instead of from a logfile
'';
unit = mkOption {
type = types.str;
default = "postfix.service";
description = ''
Name of the postfix systemd unit.
'';
};
slice = mkOption {
type = types.nullOr types.str;
default = null;
description = ''
Name of the postfix systemd slice.
This overrides the <option>systemd.unit</option>.
'';
};
journalPath = mkOption {
type = types.nullOr types.path;
default = null;
description = ''
Path to the systemd journal.
'';
};
};
};
serviceOpts = {
serviceConfig = {
ExecStart = ''
${pkgs.prometheus-postfix-exporter}/bin/postfix_exporter \
--web.listen-address ${cfg.listenAddress}:${toString cfg.port} \
--web.telemetry-path ${cfg.telemetryPath} \
--postfix.showq_path ${cfg.showqPath} \
${concatStringsSep " \\\n " (cfg.extraFlags
++ optional cfg.systemd.enable "--systemd.enable"
++ optional cfg.systemd.enable (if cfg.systemd.slice != null
then "--systemd.slice ${cfg.systemd.slice}"
else "--systemd.unit ${cfg.systemd.unit}")
++ optional (cfg.systemd.enable && (cfg.systemd.journalPath != null))
"--systemd.jounal_path ${cfg.systemd.journalPath}"
++ optional (!cfg.systemd.enable) "--postfix.logfile_path ${cfg.logfilePath}")}
''; '';
}; };
}; };
} };
serviceOpts = {
serviceConfig = {
ExecStart = ''
${pkgs.prometheus-postfix-exporter}/bin/postfix_exporter \
--web.listen-address ${cfg.listenAddress}:${toString cfg.port} \
--web.telemetry-path ${cfg.telemetryPath} \
--postfix.showq_path ${cfg.showqPath} \
${concatStringsSep " \\\n " (cfg.extraFlags
++ optional cfg.systemd.enable "--systemd.enable"
++ optional cfg.systemd.enable (if cfg.systemd.slice != null
then "--systemd.slice ${cfg.systemd.slice}"
else "--systemd.unit ${cfg.systemd.unit}")
++ optional (cfg.systemd.enable && (cfg.systemd.journalPath != null))
"--systemd.jounal_path ${cfg.systemd.journalPath}"
++ optional (!cfg.systemd.enable) "--postfix.logfile_path ${cfg.logfilePath}")}
'';
};
};
}

View File

@ -2,71 +2,70 @@
with lib; with lib;
baseCfg: let
let cfg = config.services.prometheus.exporters.snmp;
cfg = baseCfg.snmp; in
in {
{ port = 9116;
port = 9116; extraOpts = {
extraOpts = { configurationPath = mkOption {
configurationPath = mkOption { type = types.nullOr types.path;
type = types.nullOr types.path; default = null;
default = null; description = ''
description = '' Path to a snmp exporter configuration file. Mutually exclusive with 'configuration' option.
Path to a snmp exporter configuration file. Mutually exclusive with 'configuration' option. '';
''; example = "./snmp.yml";
example = "./snmp.yml"; };
};
configuration = mkOption { configuration = mkOption {
type = types.nullOr types.attrs; type = types.nullOr types.attrs;
default = {}; default = {};
description = '' description = ''
Snmp exporter configuration as nix attribute set. Mutually exclusive with 'configurationPath' option. Snmp exporter configuration as nix attribute set. Mutually exclusive with 'configurationPath' option.
''; '';
example = '' example = ''
{ {
"default" = { "default" = {
"version" = 2; "version" = 2;
"auth" = { "auth" = {
"community" = "public"; "community" = "public";
};
}; };
}; };
''; };
}; '';
logFormat = mkOption {
type = types.str;
default = "logger:stderr";
description = ''
Set the log target and format.
'';
};
logLevel = mkOption {
type = types.enum ["debug" "info" "warn" "error" "fatal"];
default = "info";
description = ''
Only log messages with the given severity or above.
'';
};
}; };
serviceOpts = let
configFile = if cfg.configurationPath != null logFormat = mkOption {
then cfg.configurationPath type = types.str;
else "${pkgs.writeText "snmp-eporter-conf.yml" (builtins.toJSON cfg.configuration)}"; default = "logger:stderr";
in { description = ''
serviceConfig = { Set the log target and format.
DynamicUser = true; '';
ExecStart = ''
${pkgs.prometheus-snmp-exporter.bin}/bin/snmp_exporter \
--config.file ${configFile} \
--log.format ${cfg.logFormat} \
--log.level ${cfg.logLevel} \
--web.listen-address ${cfg.listenAddress}:${toString cfg.port} \
${concatStringsSep " \\\n " cfg.extraFlags}
'';
};
}; };
}
logLevel = mkOption {
type = types.enum ["debug" "info" "warn" "error" "fatal"];
default = "info";
description = ''
Only log messages with the given severity or above.
'';
};
};
serviceOpts = let
configFile = if cfg.configurationPath != null
then cfg.configurationPath
else "${pkgs.writeText "snmp-eporter-conf.yml" (builtins.toJSON cfg.configuration)}";
in {
serviceConfig = {
DynamicUser = true;
ExecStart = ''
${pkgs.prometheus-snmp-exporter.bin}/bin/snmp_exporter \
--config.file=${configFile} \
--log.format=${cfg.logFormat} \
--log.level=${cfg.logLevel} \
--web.listen-address=${cfg.listenAddress}:${toString cfg.port} \
${concatStringsSep " \\\n " cfg.extraFlags}
'';
};
};
}

View File

@ -2,32 +2,31 @@
with lib; with lib;
baseCfg: let
let cfg = config.services.prometheus.exporters.surfboard;
cfg = baseCfg.surfboard; in
in {
{ port = 9239;
port = 9239; extraOpts = {
extraOpts = { modemAddress = mkOption {
modemAddress = mkOption { type = types.str;
type = types.str; default = "192.168.100.1";
default = "192.168.100.1"; description = ''
description = '' The hostname or IP of the cable modem.
The hostname or IP of the cable modem. '';
'';
};
}; };
serviceOpts = { };
description = "Prometheus exporter for surfboard cable modem"; serviceOpts = {
unitConfig.Documentation = "https://github.com/ipstatic/surfboard_exporter"; description = "Prometheus exporter for surfboard cable modem";
serviceConfig = { unitConfig.Documentation = "https://github.com/ipstatic/surfboard_exporter";
DynamicUser = true; serviceConfig = {
ExecStart = '' DynamicUser = true;
${pkgs.prometheus-surfboard-exporter}/bin/surfboard_exporter \ ExecStart = ''
--web.listen-address ${cfg.listenAddress}:${toString cfg.port} \ ${pkgs.prometheus-surfboard-exporter}/bin/surfboard_exporter \
--modem-address ${cfg.modemAddress} \ --web.listen-address ${cfg.listenAddress}:${toString cfg.port} \
${concatStringsSep " \\\n " cfg.extraFlags} --modem-address ${cfg.modemAddress} \
''; ${concatStringsSep " \\\n " cfg.extraFlags}
}; '';
}; };
} };
}

View File

@ -2,45 +2,44 @@
with lib; with lib;
baseCfg: let
let cfg = config.services.prometheus.exporters.tor;
cfg = baseCfg.tor; in
in {
{ port = 9130;
port = 9130; extraOpts = {
extraOpts = { torControlAddress = mkOption {
torControlAddress = mkOption { type = types.str;
type = types.str; default = "127.0.0.1";
default = "127.0.0.1"; description = ''
description = '' Tor control IP address or hostname.
Tor control IP address or hostname. '';
'';
};
torControlPort = mkOption {
type = types.int;
default = 9051;
description = ''
Tor control port.
'';
};
}; };
serviceOpts = {
serviceConfig = {
DynamicUser = true;
ExecStart = ''
${pkgs.prometheus-tor-exporter}/bin/prometheus-tor-exporter \
-b ${cfg.listenAddress} \
-p ${toString cfg.port} \
-a ${cfg.torControlAddress} \
-c ${toString cfg.torControlPort} \
${concatStringsSep " \\\n " cfg.extraFlags}
'';
};
# CPython requires a process to either have $HOME defined or run as a UID torControlPort = mkOption {
# defined in /etc/passwd. The latter is false with DynamicUser, so define a type = types.int;
# dummy $HOME. https://bugs.python.org/issue10496 default = 9051;
environment = { HOME = "/var/empty"; }; description = ''
Tor control port.
'';
}; };
} };
serviceOpts = {
serviceConfig = {
DynamicUser = true;
ExecStart = ''
${pkgs.prometheus-tor-exporter}/bin/prometheus-tor-exporter \
-b ${cfg.listenAddress} \
-p ${toString cfg.port} \
-a ${cfg.torControlAddress} \
-c ${toString cfg.torControlPort} \
${concatStringsSep " \\\n " cfg.extraFlags}
'';
};
# CPython requires a process to either have $HOME defined or run as a UID
# defined in /etc/passwd. The latter is false with DynamicUser, so define a
# dummy $HOME. https://bugs.python.org/issue10496
environment = { HOME = "/var/empty"; };
};
}

View File

@ -2,67 +2,66 @@
with lib; with lib;
baseCfg: let
let cfg = config.services.prometheus.exporters.unifi;
cfg = baseCfg.unifi; in
in {
{ port = 9130;
port = 9130; extraOpts = {
extraOpts = { unifiAddress = mkOption {
unifiAddress = mkOption { type = types.str;
type = types.str; example = "https://10.0.0.1:8443";
example = "https://10.0.0.1:8443"; description = ''
description = '' URL of the UniFi Controller API.
URL of the UniFi Controller API. '';
'';
};
unifiInsecure = mkOption {
type = types.bool;
default = false;
description = ''
If enabled skip the verification of the TLS certificate of the UniFi Controller API.
Use with caution.
'';
};
unifiUsername = mkOption {
type = types.str;
example = "ReadOnlyUser";
description = ''
username for authentication against UniFi Controller API.
'';
};
unifiPassword = mkOption {
type = types.str;
description = ''
Password for authentication against UniFi Controller API.
'';
};
unifiTimeout = mkOption {
type = types.str;
default = "5s";
example = "2m";
description = ''
Timeout including unit for UniFi Controller API requests.
'';
};
}; };
serviceOpts = {
serviceConfig = { unifiInsecure = mkOption {
DynamicUser = true; type = types.bool;
ExecStart = '' default = false;
${pkgs.prometheus-unifi-exporter}/bin/unifi_exporter \ description = ''
-telemetry.addr ${cfg.listenAddress}:${toString cfg.port} \ If enabled skip the verification of the TLS certificate of the UniFi Controller API.
-unifi.addr ${cfg.unifiAddress} \ Use with caution.
-unifi.username ${cfg.unifiUsername} \ '';
-unifi.password ${cfg.unifiPassword} \
-unifi.timeout ${cfg.unifiTimeout} \
${optionalString cfg.unifiInsecure "-unifi.insecure" } \
${concatStringsSep " \\\n " cfg.extraFlags}
'';
};
}; };
}
unifiUsername = mkOption {
type = types.str;
example = "ReadOnlyUser";
description = ''
username for authentication against UniFi Controller API.
'';
};
unifiPassword = mkOption {
type = types.str;
description = ''
Password for authentication against UniFi Controller API.
'';
};
unifiTimeout = mkOption {
type = types.str;
default = "5s";
example = "2m";
description = ''
Timeout including unit for UniFi Controller API requests.
'';
};
};
serviceOpts = {
serviceConfig = {
DynamicUser = true;
ExecStart = ''
${pkgs.prometheus-unifi-exporter}/bin/unifi_exporter \
-telemetry.addr ${cfg.listenAddress}:${toString cfg.port} \
-unifi.addr ${cfg.unifiAddress} \
-unifi.username ${cfg.unifiUsername} \
-unifi.password ${cfg.unifiPassword} \
-unifi.timeout ${cfg.unifiTimeout} \
${optionalString cfg.unifiInsecure "-unifi.insecure" } \
${concatStringsSep " \\\n " cfg.extraFlags}
'';
};
};
}

View File

@ -2,88 +2,87 @@
with lib; with lib;
baseCfg: let
let cfg = config.services.prometheus.exporters.varnish;
cfg = baseCfg.varnish; in
in {
{ port = 9131;
port = 9131; extraOpts = {
extraOpts = { noExit = mkOption {
noExit = mkOption { type = types.bool;
type = types.bool; default = false;
default = false; description = ''
description = '' Do not exit server on Varnish scrape errors.
Do not exit server on Varnish scrape errors. '';
'';
};
withGoMetrics = mkOption {
type = types.bool;
default = false;
description = ''
Export go runtime and http handler metrics.
'';
};
verbose = mkOption {
type = types.bool;
default = false;
description = ''
Enable verbose logging.
'';
};
raw = mkOption {
type = types.bool;
default = false;
description = ''
Enable raw stdout logging without timestamps.
'';
};
varnishStatPath = mkOption {
type = types.str;
default = "varnishstat";
description = ''
Path to varnishstat.
'';
};
instance = mkOption {
type = types.nullOr types.str;
default = null;
description = ''
varnishstat -n value.
'';
};
healthPath = mkOption {
type = types.nullOr types.str;
default = null;
description = ''
Path under which to expose healthcheck. Disabled unless configured.
'';
};
telemetryPath = mkOption {
type = types.str;
default = "/metrics";
description = ''
Path under which to expose metrics.
'';
};
}; };
serviceOpts = { withGoMetrics = mkOption {
path = [ pkgs.varnish ]; type = types.bool;
serviceConfig = { default = false;
DynamicUser = true; description = ''
RestartSec = mkDefault 1; Export go runtime and http handler metrics.
ExecStart = '' '';
${pkgs.prometheus-varnish-exporter}/bin/prometheus_varnish_exporter \
--web.listen-address ${cfg.listenAddress}:${toString cfg.port} \
--web.telemetry-path ${cfg.telemetryPath} \
--varnishstat-path ${cfg.varnishStatPath} \
${concatStringsSep " \\\n " (cfg.extraFlags
++ optional (cfg.healthPath != null) "--web.health-path ${cfg.healthPath}"
++ optional (cfg.instance != null) "-n ${cfg.instance}"
++ optional cfg.noExit "--no-exit"
++ optional cfg.withGoMetrics "--with-go-metrics"
++ optional cfg.verbose "--verbose"
++ optional cfg.raw "--raw")}
'';
};
}; };
} verbose = mkOption {
type = types.bool;
default = false;
description = ''
Enable verbose logging.
'';
};
raw = mkOption {
type = types.bool;
default = false;
description = ''
Enable raw stdout logging without timestamps.
'';
};
varnishStatPath = mkOption {
type = types.str;
default = "varnishstat";
description = ''
Path to varnishstat.
'';
};
instance = mkOption {
type = types.nullOr types.str;
default = null;
description = ''
varnishstat -n value.
'';
};
healthPath = mkOption {
type = types.nullOr types.str;
default = null;
description = ''
Path under which to expose healthcheck. Disabled unless configured.
'';
};
telemetryPath = mkOption {
type = types.str;
default = "/metrics";
description = ''
Path under which to expose metrics.
'';
};
};
serviceOpts = {
path = [ pkgs.varnish ];
serviceConfig = {
DynamicUser = true;
RestartSec = mkDefault 1;
ExecStart = ''
${pkgs.prometheus-varnish-exporter}/bin/prometheus_varnish_exporter \
--web.listen-address ${cfg.listenAddress}:${toString cfg.port} \
--web.telemetry-path ${cfg.telemetryPath} \
--varnishstat-path ${cfg.varnishStatPath} \
${concatStringsSep " \\\n " (cfg.extraFlags
++ optional (cfg.healthPath != null) "--web.health-path ${cfg.healthPath}"
++ optional (cfg.instance != null) "-n ${cfg.instance}"
++ optional cfg.noExit "--no-exit"
++ optional cfg.withGoMetrics "--with-go-metrics"
++ optional cfg.verbose "--verbose"
++ optional cfg.raw "--raw")}
'';
};
};
}