removing port from instance label

7,591 views
Skip to first unread message

mohanb...@gmail.com

unread,
May 18, 2018, 6:13:29 AM5/18/18
to Prometheus Users
I have following scape job,

- job_name: 'instance_statistics'
    static_configs:
      - targets:
        - 10.10.0.7:9100

when I read metric node_uname_info it contains label as instance="10.10.0.7:9100".
Can someone help to have this as  instance="10.10.0.7" (without port)?

Simon Pasquier

unread,
May 18, 2018, 6:22:47 AM5/18/18
to mohanb...@gmail.com, Prometheus Users
You want to use relabel_configs [1]. Something along these lines should work:

relabel_configs:
- source_labels: [__address__]
  regex: "([^:]+):\d+"
  target: instance




--
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 prometheus-users+unsubscribe@googlegroups.com.
To post to this group, send email to prometheus-users@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/ffa4f867-aaa0-40fb-b6b0-ab1ee0b09ca7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

mohanb...@gmail.com

unread,
May 21, 2018, 12:27:09 AM5/21/18
to Prometheus Users
Thank you Simon!

secret...@gmail.com

unread,
Jun 3, 2019, 11:13:58 PM6/3/19
to Prometheus Users
Thank you Simonm
This is helpful, however, i found that under prometheus v2.10 you will need to use the following
    relabel_configs:
    - source_labels: [__address__]
      regex: "([^:]+):\\d+"
      target_label: instance



mohanb...@gmail.com於 2018年5月18日星期五 UTC+8下午6時13分29秒寫道:
Reply all
Reply to author
Forward
0 new messages