Using regex in Grafana templating - how?

I would like populate values for variable in templating using query (a datasource: Prometheus). I know that I can use structure like:

label_values({job="nodes"},instance)

and I received something like: node1.example.com:9100, node2.example.com:9100, etc.

But I would like receive only the FQDN (without a collon and a port number) . Probably I can use for that the “Regex” field but I can’t prepare correct regex pattern.

Thank you in advance for any help.

I think this should work:

/([a-zA-Z0-9\.]+)/

[a-zA-Z0-9\.]+ matches lower and uppercase letters, numbers and dots. The brackets around them create a capture group so that it only returns the part that matches.

2 Likes

You can try this regex: /(.*):9100/

Good afternoon!

I would like a help, regarding the aggregation of the item coming from the same application.

Can anyone help?

label_values(node_load1,instance)
Regex /(.*[^:])[:]/

^^^^^^^
label_values(node_load1,instance)
Regex /(.*[^:])[:]/

label_values(node_load1,instance)
Regex /(.*[^:])[:]/