mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-13 21:50:33 +03:00
nixos/prometheus-ping-exporter: init
This commit is contained in:
parent
e37552b8fa
commit
5d85f0eee8
3 changed files with 51 additions and 0 deletions
|
@ -64,6 +64,7 @@ let
|
|||
"pgbouncer"
|
||||
"php-fpm"
|
||||
"pihole"
|
||||
"ping"
|
||||
"postfix"
|
||||
"postgres"
|
||||
"process"
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
{ config, lib, pkgs, options }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
cfg = config.services.prometheus.exporters.ping;
|
||||
|
||||
settingsFormat = pkgs.formats.yaml {};
|
||||
configFile = settingsFormat.generate "config.yml" cfg.settings;
|
||||
in
|
||||
{
|
||||
port = 9427;
|
||||
extraOpts = {
|
||||
telemetryPath = mkOption {
|
||||
type = types.str;
|
||||
default = "/metrics";
|
||||
description = ''
|
||||
Path under which to expose metrics.
|
||||
'';
|
||||
};
|
||||
|
||||
settings = mkOption {
|
||||
type = settingsFormat.type;
|
||||
default = {};
|
||||
|
||||
description = lib.mdDoc ''
|
||||
Configuration for ping_exporter, see
|
||||
<https://github.com/czerwonk/ping_exporter>
|
||||
for supported values.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
serviceOpts = {
|
||||
serviceConfig = {
|
||||
# ping-exporter needs `CAP_NET_RAW` to run as non root https://github.com/czerwonk/ping_exporter#running-as-non-root-user
|
||||
CapabilityBoundingSet = [ "CAP_NET_RAW" ];
|
||||
AmbientCapabilities = [ "CAP_NET_RAW" ];
|
||||
ExecStart = ''
|
||||
${pkgs.prometheus-ping-exporter}/bin/ping_exporter \
|
||||
--web.listen-address ${cfg.listenAddress}:${toString cfg.port} \
|
||||
--web.telemetry-path ${cfg.telemetryPath} \
|
||||
--config.path="${configFile}" \
|
||||
${concatStringsSep " \\\n " cfg.extraFlags}
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue