1 import ../make-test-python.nix ({ lib, pkgs, ... }:
4 name = "prometheus-remote-write";
7 receiver = { config, pkgs, ... }: {
8 environment.systemPackages = [ pkgs.jq ];
10 networking.firewall.allowedTCPPorts = [ config.services.prometheus.port ];
12 services.prometheus = {
14 globalConfig.scrape_interval = "2s";
16 extraFlags = [ "--web.enable-remote-write-receiver" ];
20 prometheus = { config, pkgs, ... }: {
21 environment.systemPackages = [ pkgs.jq ];
23 networking.firewall.allowedTCPPorts = [ config.services.prometheus.port ];
25 services.prometheus = {
27 globalConfig.scrape_interval = "2s";
31 url = "http://receiver:9090/api/v1/write";
41 "node:${toString config.services.prometheus.exporters.node.port}"
50 node = { config, pkgs, ... }: {
51 services.prometheus.exporters.node = {
59 node.wait_for_unit("prometheus-node-exporter")
60 node.wait_for_open_port(9100)
62 for machine in prometheus, receiver:
63 machine.wait_for_unit("prometheus")
64 machine.wait_for_open_port(9090)
66 # Verify both servers got the same data from the exporter
67 for machine in prometheus, receiver:
68 machine.wait_until_succeeds(
69 "curl -sf 'http://127.0.0.1:9090/api/v1/query?query=node_exporter_build_info\{instance=\"node:9100\"\}' | "
70 + "jq '.data.result[0].value[1]' | grep '\"1\"'"