Hey,
We're using Opsgenie with Coralogix integration. We have the properties `{{_payload.alert_value}}` with the the following value
[{"labels":{"topic":"my-favorite-kafka-topic"},"percentageOverThreshold":100000,"avgValueCrossingThreshold":256686.56666666668,"maxValuesCrossingThreshold":273866,"minValuesCrossingThreshold":242031}]
Is there a function to fetch all value and generate content like this?
topic: my-favorite-kafka-topic
percentageOverThreshold: 100000
avgValueCrossingThreshold: 256686.56666666668
maxValuesCrossingThreshold: 273866
minValuesCrossingThreshold: 242031
Otherwize, I'm trying to get the first value of {{_payload.alert_value}} (it's looks like a list) but I have an error when I try
"{{_payload.alert_value[0].avgValueCrossingThreshold}}" or "{{_payload.alert_value.get(0).avgValueCrossingThreshold}}"
I read the doc here but I don't find the information about it.
Thanks :)
Hey @Tifenn Le Goff ,
Thank you for reaching out with your question.
Upon examining the object/data, it appears to be a map consisting of key-value pairs within an array.
Unfortunately, there isn't a simple function to directly retrieve values from such data, as accessing array methods tends to convert the data to a string format automatically.
To obtain the values you want, you'll need to follow a two-step process.
First, access the first element in your array and assign it to an alert field, like Extra Properties. I've added the following methods to Extra Properties with a key called "topic":
{{_payload.alert_value.get(0)}}
I've attached a screenshot for your reference.
This approach allows you to use Alert Policies to apply string processing methods and extract only the values you're interested in.
Since I've added the entire object to an Extra Property called "topic," you can use the following method to extract the Kafka Topic, based on your example:
{{extraProperties.topic.substringBetween("labels={topic=", "}")}}
You can use similar string methods to access other values you need.
I hope this information is helpful.
Thanks,
Arumugam
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.