Map priority from Datadog to Priority in Opsgenie
Asked by Vinod Kaliappan:

Hi,

I have integrated Datadog with Opsgenie such that the monitors in Datadog send alerts to Opsgenie when the threshold is breached.

Once the alert is in Opsgenie, depending on the tags in the alert, we assign it to the appropriate responder teams.

I am stuck at trying to map the Priority value that comes from Datadog to the P1-P5 value in Opsgenie.

Also, I see that every alert from Datadog comes in with a "Priority : Normal" in the message of the alert.

Any help here in mapping the priority values would be greatly appreciated.

Thank you


Answers:
author: Khoa Truong
body: I think the priorities that get sent via the integration are related to "Events" where the only valid values are "normal" and "low": [Events (datadoghq.com)](https://docs.datadoghq.com/api/latest/events/)

So to work around this, as long as you set the priority in the Datadog monitor, you can extract the correct priority (P1, P2...) from the "message_title" field.

In the Datadog integration, select "Custom Value to Opsgenie Priority" for the Priority field. Depending on how you have your "Message" field set up, you can input a dynamic field similar to the following into "Mapped Priority Value":

```
{{message_title.substring(1,3)}}
```

For example, here is how I've set up the integration in Opsgenie:

![opsgenie_setup.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/147193iC8C03C23ED33AB39/image-size/large?v=v2&px=999 "opsgenie_setup.PNG")

And how a test alert looks:

![test_alert.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/147195i5D888236D059E4FB/image-size/large?v=v2&px=999 "test_alert.PNG")

As you can see, the dynamic field extracts the "P2" from the message title and uses it for the priority in Opsgenie. Here is a page I found on this topic, but it's not that helpful. You can explore the "string processing methods" though, if you want to learn more about how the .substring method works: [Set the priority level of alerts created with integrations \| Opsgenie \| Atlassian Support](https://support.atlassian.com/opsgenie/docs/what-is-the-priority-level-of-integration/)


author: Samir
body: Hi [@Vinod Kaliappan](/t5/user/viewprofilepage/user-id/1212558) ,

Since Datadog uses strings like "low" or "normal" for priority, whereas Opsgenie uses a number system (P1-P5), you can setup multiple create alert actions on your Datadog integration to filter on the priority being received from Datadog, and set the Opsgenie alert priority accordingly...

e.g.

![2021-04-29_09-20-51.png](https://community.atlassian.com/t5/image/serverpage/image-id/141164i622C33AB2F158DDF/image-size/large?v=v2&px=999 "2021-04-29_09-20-51.png")

So you can setup multiple of those "Create Alert" actions for each priority sent from Datadog.

Hope that helps!

comments: author: Vinod Kaliappan
body: [@Samir](/t5/user/viewprofilepage/user-id/2168284) thank you for your response.

I seem to get the 'normal' priority consistently in all my alerts. Is there a way to manage that?

And also, what would be the corresponding datadog priority for P1 and P2 Opsgenie priorities.

Thank you


author: Samir
body: Hi [@Vinod Kaliappan](/t5/user/viewprofilepage/user-id/1212558) ,

I'm not too familiar on the Datadog side, and how they rank priorities. Opsgenie uses a P1-P5 ranking system. According to this doc, it sounds like you can specify a priority associated with your monitors in Datadog: <https://docs.datadoghq.com/monitors/notifications/?tab=is_alert#priority>

But this would be more a question of the Datadog side. The answer I provided above shows how you can filter on the priority we're receiving from Datadog, to set the priority that the Opsgenie alert will be created with.


Tags: cloud