Need to extract IP address from instance variable in Grafana alert rules

Hi Team,

We are using Grafana alerting feature to send events to ServiceNow using webhooks. Here we have a requirement to send IP address to ServiceNow.

I am trying to extract IP address from instance variable ( instance=“10.163.133.80:9090”) . Tried with below options in annotation fields, but no luck.

{{ printf "Instance %s is down" (reReplaceAll :[0-9]+ .Labels.instance ``) }}

{{ reReplaceAll “:[0-9]+” .Labels.instance “” }}

I appreciate any help/guidance you can provide

image

Regard,
Jijo

Hey @jijomilestogo

What happen with your actual templates? What’s the output?

Hello @codi639 ,

I am getting output as below. node and summary is not showing. We are not using templates here, we are parsing the json payload from Grafana in ServiceNow

image

Thanks,
Jijo

What I call template is something like {{ reReplaceAll ":[0-9]+" .Labels.instance "" }}, my bad haha.

Would it be a bad thing if the IP show directly on the description?

Also, I just saw that you use the char ` for the node and the char " for the Summary, is there a reason?

Ohh ok , got it.

Would it be a bad thing if the IP show directly on the description?

IP address can be on the description also, its fine , but i need to removed the port :9090 before displaying it

Also, I just saw that you use the char ` for the node and the char " for the Summary, is there a reason?

I was just trying with multiple options

Regards,
Jijo

Then, in your summary, can you try to slightly change your private ip part to {{ regexReplaceAll ":[0-9]+" .Labels.instance "" }} or {{ regexReplaceAll ":.*" .Labels.instance "" }}?
Let me know how it goes.

sure let me try with above