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.after = ["wireguard.wg-intra"];
112 systemd.services.grafana.requires = ["wireguard.wg-intra"];
115 addr = "losurdo.wg"; # listenAddress;
117 analytics.reporting.enable = false;
119 ANALYTICS_CHECK_FOR_UPDATES = "false";
122 # override systemd exporter execstart to enable option...
123 # FIXME: use extraFlags
124 systemd.services.prometheus-systemd-exporter.serviceConfig = {
125 ExecStart = lib.mkForce ''
126 ${pkgs.prometheus-systemd-exporter}/bin/systemd_exporter \
127 --web.listen-address=${listenAddress}:${toString prometheus.exporters.systemd.port} \
128 --collector.enable-ip-accounting \
129 --collector.enable-restart-count