blob: 5505892b3a167550f7e7f7767c25a2769eac993f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
{ lib, config, ... }:
let
cfg = config.monitoring;
in
{
config = lib.mkIf (cfg.monitorAll && config.services.postgresql.enable) {
services.prometheus.exporters.postgres = {
enable = true;
extraFlags = [
"--collector.database_wraparound"
"--collector.long_running_transactions"
"--collector.postmaster"
"--collector.process_idle"
"--collector.stat_activity_autovacuum"
"--collector.stat_statements"
#"--collector.stat_wal_receiver" #we dont have WAL receivers
"--collector.statio_user_indexes"
"--collector.xlog_location"
];
};
services.prometheus.scrapeConfigs = (
lib.map (interval: {
job_name = "postgres-${toString interval}s";
scrape_interval = "${toString interval}s";
static_configs = [ { targets = [ "localhost:${toString config.services.prometheus.exporters.postgres.port}" ]; } ];
}) cfg.prometheusScrapeIntervals
);
services.grafana.provision.dashboards.settings = {
apiVersion = 1;
providers = [
{
name = "14114-postgres-overview";
orgId = 1;
type = "file";
options = {
path = builtins.fetchurl {
url = "https://grafana.com/api/dashboards/14114/revisions/1/download";
sha256 = "0hk0d2nk8nh5ldd17sy3wwpn1xhyinjlsy5vgmnvpvn6g97n342z";
};
};
}
];
};
};
}
|