0

I have prometheus target endpoint http://10.x.x.x/9090/targets .

I am able to see the endpoints which are scraping metrics from the node. I want to get those endpoints as servers in grafana dashboard dropdown. Currentyl it is being displayed as endpoints with port numbers i.e http://xyz.abc:9100 when i use the query label_values(instance) . I just want xyz.abc to be displayed in dropdown.

Please help.

I tried below query: label_values(instance)

1 Answers1

0

I think it would be better if you use the "relabel_config" clause in the Prometheus, to get the "instance" label in the desired format. See more information about "relabel_config" in the Prometheus documentation here.

Anyway, you can also do the same at the Grafana tool, by using the following in the "Regex" field:

/^(.+):[0-9]$/
  • When i am using /^http://(.+):[0-9]$/ then i am not getting any value. I tried this /[a-z]+[0-9]+[.-]+/ but I am getting the port number again with the server name: i.e xyz1.hui.klo.gh-1:9100 . I want xyz1.hui.klo.gh-1 in the result. Note: There is no http:// in the beginning – Spiderweb Computer Technologie Nov 08 '22 at 06:15
  • I removed the "http://" from the answer (in the question you say there is it). You need to put the parenthesis to limit what you want to select in the regexp. If you don't put them Grafana will select the whole expression (with the port number). – Marcelo Ávila de Oliveira Nov 08 '22 at 13:37