1 { pkgs, lib, config, hostName, ... }:
3 inherit (config.services) prometheus;
4 listenAddress = "127.0.0.1";
7 services.prometheus = {
12 "--storage.tsdb.retention.time 30d"
17 inherit listenAddress;
21 inherit listenAddress;
22 #enabledCollectors = [ "wifi" ];
26 inherit listenAddress;
27 buckets = "0.0001,0.001,0.005,0.01,0.02,0.04,0.06,0.08,0.16,0.24,0.32,0.4,0.48,0.8,1.6,3.2,6.4";
28 hosts = [ "www.fdn.fr" "8.8.8.8" ];
33 inherit listenAddress;
37 inherit listenAddress;
47 "${listenAddress}:${toString prometheus.exporters.apcupsd.port}"
48 "${listenAddress}:${toString prometheus.exporters.node.port}"
49 #"[${listenAddress}:${toString prometheus.exporters.smokeping.port}"
50 "${listenAddress}:${toString prometheus.exporters.systemd.port}"
51 #"${listenAddress}:${toString prometheus.exporters.wireguard.port}"
60 static_configs = [ { targets = [ "${listenAddress}:9093" ]; } ];
65 inherit listenAddress;
68 "smtp_smarthost" = "localhost:25";
69 "smtp_require_tls" = false;
70 "smtp_from" = "alertmanager@${domain}";
73 "group_by" = [ "alertname" "alias" ];
75 "group_interval" = "2m";
76 "repeat_interval" = "12h";
84 "to" = "root+alertmanager@${domain}";
85 "send_resolved" = true;
97 - record: battery_percent
98 expr: 100 * battery_energy_now / battery_energy_full
99 - alert: battery_soon_out
100 expr: predict_linear(battery_percent[30m], 3600) <= 10
105 summary: "Instance [{{ $labels.instance }}] battery about 1h left"
106 description: "[{{ $labels.instance }}] battery in 1h estimated to {{ $value }}%"
111 systemd.services.grafana = {
112 after = [ "wireguard-wg-intra.service" ];
113 requires = [ "wireguard-wg-intra.service" ];
118 server.http_port = 3000;
119 setver.http_addr = "${hostName}.wg"; # listenAddress;
120 analytics.reporting_enabled = false;
121 analytics.check_for_updates = false;
122 analytics.check_for_plugin_updates = false;
125 # override systemd exporter execstart to enable option...
126 # FIXME: use extraFlags
127 systemd.services.prometheus-systemd-exporter.serviceConfig = {
128 ExecStart = lib.mkForce ''
129 ${pkgs.prometheus-systemd-exporter}/bin/systemd_exporter \
130 --web.listen-address=${listenAddress}:${toString prometheus.exporters.systemd.port} \
131 --systemd.collector.enable-file-descriptor-size \
132 --systemd.collector.enable-ip-accounting \
133 --systemd.collector.enable-restart-count