summary refs log blame commit diff
path: root/nixos/tests/prometheus.nix
blob: ade097597bb832e2bdcbb5361ce9bbe613ba4e0f (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12











                                    
                             















                                                               
import ./make-test.nix {
  name = "prometheus";

  nodes = {
    one = { config, pkgs, ... }: {
      services.prometheus = {
        enable = true;
        globalConfig = {
          labels = { foo = "bar"; };
        };
        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");
  '';
}