about summary refs log tree commit diff
path: root/hosts/common/server/prometheus.nix
blob: a27e3cc1f16018c06a59d0a0909ec89295f09c38 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
{ config, pkgs, lib, ... }:

{
  services.prometheus = {
    enable = true;

    globalConfig.scrape_interval = "15s";

    extraFlags = [
      # 3 years of retention
      "--storage.tsdb.retention=${toString (365 * 3)}d"
      "--web.enable-admin-api"
    ];

    scrapeConfigs = [
      {
        job_name = "node";
        static_configs = [
          {targets = ["192.168.6.10:9100" "192.168.6.20:9100"]; }
        ];
        relabel_configs = [{
          source_labels = ["__address__"];
          target_label = "instance";
          replacement = "nas";
          action = "replace";
          regex = "192\.168\.6\.10:(.*)";
        } {
          source_labels = ["__address__"];
          target_label = "instance";
          replacement = "tahoe";
          action = "replace";
          regex = "192\.168\.6\.20:(.*)";
        }];
      }
    ];
  };
}