aboutsummaryrefslogtreecommitdiff
path: root/nixpkgs/nixos/modules/services/monitoring/prometheus/exporters
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/nixos/modules/services/monitoring/prometheus/exporters')
-rw-r--r--nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/bind.nix54
-rw-r--r--nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/blackbox.nix37
-rw-r--r--nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/collectd.nix77
-rw-r--r--nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/dnsmasq.nix38
-rw-r--r--nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/dovecot.nix73
-rw-r--r--nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/fritzbox.nix38
-rw-r--r--nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/json.nix35
-rw-r--r--nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/mail.nix157
-rw-r--r--nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/minio.nix64
-rw-r--r--nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/nginx.nix54
-rw-r--r--nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/node.nix40
-rw-r--r--nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/postfix.nix82
-rw-r--r--nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/postgres.nix47
-rw-r--r--nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/rspamd.nix92
-rw-r--r--nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/snmp.nix70
-rw-r--r--nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/surfboard.nix31
-rw-r--r--nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/tor.nix44
-rw-r--r--nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/unifi.nix66
-rw-r--r--nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/varnish.nix88
-rw-r--r--nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/wireguard.nix61
20 files changed, 1248 insertions, 0 deletions
diff --git a/nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/bind.nix b/nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/bind.nix
new file mode 100644
index 00000000000..972632b5a24
--- /dev/null
+++ b/nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/bind.nix
@@ -0,0 +1,54 @@
+{ config, lib, pkgs, options }:
+
+with lib;
+
+let
+ cfg = config.services.prometheus.exporters.bind;
+in
+{
+ port = 9119;
+ extraOpts = {
+ bindURI = mkOption {
+ type = types.str;
+ default = "http://localhost:8053/";
+ description = ''
+ 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 = {
+ serviceConfig = {
+ 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}
+ '';
+ };
+ };
+}
diff --git a/nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/blackbox.nix b/nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/blackbox.nix
new file mode 100644
index 00000000000..ca4366121e1
--- /dev/null
+++ b/nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/blackbox.nix
@@ -0,0 +1,37 @@
+{ config, lib, pkgs, options }:
+
+with lib;
+
+let
+ cfg = config.services.prometheus.exporters.blackbox;
+
+ checkConfig = file: pkgs.runCommand "checked-blackbox-exporter.conf" {
+ preferLocalBuild = true;
+ buildInputs = [ pkgs.buildPackages.prometheus-blackbox-exporter ]; } ''
+ ln -s ${file} $out
+ blackbox_exporter --config.check --config.file $out
+ '';
+in
+{
+ port = 9115;
+ extraOpts = {
+ configFile = mkOption {
+ type = types.path;
+ description = ''
+ Path to configuration file.
+ '';
+ };
+ };
+ serviceOpts = {
+ serviceConfig = {
+ AmbientCapabilities = [ "CAP_NET_RAW" ]; # for ping probes
+ ExecStart = ''
+ ${pkgs.prometheus-blackbox-exporter}/bin/blackbox_exporter \
+ --web.listen-address ${cfg.listenAddress}:${toString cfg.port} \
+ --config.file ${checkConfig cfg.configFile} \
+ ${concatStringsSep " \\\n " cfg.extraFlags}
+ '';
+ ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
+ };
+ };
+}
diff --git a/nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/collectd.nix b/nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/collectd.nix
new file mode 100644
index 00000000000..1cc34641809
--- /dev/null
+++ b/nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/collectd.nix
@@ -0,0 +1,77 @@
+{ config, lib, pkgs, options }:
+
+with lib;
+
+let
+ cfg = config.services.prometheus.exporters.collectd;
+in
+{
+ port = 9103;
+ extraOpts = {
+ collectdBinary = {
+ enable = mkEnableOption "collectd binary protocol receiver";
+
+ authFile = mkOption {
+ default = null;
+ type = types.nullOr types.path;
+ 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 {
+ type = types.str;
+ default = "logger:stderr";
+ example = "logger:syslog?appname=bob&local=7 or logger:stdout?json=true";
+ 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
+ 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 = {
+ 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}
+ '';
+ };
+ };
+}
diff --git a/nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/dnsmasq.nix b/nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/dnsmasq.nix
new file mode 100644
index 00000000000..e9fa26cb1f5
--- /dev/null
+++ b/nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/dnsmasq.nix
@@ -0,0 +1,38 @@
+{ config, lib, pkgs, options }:
+
+with lib;
+
+let
+ cfg = config.services.prometheus.exporters.dnsmasq;
+in
+{
+ port = 9153;
+ extraOpts = {
+ dnsmasqListenAddress = mkOption {
+ type = types.str;
+ default = "localhost:53";
+ description = ''
+ 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 = {
+ serviceConfig = {
+ 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}
+ '';
+ };
+ };
+}
diff --git a/nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/dovecot.nix b/nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/dovecot.nix
new file mode 100644
index 00000000000..a01074758ff
--- /dev/null
+++ b/nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/dovecot.nix
@@ -0,0 +1,73 @@
+{ config, lib, pkgs, options }:
+
+with lib;
+
+let
+ cfg = config.services.prometheus.exporters.dovecot;
+in
+{
+ port = 9166;
+ extraOpts = {
+ telemetryPath = mkOption {
+ type = types.str;
+ default = "/metrics";
+ description = ''
+ Path under which to expose metrics.
+ '';
+ };
+ socketPath = mkOption {
+ type = types.path;
+ default = "/var/run/dovecot/stats";
+ example = "/var/run/dovecot2/old-stats";
+ description = ''
+ Path under which the stats socket is placed.
+ The user/group under which the exporter runs,
+ should be able to access the socket in order
+ to scrape the metrics successfully.
+
+ 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
+ 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
+ work with this exporter:
+ <programlisting>
+ {
+ <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.dovecot2.extraConfig" /> = '''
+ mail_plugins = $mail_plugins old_stats
+ service old-stats {
+ unix_listener old-stats {
+ user = dovecot-exporter
+ group = dovecot-exporter
+ }
+ }
+ ''';
+ }
+ </programlisting>
+ '';
+ };
+ scopes = mkOption {
+ type = types.listOf types.str;
+ default = [ "user" ];
+ example = [ "user" "global" ];
+ description = ''
+ Stats scopes to query.
+ '';
+ };
+ };
+ serviceOpts = {
+ serviceConfig = {
+ DynamicUser = false;
+ 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}
+ '';
+ };
+ };
+}
diff --git a/nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/fritzbox.nix b/nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/fritzbox.nix
new file mode 100644
index 00000000000..9526597b8c9
--- /dev/null
+++ b/nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/fritzbox.nix
@@ -0,0 +1,38 @@
+{ config, lib, pkgs, options }:
+
+with lib;
+
+let
+ cfg = config.services.prometheus.exporters.fritzbox;
+in
+{
+ port = 9133;
+ extraOpts = {
+ gatewayAddress = mkOption {
+ type = types.str;
+ default = "fritz.box";
+ description = ''
+ The hostname or IP of the FRITZ!Box.
+ '';
+ };
+
+ gatewayPort = mkOption {
+ type = types.int;
+ default = 49000;
+ description = ''
+ The port of the FRITZ!Box UPnP service.
+ '';
+ };
+ };
+ serviceOpts = {
+ serviceConfig = {
+ ExecStart = ''
+ ${pkgs.prometheus-fritzbox-exporter}/bin/exporter \
+ -listen-address ${cfg.listenAddress}:${toString cfg.port} \
+ -gateway-address ${cfg.gatewayAddress} \
+ -gateway-port ${toString cfg.gatewayPort} \
+ ${concatStringsSep " \\\n " cfg.extraFlags}
+ '';
+ };
+ };
+}
diff --git a/nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/json.nix b/nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/json.nix
new file mode 100644
index 00000000000..82a55bafc98
--- /dev/null
+++ b/nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/json.nix
@@ -0,0 +1,35 @@
+{ config, lib, pkgs, options }:
+
+with lib;
+
+let
+ cfg = config.services.prometheus.exporters.json;
+in
+{
+ port = 7979;
+ extraOpts = {
+ url = mkOption {
+ type = types.str;
+ description = ''
+ URL to scrape JSON from.
+ '';
+ };
+ configFile = mkOption {
+ type = types.path;
+ description = ''
+ Path to configuration file.
+ '';
+ };
+ listenAddress = {}; # not used
+ };
+ serviceOpts = {
+ serviceConfig = {
+ ExecStart = ''
+ ${pkgs.prometheus-json-exporter}/bin/prometheus-json-exporter \
+ --port ${toString cfg.port} \
+ ${cfg.url} ${cfg.configFile} \
+ ${concatStringsSep " \\\n " cfg.extraFlags}
+ '';
+ };
+ };
+}
diff --git a/nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/mail.nix b/nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/mail.nix
new file mode 100644
index 00000000000..7d8c6fb6140
--- /dev/null
+++ b/nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/mail.nix
@@ -0,0 +1,157 @@
+{ config, lib, pkgs, options }:
+
+with lib;
+
+let
+ cfg = config.services.prometheus.exporters.mail;
+
+ configurationFile = pkgs.writeText "prometheus-mail-exporter.conf" (builtins.toJSON (
+ # removes the _module attribute, null values and converts attrNames to lowercase
+ mapAttrs' (name: value:
+ if name == "servers"
+ then nameValuePair (toLower name)
+ ((map (srv: (mapAttrs' (n: v: nameValuePair (toLower n) v)
+ (filterAttrs (n: v: !(n == "_module" || v == null)) srv)
+ ))) value)
+ else nameValuePair (toLower name) value
+ ) (filterAttrs (n: _: !(n == "_module")) cfg.configuration)
+ ));
+
+ serverOptions.options = {
+ name = mkOption {
+ type = types.str;
+ description = ''
+ Value for label 'configname' which will be added to all metrics.
+ '';
+ };
+ server = mkOption {
+ type = types.str;
+ description = ''
+ Hostname of the server that should be probed.
+ '';
+ };
+ port = mkOption {
+ type = types.int;
+ example = 587;
+ description = ''
+ Port to use for SMTP.
+ '';
+ };
+ from = mkOption {
+ type = types.str;
+ example = "exporteruser@domain.tld";
+ description = ''
+ Content of 'From' Header for probing mails.
+ '';
+ };
+ to = mkOption {
+ type = types.str;
+ example = "exporteruser@domain.tld";
+ description = ''
+ Content of 'To' Header for probing mails.
+ '';
+ };
+ detectionDir = mkOption {
+ type = types.path;
+ example = "/var/spool/mail/exporteruser/new";
+ description = ''
+ Directory in which new mails for the exporter user are placed.
+ Note that this needs to exist when the exporter starts.
+ '';
+ };
+ login = mkOption {
+ type = types.nullOr types.str;
+ default = null;
+ example = "exporteruser@domain.tld";
+ description = ''
+ Username to use for SMTP authentication.
+ '';
+ };
+ passphrase = mkOption {
+ type = types.nullOr types.str;
+ default = null;
+ description = ''
+ Password to use for SMTP authentication.
+ '';
+ };
+ };
+
+ exporterOptions.options = {
+ monitoringInterval = mkOption {
+ type = types.str;
+ example = "10s";
+ description = ''
+ Time interval between two probe attempts.
+ '';
+ };
+ mailCheckTimeout = mkOption {
+ type = types.str;
+ description = ''
+ Timeout until mails are considered "didn't make it".
+ '';
+ };
+ disableFileDelition = mkOption {
+ type = types.bool;
+ default = false;
+ description = ''
+ Disables the exporter's function to delete probing mails.
+ '';
+ };
+ servers = mkOption {
+ type = types.listOf (types.submodule serverOptions);
+ default = [];
+ example = literalExample ''
+ [ {
+ name = "testserver";
+ server = "smtp.domain.tld";
+ port = 587;
+ from = "exporteruser@domain.tld";
+ to = "exporteruser@domain.tld";
+ detectionDir = "/path/to/Maildir/new";
+ } ]
+ '';
+ description = ''
+ List of servers that should be probed.
+ '';
+ };
+ };
+in
+{
+ port = 9225;
+ extraOpts = {
+ configFile = mkOption {
+ type = types.nullOr types.path;
+ default = null;
+ description = ''
+ Specify the mailexporter configuration file to use.
+ '';
+ };
+ configuration = mkOption {
+ type = types.submodule exporterOptions;
+ default = {};
+ description = ''
+ Specify the mailexporter configuration file to use.
+ '';
+ };
+ telemetryPath = mkOption {
+ type = types.str;
+ default = "/metrics";
+ description = ''
+ Path under which to expose metrics.
+ '';
+ };
+ };
+ serviceOpts = {
+ serviceConfig = {
+ DynamicUser = false;
+ ExecStart = ''
+ ${pkgs.prometheus-mail-exporter}/bin/mailexporter \
+ --web.listen-address ${cfg.listenAddress}:${toString cfg.port} \
+ --config.file ${
+ if cfg.configuration != {} then configurationFile else cfg.configFile
+ } \
+ ${concatStringsSep " \\\n " cfg.extraFlags}
+ '';
+ };
+ };
+}
diff --git a/nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/minio.nix b/nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/minio.nix
new file mode 100644
index 00000000000..ab3e3d7d5d5
--- /dev/null
+++ b/nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/minio.nix
@@ -0,0 +1,64 @@
+{ config, lib, pkgs, options }:
+
+with lib;
+
+let
+ cfg = config.services.prometheus.exporters.minio;
+in
+{
+ port = 9290;
+ extraOpts = {
+ minioAddress = mkOption {
+ type = types.str;
+ example = "https://10.0.0.1:9000";
+ description = ''
+ The URL of the minio server.
+ Use HTTPS if Minio accepts secure connections only.
+ 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 = {
+ 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}
+ '';
+ };
+ };
+}
diff --git a/nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/nginx.nix b/nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/nginx.nix
new file mode 100644
index 00000000000..554377df37b
--- /dev/null
+++ b/nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/nginx.nix
@@ -0,0 +1,54 @@
+{ config, lib, pkgs, options }:
+
+with lib;
+
+let
+ cfg = config.services.prometheus.exporters.nginx;
+in
+{
+ port = 9113;
+ extraOpts = {
+ scrapeUri = mkOption {
+ type = types.str;
+ default = "http://localhost/nginx_status";
+ description = ''
+ Address to access the nginx status page.
+ Can be enabled with services.nginx.statusPage = true.
+ '';
+ };
+ telemetryPath = mkOption {
+ type = types.str;
+ default = "/metrics";
+ description = ''
+ Path under which to expose metrics.
+ '';
+ };
+ sslVerify = mkOption {
+ type = types.bool;
+ default = true;
+ description = ''
+ Whether to perform certificate verification for https.
+ '';
+ };
+
+ };
+ serviceOpts = {
+ serviceConfig = {
+ ExecStart = ''
+ ${pkgs.prometheus-nginx-exporter}/bin/nginx-prometheus-exporter \
+ --nginx.scrape-uri '${cfg.scrapeUri}' \
+ --nginx.ssl-verify ${toString cfg.sslVerify} \
+ --web.listen-address ${cfg.listenAddress}:${toString cfg.port} \
+ --web.telemetry-path ${cfg.telemetryPath} \
+ ${concatStringsSep " \\\n " cfg.extraFlags}
+ '';
+ };
+ };
+ imports = [
+ (mkRenamedOptionModule [ "telemetryEndpoint" ] [ "telemetryPath" ])
+ (mkRemovedOptionModule [ "insecure" ] ''
+ This option was replaced by 'prometheus.exporters.nginx.sslVerify'.
+ '')
+ ({ options.warnings = options.warnings; })
+ ];
+}
diff --git a/nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/node.nix b/nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/node.nix
new file mode 100644
index 00000000000..adc2abe0b91
--- /dev/null
+++ b/nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/node.nix
@@ -0,0 +1,40 @@
+{ config, lib, pkgs, options }:
+
+with lib;
+
+let
+ cfg = config.services.prometheus.exporters.node;
+in
+{
+ port = 9100;
+ extraOpts = {
+ enabledCollectors = mkOption {
+ type = types.listOf types.str;
+ default = [];
+ example = ''[ "systemd" ]'';
+ description = ''
+ 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 = {
+ serviceConfig = {
+ DynamicUser = false;
+ 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 " " cfg.extraFlags}
+ '';
+ };
+ };
+}
diff --git a/nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/postfix.nix b/nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/postfix.nix
new file mode 100644
index 00000000000..f40819e826b
--- /dev/null
+++ b/nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/postfix.nix
@@ -0,0 +1,82 @@
+{ config, lib, pkgs, options }:
+
+with lib;
+
+let
+ cfg = config.services.prometheus.exporters.postfix;
+in
+{
+ port = 9154;
+ extraOpts = {
+ 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;
+ 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 = {
+ DynamicUser = false;
+ 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}")}
+ '';
+ };
+ };
+}
diff --git a/nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/postgres.nix b/nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/postgres.nix
new file mode 100644
index 00000000000..1ece73a1159
--- /dev/null
+++ b/nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/postgres.nix
@@ -0,0 +1,47 @@
+{ config, lib, pkgs, options }:
+
+with lib;
+
+let
+ cfg = config.services.prometheus.exporters.postgres;
+in
+{
+ port = 9187;
+ extraOpts = {
+ telemetryPath = mkOption {
+ type = types.str;
+ default = "/metrics";
+ description = ''
+ Path under which to expose metrics.
+ '';
+ };
+ dataSourceName = mkOption {
+ type = types.str;
+ default = "user=postgres database=postgres host=/run/postgresql sslmode=disable";
+ example = "postgresql://username:password@localhost:5432/postgres?sslmode=disable";
+ description = ''
+ Accepts PostgreSQL URI form and key=value form arguments.
+ '';
+ };
+ runAsLocalSuperUser = mkOption {
+ type = types.bool;
+ default = false;
+ description = ''
+ Whether to run the exporter as the local 'postgres' super user.
+ '';
+ };
+ };
+ serviceOpts = {
+ environment.DATA_SOURCE_NAME = cfg.dataSourceName;
+ serviceConfig = {
+ DynamicUser = false;
+ User = mkIf cfg.runAsLocalSuperUser (mkForce "postgres");
+ ExecStart = ''
+ ${pkgs.prometheus-postgres-exporter}/bin/postgres_exporter \
+ --web.listen-address ${cfg.listenAddress}:${toString cfg.port} \
+ --web.telemetry-path ${cfg.telemetryPath} \
+ ${concatStringsSep " \\\n " cfg.extraFlags}
+ '';
+ };
+ };
+}
diff --git a/nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/rspamd.nix b/nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/rspamd.nix
new file mode 100644
index 00000000000..1f02ae20724
--- /dev/null
+++ b/nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/rspamd.nix
@@ -0,0 +1,92 @@
+{ config, lib, pkgs, options }:
+
+with lib;
+
+let
+ cfg = config.services.prometheus.exporters.rspamd;
+
+ prettyJSON = conf:
+ pkgs.runCommand "rspamd-exporter-config.yml" { } ''
+ echo '${builtins.toJSON conf}' | ${pkgs.buildPackages.jq}/bin/jq '.' > $out
+ '';
+
+ generateConfig = extraLabels: (map (path: {
+ name = "rspamd_${replaceStrings [ "." " " ] [ "_" "_" ] path}";
+ path = "$.${path}";
+ labels = extraLabels;
+ }) [
+ "actions.'add header'"
+ "actions.'no action'"
+ "actions.'rewrite subject'"
+ "actions.'soft reject'"
+ "actions.greylist"
+ "actions.reject"
+ "bytes_allocated"
+ "chunks_allocated"
+ "chunks_freed"
+ "chunks_oversized"
+ "connections"
+ "control_connections"
+ "ham_count"
+ "learned"
+ "pools_allocated"
+ "pools_freed"
+ "read_only"
+ "scanned"
+ "shared_chunks_allocated"
+ "spam_count"
+ "total_learns"
+ ]) ++ [{
+ name = "rspamd_statfiles";
+ type = "object";
+ path = "$.statfiles[*]";
+ labels = recursiveUpdate {
+ symbol = "$.symbol";
+ type = "$.type";
+ } extraLabels;
+ values = {
+ revision = "$.revision";
+ size = "$.size";
+ total = "$.total";
+ used = "$.used";
+ languages = "$.languages";
+ users = "$.users";
+ };
+ }];
+in
+{
+ port = 7980;
+ extraOpts = {
+ listenAddress = {}; # not used
+
+ url = mkOption {
+ type = types.str;
+ description = ''
+ URL to the rspamd metrics endpoint.
+ Defaults to http://localhost:11334/stat when
+ <option>services.rspamd.enable</option> is true.
+ '';
+ };
+
+ extraLabels = mkOption {
+ type = types.attrsOf types.str;
+ default = {
+ host = config.networking.hostName;
+ };
+ defaultText = "{ host = config.networking.hostName; }";
+ example = literalExample ''
+ {
+ host = config.networking.hostName;
+ custom_label = "some_value";
+ }
+ '';
+ description = "Set of labels added to each metric.";
+ };
+ };
+ serviceOpts.serviceConfig.ExecStart = ''
+ ${pkgs.prometheus-json-exporter}/bin/prometheus-json-exporter \
+ --port ${toString cfg.port} \
+ ${cfg.url} ${prettyJSON (generateConfig cfg.extraLabels)} \
+ ${concatStringsSep " \\\n " cfg.extraFlags}
+ '';
+}
diff --git a/nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/snmp.nix b/nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/snmp.nix
new file mode 100644
index 00000000000..fe7ae8a8ac9
--- /dev/null
+++ b/nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/snmp.nix
@@ -0,0 +1,70 @@
+{ config, lib, pkgs, options }:
+
+with lib;
+
+let
+ cfg = config.services.prometheus.exporters.snmp;
+in
+{
+ port = 9116;
+ extraOpts = {
+ configurationPath = mkOption {
+ type = types.nullOr types.path;
+ default = null;
+ description = ''
+ Path to a snmp exporter configuration file. Mutually exclusive with 'configuration' option.
+ '';
+ example = "./snmp.yml";
+ };
+
+ configuration = mkOption {
+ type = types.nullOr types.attrs;
+ default = {};
+ description = ''
+ Snmp exporter configuration as nix attribute set. Mutually exclusive with 'configurationPath' option.
+ '';
+ example = ''
+ {
+ "default" = {
+ "version" = 2;
+ "auth" = {
+ "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
+ then cfg.configurationPath
+ else "${pkgs.writeText "snmp-eporter-conf.yml" (builtins.toJSON cfg.configuration)}";
+ in {
+ serviceConfig = {
+ 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}
+ '';
+ };
+ };
+}
diff --git a/nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/surfboard.nix b/nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/surfboard.nix
new file mode 100644
index 00000000000..81c5c70ed93
--- /dev/null
+++ b/nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/surfboard.nix
@@ -0,0 +1,31 @@
+{ config, lib, pkgs, options }:
+
+with lib;
+
+let
+ cfg = config.services.prometheus.exporters.surfboard;
+in
+{
+ port = 9239;
+ extraOpts = {
+ modemAddress = mkOption {
+ type = types.str;
+ default = "192.168.100.1";
+ description = ''
+ The hostname or IP of the cable modem.
+ '';
+ };
+ };
+ serviceOpts = {
+ description = "Prometheus exporter for surfboard cable modem";
+ unitConfig.Documentation = "https://github.com/ipstatic/surfboard_exporter";
+ serviceConfig = {
+ ExecStart = ''
+ ${pkgs.prometheus-surfboard-exporter}/bin/surfboard_exporter \
+ --web.listen-address ${cfg.listenAddress}:${toString cfg.port} \
+ --modem-address ${cfg.modemAddress} \
+ ${concatStringsSep " \\\n " cfg.extraFlags}
+ '';
+ };
+ };
+}
diff --git a/nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/tor.nix b/nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/tor.nix
new file mode 100644
index 00000000000..36c473677ef
--- /dev/null
+++ b/nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/tor.nix
@@ -0,0 +1,44 @@
+{ config, lib, pkgs, options }:
+
+with lib;
+
+let
+ cfg = config.services.prometheus.exporters.tor;
+in
+{
+ port = 9130;
+ extraOpts = {
+ torControlAddress = mkOption {
+ type = types.str;
+ default = "127.0.0.1";
+ description = ''
+ Tor control IP address or hostname.
+ '';
+ };
+
+ torControlPort = mkOption {
+ type = types.int;
+ default = 9051;
+ description = ''
+ Tor control port.
+ '';
+ };
+ };
+ serviceOpts = {
+ serviceConfig = {
+ 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"; };
+ };
+}
diff --git a/nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/unifi.nix b/nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/unifi.nix
new file mode 100644
index 00000000000..9aa0f1b85aa
--- /dev/null
+++ b/nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/unifi.nix
@@ -0,0 +1,66 @@
+{ config, lib, pkgs, options }:
+
+with lib;
+
+let
+ cfg = config.services.prometheus.exporters.unifi;
+in
+{
+ port = 9130;
+ extraOpts = {
+ unifiAddress = mkOption {
+ type = types.str;
+ example = "https://10.0.0.1:8443";
+ description = ''
+ 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 = {
+ 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}
+ '';
+ };
+ };
+}
diff --git a/nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/varnish.nix b/nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/varnish.nix
new file mode 100644
index 00000000000..12153fa021e
--- /dev/null
+++ b/nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/varnish.nix
@@ -0,0 +1,88 @@
+{ config, lib, pkgs, options }:
+
+with lib;
+
+let
+ cfg = config.services.prometheus.exporters.varnish;
+in
+{
+ port = 9131;
+ extraOpts = {
+ noExit = mkOption {
+ type = types.bool;
+ default = false;
+ description = ''
+ 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 = {
+ path = [ pkgs.varnish ];
+ serviceConfig = {
+ RestartSec = mkDefault 1;
+ DynamicUser = false;
+ 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")}
+ '';
+ };
+ };
+}
diff --git a/nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/wireguard.nix b/nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/wireguard.nix
new file mode 100644
index 00000000000..8ae2c927b58
--- /dev/null
+++ b/nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/wireguard.nix
@@ -0,0 +1,61 @@
+{ config, lib, pkgs, options }:
+
+with lib;
+
+let
+ cfg = config.services.prometheus.exporters.wireguard;
+in {
+ port = 9586;
+ extraOpts = {
+ verbose = mkEnableOption "Verbose logging mode for prometheus-wireguard-exporter";
+
+ wireguardConfig = mkOption {
+ type = with types; nullOr (either path str);
+ default = null;
+
+ description = ''
+ Path to the Wireguard Config to
+ <link xlink:href="https://github.com/MindFlavor/prometheus_wireguard_exporter/tree/2.0.0#usage">add the peer's name to the stats of a peer</link>.
+
+ Please note that <literal>networking.wg-quick</literal> is required for this feature
+ as <literal>networking.wireguard</literal> uses
+ <citerefentry><refentrytitle>wg</refentrytitle><manvolnum>8</manvolnum></citerefentry>
+ to set the peers up.
+ '';
+ };
+
+ singleSubnetPerField = mkOption {
+ type = types.bool;
+ default = false;
+ description = ''
+ By default, all allowed IPs and subnets are comma-separated in the
+ <literal>allowed_ips</literal> field. With this option enabled,
+ a single IP and subnet will be listed in fields like <literal>allowed_ip_0</literal>,
+ <literal>allowed_ip_1</literal> and so on.
+ '';
+ };
+
+ withRemoteIp = mkOption {
+ type = types.bool;
+ default = false;
+ description = ''
+ Whether or not the remote IP of a WireGuard peer should be exposed via prometheus.
+ '';
+ };
+ };
+ serviceOpts = {
+ path = [ pkgs.wireguard-tools ];
+
+ serviceConfig = {
+ AmbientCapabilities = [ "CAP_NET_ADMIN" ];
+ ExecStart = ''
+ ${pkgs.prometheus-wireguard-exporter}/bin/prometheus_wireguard_exporter \
+ -p ${toString cfg.port} \
+ ${optionalString cfg.verbose "-v"} \
+ ${optionalString cfg.singleSubnetPerField "-s"} \
+ ${optionalString cfg.withRemoteIp "-r"} \
+ ${optionalString (cfg.wireguardConfig != null) "-n ${cfg.wireguardConfig}"}
+ '';
+ };
+ };
+}