I think it's a copy-paste error. Can you paste back the entire relabel_configs section from your config.
On Wednesday, 20 October 2021 at 15:32:59 UTC+1 Nikolay Buhryk wrote: > Hi Brian, > > I modified my target to the new view e.g. 'hostname ip' = 'foo > 10.11.12.13' and i received only this instance="1" > > I can’t understand where issue still exists > > On Fri, Oct 15, 2021 at 2:24 PM Brian Candler <[email protected]> wrote: > >> You can use target relabelling, where each target entry can contain both >> a name and an IP address and you separate them out in relabelling rules. >> This also lets you generate meaningful instance labels >> <https://www.robustperception.io/controlling-the-instance-label> that >> don't have the exporter port number in them - this is very useful when you >> want a query to join metrics from two different exporters. >> >> Here is a sample config: >> >> - job_name: node >> file_sd_configs: >> - files: >> - /etc/prometheus/targets.d/node_targets.yml >> metrics_path: /metrics >> relabel_configs: >> - source_labels: [__address__] >> regex: '([^ ]+)' # single value (DNS name or address) >> target_label: instance >> - source_labels: [__address__] >> regex: '(.+) (.+)' # name address >> target_label: instance >> replacement: '${1}' >> - source_labels: [__address__] >> regex: '(.+) (.+)' # name address >> target_label: __address__ >> replacement: '${2}' >> - source_labels: [__address__] >> target_label: __address__ >> replacement: '${1}:9100' >> >> >> With this configuration, each entry in your targets file can be either an >> IP address, a DNS name, or "<name><space><address>", e.g. "foo 1.2.3.4" >> >> In the latter case, the <name> becomes the 'instance' label, and the >> <address> is the address used to scrape. The name you choose can be >> anything you like - it doesn't have to relate to a DNS name. >> >> Don't include the port number in your targets file, as this is added >> automatically by the last relabelling rule. You could remove that rule if >> you want though, in which case entries would be of the form "foo >> 1.2.3.4:9100" >> >> On Monday, 11 October 2021 at 17:11:00 UTC+1 Nikolay Buhryk wrote: >> >>> Hi, >>> >>> Can someone help with replacing labels on targets. >>> >>> I have file_sd configs with targets. Prometheus scrapes them and shows >>> their ip addresses and labels that were defined. >>> >>> I need to have possibility scrape their hostnames instead of ip and add >>> new label "hostname" for future use in Alertmanager notifications. >>> >> -- >> You received this message because you are subscribed to a topic in the >> Google Groups "Prometheus Users" group. >> To unsubscribe from this topic, visit >> https://groups.google.com/d/topic/prometheus-users/_-NNuiz8lVs/unsubscribe >> . >> To unsubscribe from this group and all its topics, send an email to >> [email protected]. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/prometheus-users/773d176e-bbe7-44bd-984b-05cce4cbe90cn%40googlegroups.com >> >> <https://groups.google.com/d/msgid/prometheus-users/773d176e-bbe7-44bd-984b-05cce4cbe90cn%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> > -- You received this message because you are subscribed to the Google Groups "Prometheus Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/617d8da5-854b-4b10-ba3b-8a3a2216d7ccn%40googlegroups.com.

