blob: 1c03c35e84fb9594e7fe3aee0db387006d9be9ac (
plain)
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
|
{ config, lib, pkgs, ... }:
let
helpers = import <top/shared/postgres-collectors.nix> { inherit config lib pkgs; };
cfg = config.exporters;
in
{
options.exporters = {
sqlExporterPort = lib.mkOption {
type = lib.types.int;
};
};
imports = [
<top/shared/prometheus-sql-exporter/service.nix>
];
config = {
services.prometheus-sql-exporter = {
enable = true;
port = cfg.sqlExporterPort;
config = {
target = {
# This URL should be postgresql:///postgres?host=/run/postgresql
# but sql_exporter uses xo/dburl which isn't spec-compliant: https://github.com/xo/dburl/issues/46
data_source_name = "postgresql:/run/postgresql:/postgres";
collectors = helpers.collectorNames;
};
collectors = helpers.collectors;
};
};
monitoring.prometheusScrapeConfigs = [
{
job_name = "sql";
static_configs = [{
targets = [ "localhost:${toString cfg.sqlExporterPort}" ];
}];
}
];
};
}
|