{ 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}"; }]; }