forked from Drift/pvv-nixos-config
Revert "metrics: stop parsing prometheus labels from url"
This reverts commit 1524b6b10c
.
Prometheus doesn't allow scraping from uris only socketAddresses
The relabeling is to change the internal labels to trick it to read
from a url
This commit is contained in:
parent
1524b6b10c
commit
efed13c810
|
@ -34,6 +34,33 @@ in {
|
||||||
url = "https://matrix.pvv.ntnu.no/metrics/config.json";
|
url = "https://matrix.pvv.ntnu.no/metrics/config.json";
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
relabel_configs = [
|
||||||
|
{
|
||||||
|
source_labels = [ "__address__" ];
|
||||||
|
regex = "[^/]+(/.*)";
|
||||||
|
target_label = "__metrics_path__";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
source_labels = [ "__address__" ];
|
||||||
|
regex = "([^/]+)/.*";
|
||||||
|
target_label = "instance";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
source_labels = [ "__address__" ];
|
||||||
|
regex = "[^/]+\\/+[^/]+/(.*)/\\d+$";
|
||||||
|
target_label = "job";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
source_labels = [ "__address__" ];
|
||||||
|
regex = "[^/]+\\/+[^/]+/.*/(\\d+)$";
|
||||||
|
target_label = "index";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
source_labels = [ "__address__" ];
|
||||||
|
regex = "([^/]+)/.*";
|
||||||
|
target_label = "__address__";
|
||||||
|
}
|
||||||
|
];
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
ruleFiles = [ rules/synapse-v2.rules ];
|
ruleFiles = [ rules/synapse-v2.rules ];
|
||||||
|
|
|
@ -206,22 +206,17 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
locations."/metrics/" = let
|
locations."/metrics/" = let
|
||||||
# See https://github.com/matrix-org/synapse/blob/develop/docs/metrics-howto.md
|
endpoints = lib.pipe cfg.workers.instances [
|
||||||
staticConfigs = lib.pipe cfg.workers.instances [
|
|
||||||
(lib.mapAttrsToList (_: v: v))
|
(lib.mapAttrsToList (_: v: v))
|
||||||
# Add metrics for main process to the list of workers
|
(map (w: "${w.type}/${toString w.index}"))
|
||||||
(x: x ++ [{ type = "master"; index = 1; }])
|
(map (w: "matrix.pvv.ntnu.no/metrics/${w}"))
|
||||||
(map (w: {
|
] ++ [ "matrix.pvv.ntnu.no/metrics/master/1" ];
|
||||||
targets = [ "matrix.pvv.ntnu.no/metrics/${w.type}/${toString w.index}" ];
|
|
||||||
labels = {
|
|
||||||
instance = "matrix.pvv.ntnu.no";
|
|
||||||
job = w.type;
|
|
||||||
index = toString w.index;
|
|
||||||
};
|
|
||||||
}))
|
|
||||||
];
|
|
||||||
in {
|
in {
|
||||||
alias = (pkgs.writeTextDir "/config.json" (builtins.toJSON staticConfigs)) + "/";
|
alias = pkgs.writeTextDir "/config.json"
|
||||||
|
(builtins.toJSON [
|
||||||
|
{ targets = endpoints;
|
||||||
|
labels = { };
|
||||||
|
}]) + "/";
|
||||||
};
|
};
|
||||||
})];
|
})];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue