summary refs log tree commit diff
path: root/nixos/tests/prometheus.nix
blob: 87a6510f40fd8e6c66709fa433328234ff4fa205 (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
import ./make-test.nix {
  name = "prometheus";

  nodes = {
    one = { ... }: {
      services.prometheus = {
        enable = true;
        scrapeConfigs = [{
          job_name = "prometheus";
          static_configs = [{
            targets = [ "127.0.0.1:9090" ];
            labels = { instance = "localhost"; };
          }];
        }];
        rules = [ ''testrule = count(up{job="prometheus"})'' ];
      };
    };
  };

  testScript = ''
    startAll;
    $one->waitForUnit("prometheus.service");
    $one->waitForOpenPort(9090);
    $one->succeed("curl -s http://127.0.0.1:9090/metrics");
  '';
}