From d1f8cc2e845abfddaff5391af3e30338b9ee6185 Mon Sep 17 00:00:00 2001 From: Dmitriy Pleshevskiy <dmitriy@pleshevski.ru> Date: Thu, 30 Jan 2025 01:26:09 +0300 Subject: [PATCH] host/tatos: configure prometheus --- hosts/tatos/services/default.nix | 3 +- .../{grafana/default.nix => grafana.nix} | 0 hosts/tatos/services/prometheus.nix | 39 +++++++++++++++++++ 3 files changed, 41 insertions(+), 1 deletion(-) rename hosts/tatos/services/{grafana/default.nix => grafana.nix} (100%) create mode 100644 hosts/tatos/services/prometheus.nix diff --git a/hosts/tatos/services/default.nix b/hosts/tatos/services/default.nix index ec55285..29bdf6c 100644 --- a/hosts/tatos/services/default.nix +++ b/hosts/tatos/services/default.nix @@ -2,10 +2,11 @@ { imports = [ - ./grafana ./miniflux ./wireguard ./nginx.nix ./dns.nix + ./grafana.nix + ./prometheus.nix ]; } diff --git a/hosts/tatos/services/grafana/default.nix b/hosts/tatos/services/grafana.nix similarity index 100% rename from hosts/tatos/services/grafana/default.nix rename to hosts/tatos/services/grafana.nix diff --git a/hosts/tatos/services/prometheus.nix b/hosts/tatos/services/prometheus.nix new file mode 100644 index 0000000..bbebe23 --- /dev/null +++ b/hosts/tatos/services/prometheus.nix @@ -0,0 +1,39 @@ +{ config, hostsPath, ... }: + +let + istalData = import (hostsPath + "/istal/data.secret.nix"); + nodeExporterPort = 40000; +in +{ + services.prometheus.exporters.node = { + enable = true; + port = nodeExporterPort; + # https://github.com/NixOS/nixpkgs/blob/nixos-24.05/nixos/modules/services/monitoring/prometheus/exporters.nix + enabledCollectors = [ "systemd" ]; + # /nix/store/zgsw0yx18v10xa58psanfabmg95nl2bb-node_exporter-1.8.1/bin/node_exporter --help + extraFlags = [ "--collector.ethtool" "--collector.softirqs" "--collector.tcpstat" "--collector.wifi" ]; + }; + + # https://wiki.nixos.org/wiki/Prometheus + # https://nixos.org/manual/nixos/stable/#module-services-prometheus-exporters-configuration + # https://github.com/NixOS/nixpkgs/blob/nixos-24.05/nixos/modules/services/monitoring/prometheus/default.nix + services.prometheus = { + enable = true; + listenAddress = "127.0.0.1"; + port = 33010; + globalConfig.scrape_interval = "15s"; # "1m" + scrapeConfigs = [ + { + job_name = "node_dev"; + static_configs = [ + { + targets = [ + "localhost:${toString nodeExporterPort}" + "${istalData.addr}:${toString nodeExporterPort}" + ]; + } + ]; + } + ]; + }; +}