blob: 2c7c3cf966483decfbada520b82b960ff8747f18 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
{ config, lib }:
rec {
mkTarget = host: port: {
targets = [ "${host}:${toString port}" ];
};
mkScrapeConfig = name: hosts: port: {
job_name = name;
static_configs = map (host: mkTarget host port) hosts;
relabel_configs = relabelConfig;
};
relabelConfig = [{
source_labels = ["__address__"];
target_label = "host";
regex = "([^:]+)(:[0-9]+)?";
replacement = "\${1}";
}];
}
|