It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to set Opsgenie alert priority from Prometheus alert priority

Hello

I have the priority level in Prometheus set as 'severity' with values low,medium and critical. I tried using Opsgenie's 'Custom Value to Opsgenie priority' option with value {{severity.substring(0,2)}} but that does not seem to change the priority level of the Opsgenie alert. What am I missing here? Can someone please help me.

Thanks!

2 answers

0 votes
nickhaller Atlassian Team Oct 25, 2019

Hi Ashman,

I think you are on the right track, but missing one character. Can you try this string instead:

P{{severity.substring(0,2)}}

The priority is touchy in this sense that it needs a hardcoded 'P' to map to our priorities.

Let us know if this does the trick! If not, I may need to take a look at what the logs are parsing or what the severity looks like.

@nickhaller Thanks for the response. I tried what you suggested but that did not seem to work. Please take a look and let me know about the workaround. Thanks!

0 votes
nickhaller Atlassian Team Nov 12, 2019

With Prometheus' Alert Manager config file you should be able to map the severity field with something customer like this:

priority: '{{ range .Alerts }}{{ if eq .Labels.severity "critical"}}P1{{else}}P3{{end}}{{end}}'

You can always change "P1" "P3" to their preference.

image.png

@nickhaller Thanks! I tried that out and it maps  priority to P1 for critical alerts but I still wonder why does the one on Opsgenie portal did not work out. ie,  Setting 'Custom Value to Opsgenie priority' option with value {{severity.substring(0,2)}} 

Any update on this yet?

nickhaller Atlassian Team Nov 18, 2019

I'm realizing Prometheus unfortunately is not an integration that can have a custom value to Opsgenie property configured such as a value {{severity.substring(0,2)}}:

priority image.jpg

 

So the best option is mapping this on the Alert Manager side like shown above. We also see customers using Alert Policies to parsed for the severity field, and modify/map the alert's priority this way, but these policies are only included in our Standard and Enterprise plans: https://docs.opsgenie.com/docs/global-policies#section-alert-policy

apologies, but i'm not satisfied with your answer. If you say Prometheus is not an integration that can have a custom value to Opsgenie property, why is the option 'Custom Value to Opsgenie priority' even included in Prometheus integration page? If that cannot have values like '{{severity.substring(0,2)}}' what other values can it have? Can you please give me an example so that I understand the feature better?

nickhaller Atlassian Team Nov 18, 2019

It's not an option (unless you are seeing something else with your integration):

priorty 2.jpg

Prometheus is using an API key to post to Opsgenie and because of this, looking for the values that are priority is (P1-5).

 

This is what I see and I would like to know  how to use it and what values does it take.Opsgenie.png

nickhaller Atlassian Team Nov 19, 2019

You can use this option (Custom Value to Opsgenie Priority) with other webhook-based integrations. Unfortunately it does not work with our API integrations such as Prometheus.

Prometheus is an integration that sends notifications through our API (https://prometheus.io/docs/alerting/configuration/#opsgenie_config) and due to this - Opsgenie will be looking for exactly this value being sent from the alert API.

So for your use-case, you'd need to map this in Alert Manager (since you are on a Free plan with limited functionality to other ways of mapping this in Opsgenie).

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Opsgenie

What’s New in Opsgenie October 2019

Hi there, we have a lot of exciting announcements this month, specifically around Dark Mode. You don’t want to miss out!    Dark Mode for Mobile App is here! A few weeks ago, we annou...

1,402 views 3 15
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you