1
0
Fork 0
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-07-07 19:15:36 +03:00

prometheus-postgres-exporter: init at 0.5.1

This commit is contained in:
Franz Pletz 2019-08-01 23:10:08 +02:00
parent a8d45e7fc3
commit e4c60a1e42
No known key found for this signature in database
GPG key ID: 846FDED7792617B4
5 changed files with 96 additions and 0 deletions

View file

@ -32,6 +32,7 @@ let
"nginx"
"node"
"postfix"
"postgres"
"snmp"
"surfboard"
"tor"

View file

@ -0,0 +1,46 @@
{ 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 = {
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}
'';
};
};
}