From ea50f9d68c48415883a9f9cb2e014526bb4236ff Mon Sep 17 00:00:00 2001 From: Franck Cuny Date: Mon, 28 Feb 2022 19:13:31 -0800 Subject: prometheus: initial configuration for the server Run prometheus via systemd, and configure to pull node-exporter's metrics from two hosts. The retention is set for 3 years. --- hosts/common/server/prometheus.nix | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 hosts/common/server/prometheus.nix (limited to 'hosts/common/server') diff --git a/hosts/common/server/prometheus.nix b/hosts/common/server/prometheus.nix new file mode 100644 index 0000000..1c7c906 --- /dev/null +++ b/hosts/common/server/prometheus.nix @@ -0,0 +1,29 @@ +{ config, pkgs, lib, ... }: + +let + # Scrape a list of static targets for a job. + staticScrape = (job_name: targets: { + inherit job_name; + static_configs = [{ inherit targets; }]; + }); +in +{ + services.prometheus = { + enable = true; + + globalConfig.scrape_interval = "15s"; + + extraFlags = [ + # 3 years of retention + "--storage.tsdb.retention=1095d" + "--web.enable-admin-api" + ]; + + scrapeConfigs = [ + (staticScrape "node" [ + "rtr:9100" + "tahoe:9100" + ]) + ]; + }; +} -- cgit 1.4.1