listenAddress = "127.0.0.1";
in
{
-services.prometheus = {
- enable = true;
- inherit listenAddress;
- port = 9090;
- extraFlags = [
- "--storage.tsdb.retention.time 30d"
- ];
- exporters = {
- apcupsd = {
- enable = true;
- inherit listenAddress;
- };
- node = {
- enable = true;
- inherit listenAddress;
- #enabledCollectors = [ "wifi" ];
- };
- smokeping = {
- #enable = true;
- inherit listenAddress;
- 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";
- hosts = [ "www.fdn.fr" "8.8.8.8" ];
- pingInterval = "3s";
+ services.prometheus = {
+ enable = true;
+ inherit listenAddress;
+ port = 9090;
+ extraFlags = [
+ "--storage.tsdb.retention.time 30d"
+ ];
+ exporters = {
+ apcupsd = {
+ enable = true;
+ inherit listenAddress;
+ };
+ node = {
+ enable = true;
+ inherit listenAddress;
+ #enabledCollectors = [ "wifi" ];
+ };
+ smokeping = {
+ #enable = true;
+ inherit listenAddress;
+ 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";
+ hosts = [ "www.fdn.fr" "8.8.8.8" ];
+ pingInterval = "3s";
+ };
+ systemd = {
+ enable = true;
+ inherit listenAddress;
+ };
+ wireguard = {
+ #enable = true;
+ inherit listenAddress;
+ withRemoteIp = true;
+ };
};
- systemd = {
+ scrapeConfigs = [
+ {
+ job_name = hostName;
+ static_configs = [
+ {
+ targets = [
+ "${listenAddress}:${toString prometheus.exporters.apcupsd.port}"
+ "${listenAddress}:${toString prometheus.exporters.node.port}"
+ #"[${listenAddress}:${toString prometheus.exporters.smokeping.port}"
+ "${listenAddress}:${toString prometheus.exporters.systemd.port}"
+ #"${listenAddress}:${toString prometheus.exporters.wireguard.port}"
+ ];
+ }
+ ];
+ }
+ ];
+ /*
+ alertmanagers = [
+ {
+ static_configs = [ { targets = [ "${listenAddress}:9093" ]; } ];
+ }
+ ];
+ alertmanager = {
enable = true;
inherit listenAddress;
- };
- wireguard = {
- #enable = true;
- inherit listenAddress;
- withRemoteIp = true;
- };
- };
- scrapeConfigs = [
- {
- job_name = hostName;
- static_configs = [
- {
- targets = [
- "${listenAddress}:${toString prometheus.exporters.apcupsd.port}"
- "${listenAddress}:${toString prometheus.exporters.node.port}"
- #"[${listenAddress}:${toString prometheus.exporters.smokeping.port}"
- "${listenAddress}:${toString prometheus.exporters.systemd.port}"
- #"${listenAddress}:${toString prometheus.exporters.wireguard.port}"
- ];
- }
- ];
- }
- ];
- /*
- alertmanagers = [
- {
- static_configs = [ { targets = [ "${listenAddress}:9093" ]; } ];
- }
- ];
- alertmanager = {
- enable = true;
- inherit listenAddress;
- configuration = {
+ configuration = {
global = {
"smtp_smarthost" = "localhost:25";
"smtp_require_tls" = false;
];
}
];
- };
- };
- rules = [
- ''
+ };
+ };
+ rules = [
+ ''
groups:
- name: custom_rules
rules:
annotations:
summary: "Instance [{{ $labels.instance }}] battery about 1h left"
description: "[{{ $labels.instance }}] battery in 1h estimated to {{ $value }}%"
- ''
- ];
- */
-};
-systemd.services.grafana.after = ["wireguard-wg-intra.service"];
-systemd.services.grafana.requires = ["wireguard-wg-intra.service"];
-services.grafana = {
- enable = true;
- addr = "${hostName}.wg"; # listenAddress;
- port = 3000;
- analytics.reporting.enable = false;
- extraOptions = {
- ANALYTICS_CHECK_FOR_UPDATES = "false";
+ ''
+ ];
+ */
+ };
+ systemd.services.grafana = {
+ after = [ "wireguard-wg-intra.service" ];
+ requires = [ "wireguard-wg-intra.service" ];
+ };
+ services.grafana = {
+ enable = true;
+ settings = {
+ server.http_port = 3000;
+ setver.http_addr = "${hostName}.sp"; # listenAddress;
+ analytics.reporting_enabled = false;
+ analytics.check_for_updates = false;
+ analytics.check_for_plugin_updates = false;
+ };
+ };
+ # override systemd exporter execstart to enable option...
+ # FIXME: use extraFlags
+ systemd.services.prometheus-systemd-exporter.serviceConfig = {
+ ExecStart = lib.mkForce ''
+ ${pkgs.prometheus-systemd-exporter}/bin/systemd_exporter \
+ --web.listen-address=${listenAddress}:${toString prometheus.exporters.systemd.port} \
+ --systemd.collector.enable-ip-accounting \
+ --systemd.collector.enable-restart-count
+ '';
};
-};
-# override systemd exporter execstart to enable option...
-# FIXME: use extraFlags
-systemd.services.prometheus-systemd-exporter.serviceConfig = {
- ExecStart = lib.mkForce ''
- ${pkgs.prometheus-systemd-exporter}/bin/systemd_exporter \
- --web.listen-address=${listenAddress}:${toString prometheus.exporters.systemd.port} \
- --collector.enable-ip-accounting \
- --collector.enable-restart-count
- '';
-};
}