ildkule: add postgres exporter for knakelibrak

This commit is contained in:
h7x4 2023-01-26 02:16:38 +01:00
parent f3d143cfb9
commit efc8eb7ffc
No known key found for this signature in database
GPG Key ID: 9F2F7D8250F35146
2 changed files with 41 additions and 12 deletions

View File

@ -1,18 +1,34 @@
{ config, values, ... }: let { pkgs, lib, config, values, ... }: let
cfg = config.services.prometheus; cfg = config.services.prometheus;
in { in {
sops.secrets."keys/postgres/postgres_exporter_env" = { sops.secrets = {
"keys/postgres/postgres_exporter_env" = {};
"keys/postgres/postgres_exporter_knakelibrak_env" = {};
}; };
services.prometheus = { services.prometheus = {
scrapeConfigs = [{ scrapeConfigs = [
job_name = "postgres"; {
scrape_interval = "15s"; job_name = "postgres";
static_configs = [{ scrape_interval = "15s";
targets = [ "localhost:${toString cfg.exporters.postgres.port}" ]; static_configs = [{
}]; targets = [ "localhost:${toString cfg.exporters.postgres.port}" ];
}]; labels = {
server = "bicep";
};
}];
}
{
job_name = "postgres-knakelibrak";
scrape_interval = "15s";
static_configs = [{
targets = [ "localhost:${toString (cfg.exporters.postgres.port + 1)}" ];
labels = {
server = "knakelibrak";
};
}];
}
];
exporters.postgres = { exporters.postgres = {
enable = true; enable = true;
@ -20,4 +36,16 @@ in {
environmentFile = config.sops.secrets."keys/postgres/postgres_exporter_env".path; environmentFile = config.sops.secrets."keys/postgres/postgres_exporter_env".path;
}; };
}; };
systemd.services.prometheus-postgres-exporter-knakelibrak.serviceConfig = let
localCfg = config.services.prometheus.exporters.postgres;
in lib.recursiveUpdate config.systemd.services.prometheus-postgres-exporter.serviceConfig {
EnvironmentFile = config.sops.secrets."keys/postgres/postgres_exporter_knakelibrak_env".path;
ExecStart = ''
${pkgs.prometheus-postgres-exporter}/bin/postgres_exporter \
--web.listen-address ${localCfg.listenAddress}:${toString (localCfg.port + 1)} \
--web.telemetry-path ${localCfg.telemetryPath} \
${lib.concatStringsSep " \\\n " localCfg.extraFlags}
'';
};
} }

View File

@ -15,6 +15,7 @@ keys:
postgres: postgres:
grafana: ENC[AES256_GCM,data:D6qkg98WZYzKYegSNBb31v8o+KHisGmJ+ab5Ut7EMtsJz36kUup5RS4EbtM=,iv:rfE1uH1QycKMTpSq2p1ntQ2BIvptAh2J3l/QcQhiuLo=,tag:QxmGFcekjFRPf6orN86IxQ==,type:str] grafana: ENC[AES256_GCM,data:D6qkg98WZYzKYegSNBb31v8o+KHisGmJ+ab5Ut7EMtsJz36kUup5RS4EbtM=,iv:rfE1uH1QycKMTpSq2p1ntQ2BIvptAh2J3l/QcQhiuLo=,tag:QxmGFcekjFRPf6orN86IxQ==,type:str]
postgres_exporter_env: ENC[AES256_GCM,data:8MEoikoA6tFNm9qZbk0DFWANd7nRs5QSqrsGLoLKPIc1xykJaXTlyP5v8ywVGR8j7bfPs4p6QfpUIWK8CCnfQ1QhsFPXUMksl8p+K+xuMakYZr9OoWigGqvOHpFb9blfBN1FBdRrk38REXWAMUn74KSRI9v+0i5lpC4=,iv:anpjWVUadKfSAm9XbkeAKu+jAk+LxcpVYQ+gUe5szYw=,tag:4tzb/8B/e1uVoqTsQGlcKA==,type:str] postgres_exporter_env: ENC[AES256_GCM,data:8MEoikoA6tFNm9qZbk0DFWANd7nRs5QSqrsGLoLKPIc1xykJaXTlyP5v8ywVGR8j7bfPs4p6QfpUIWK8CCnfQ1QhsFPXUMksl8p+K+xuMakYZr9OoWigGqvOHpFb9blfBN1FBdRrk38REXWAMUn74KSRI9v+0i5lpC4=,iv:anpjWVUadKfSAm9XbkeAKu+jAk+LxcpVYQ+gUe5szYw=,tag:4tzb/8B/e1uVoqTsQGlcKA==,type:str]
postgres_exporter_knakelibrak_env: ENC[AES256_GCM,data:xjC7DGXrW2GIJq8XioIZb+jSe/Hzcz0tv9cUHmX/n1nhI+D64lYt+EKnq1+RX/vJzU4sTaKjveKBh88Qqnv6RQm+MZC//dIxcvnnAdl50qnHZyBCaFFEzSNI8I8vGyArMk8Ja72clBq3kMpUz/pLBP0qDrjblKDoWkU=,iv:ZW98hJy8A5t4Oxtu17R3tM7gou183VLbgBsHA8LFuJY=,tag:VMOvQz3X/XDylV1YFg2Jsg==,type:str]
sops: sops:
kms: [] kms: []
gcp_kms: [] gcp_kms: []
@ -48,8 +49,8 @@ sops:
a2hQVVprakt5NURpNXdQUjREczJKWTgKn60yrLqco9brlqigAolO8rEkww9z3y3u a2hQVVprakt5NURpNXdQUjREczJKWTgKn60yrLqco9brlqigAolO8rEkww9z3y3u
KmefLVZCGfoko+fnKLVE9UKFS/tAowqgPS1qE76u1Mmkk6yqZoG9rg== KmefLVZCGfoko+fnKLVE9UKFS/tAowqgPS1qE76u1Mmkk6yqZoG9rg==
-----END AGE ENCRYPTED FILE----- -----END AGE ENCRYPTED FILE-----
lastmodified: "2023-01-22T01:11:03Z" lastmodified: "2023-01-26T00:16:54Z"
mac: ENC[AES256_GCM,data:qR9M3jAIEsT/65yl6p12BQTHVvAu+oD2ufp7BSLk421mZYfQsKYFh//OZIe5wUE7XDDzhme/oIZGIQX8txaUuDDvFGQO8pQ/Oe19j7MoRG6o/UOTD9nlxcOf/oGekex2vkg5MUgfB1rotSp9Yq6fspVciKQKEawxPCHejqKQRNk=,iv:BkCoXNVAD6joueXkyWApeeZmYj2yopGGG+qK494Ah24=,tag:ax0AUfZdCA3saCYWLsYNrA==,type:str] mac: ENC[AES256_GCM,data:T13TG5fwXgAXUD4I8yIsdUQTA4MKZdEWkpVP1H734YBt5c0J0FJ5Ppxvf1n3hPcC6dcyCJ1NonbmmDBeKn0JUlxTlrK645O33RHLHlsMZGVijYyLyvxCxGo22SfdT2OdPv7tggyat9Cpd9bVLd7YdhPxTYDnZ3eNbIwx+5Fnw48=,iv:bYz6k1f30nlCjOuTRu3F2OE9iQIMd2eBGezXQx901zE=,tag:GHGGNlNg+huP6F3uyrbncQ==,type:str]
pgp: pgp:
- created_at: "2023-01-21T19:52:08Z" - created_at: "2023-01-21T19:52:08Z"
enc: | enc: |