Azure Resource Health integration does not close alerts
Asked by Michal Keder:

I've configured Azure Resource Health integration, and noticed that alerts are not closed automatically even though they have Resolved activityLog status.

I looked at the Advanced configuration of the integration, and found out that the Close action checks the main status field of the message to be "Resolved". Given [the Microsoft documentation](https://docs.microsoft.com/en-us/azure/azure-monitor/alerts/activity-log-alerts-webhook#resourcehealth) about the resource health message payload, the Close action is never going to be triggered, since the main status is **always**"Activated" for this kind of message. Only the Activity Log Status is going to change, and here is an example of such a message:

```
{  "schemaId": "Microsoft.Insights/activityLogs",  "data": {    "status": "Activated",    "context": {      "activityLog": {        "channels": "Admin, Operation",        "correlationId": "...",        "eventSource": "ResourceHealth",        "eventTimestamp": "2021-08-18T15:23:00.2603901+00:00",        "eventDataId": "...",        "level": "Informational",        "operationName": "Microsoft.Resourcehealth/healthevent/Resolved/action",        "operationId": "...",        "properties": {          "title": "Unknown",          "details": "Unknown",          "currentHealthStatus": "Available",          "previousHealthStatus": "Unknown",          "type": "Unknown",          "cause": "Unknown"        },        "resourceId": "...",        "resourceGroupName": "...",        "resourceProviderName": "Microsoft.Resourcehealth/healthevent/action",        "status": "Resolved",        "subscriptionId": "...",        "submissionTimestamp": "2021-08-18T15:23:14.0751627+00:00",        "resourceType": "MICROSOFT.SQL/SERVERS/DATABASES"      }    },    "properties": {}  }}
```

I wanted to change the behavior of Close action, but there is no way of selecting Activity Log Status for the filter conditions...

Also there is no Activity Log Status field in draggable items:

![obraz.png](https://community.atlassian.com/t5/image/serverpage/image-id/156719i678AC0A4D1E59947/image-size/large?v=v2&px=999 "obraz.png")

even though it's present in extra properties, but with a spelling mistake:

![obraz.png](https://community.atlassian.com/t5/image/serverpage/image-id/156724iA510190835DCC444/image-size/large?v=v2&px=999 "obraz.png")

I know that I can still use {{_payload.data.context.activityLog.status}} but still I consider this as a bug.


Answers:
author: Skyler Ataide
body: Hi Michal,

Thanks for reaching out, and thank you for providing this information! Are you able to reconfigure your Azure Resource Health Close Alert action to filter for alerts where the *Resource Id* has a Status of "Resolved"? Also, is there an Azure Resource Health rule for when the Status is Resolved on the Azure side, and does it have the Opsgenie Web-Hook? Proceeding with these steps, if your Azure side sends out the Resolved status messages to Opsgenie, then it should be able to automatically close these alerts. Regarding the extra properties *Status: {{activitLogStatus}}* spelling error, thank you for pointing this out; I will reach out to our engineering team to see to it that this is corrected. Hope this helps, and please let me know if you have any further questions.

Thanks,

Skyler

comments: author: Michal Keder
body: Hi Skyler,

My Azure Resource Health Close Alert action is set to default as follows

![1.png](https://community.atlassian.com/t5/image/serverpage/image-id/157088i8425B509F91FFD5D/image-size/large?v=v2&px=999 "1.png")

Also Azure Resource Health rule is configured as it should be

![2.png](https://community.atlassian.com/t5/image/serverpage/image-id/157090i507D092572837B46/image-size/large?v=v2&px=999 "2.png")

Alerts are coming to OpsGenie, with event statuses Active, Updated and Resolved. I can see them in OpsGenie debug logs, but as I already stated, the default Filter for Close action is not going to work, since it checks the Status field of the message, and Microsoft documentation states that it's always set to **Activated** no matter the internal activity log status:

![3.png](https://community.atlassian.com/t5/image/serverpage/image-id/157091iDF12C5991F1B4BEA/image-size/large?v=v2&px=999 "3.png")

Currently the result is that Count of the alert with the same *resourceId* is increased but the alert itself is not closed even though the activityLogStatus is **Resolved.**

![4.png](https://community.atlassian.com/t5/image/serverpage/image-id/157092i66A9BA75D52C4511/image-size/large?v=v2&px=999 "4.png")


author: Skyler Ataide
body: Hi Michal,

Apologies for the delayed response. According to this integration's settings, the payloads are checked against Status filter. For Activated status; by default, Create alert action gets applied and for Resolved statuses; Close alert action gets applied. Since all of your activity log alerts are coming into Opsgenie with the status always set to Activated in the payload, this is the reason that duplicate alerts are being created.

From what I understand, it does seem incorrect that the default Create Alert and Close Alert actions would behave in this way considering that the Status included in the payload being sent from Azure is always equal to "Activated" in the use case you've described.

Are you able to raise a support ticket with Opsgenie support using this link here: <https://support.atlassian.com/contact/#/> so that we can dig into this issue deeper?

We may need the ability to access your account instance to see if we are able to reconfigure the filters in these actions to Create and Close alerts that come in from your Azure Resource Health integration correctly. There is also a potential workaround here that can be deployed, however, it will be best to see if we can get the default integration actions to work appropriately first. If the default integration can not work due to the reasons you've described, then this problem could indeed be classified as a bug, in which case we will want to escalate the full details of the issue to engineering so that it can be fixed.

Thank you,

Skyler


Tags: cloud