1import ./make-test-python.nix (
2 { pkgs, ... }:
3 {
4 name = "mimir";
5 nodes = {
6 server =
7 { ... }:
8 {
9 environment.systemPackages = [ pkgs.jq ];
10 services.mimir.enable = true;
11 services.mimir.configuration = {
12 ingester.ring.replication_factor = 1;
13 };
14
15 services.telegraf.enable = true;
16 services.telegraf.extraConfig = {
17 agent.interval = "1s";
18 agent.flush_interval = "1s";
19 inputs.exec = {
20 commands = [
21 "${pkgs.coreutils}/bin/echo 'foo i=42i'"
22 ];
23 data_format = "influx";
24 };
25 outputs = {
26 http = {
27 # test remote write
28 url = "http://localhost:8080/api/v1/push";
29
30 # Data format to output.
31 data_format = "prometheusremotewrite";
32
33 headers = {
34 Content-Type = "application/x-protobuf";
35 Content-Encoding = "snappy";
36 X-Scope-OrgID = "nixos";
37 X-Prometheus-Remote-Write-Version = "0.1.0";
38 };
39 };
40 };
41 };
42 };
43 };
44
45 testScript = ''
46 start_all()
47 server.wait_for_unit("mimir.service")
48 server.wait_for_unit("telegraf.service")
49 server.wait_for_open_port(8080)
50 server.wait_until_succeeds(
51 "curl -H 'X-Scope-OrgID: nixos' http://127.0.0.1:8080/prometheus/api/v1/label/host/values | jq -r '.data[0]' | grep server"
52 )
53 '';
54 }
55)