In order to interact with Service Health Activity Log Alerts that are created in the portal, this SDK needs support for compound anyOf conditions as well as support for the containsAny property in leaf conditions.
Here is an example JSON fragment that is returned from the API but which most of the data is currently dropped by the SDK:
"condition": {
"allOf": [
{
"field": "category",
"equals": "ServiceHealth",
"containsAny": null
},
{
"anyOf": [
{
"field": "properties.incidentType",
"equals": "Incident",
"containsAny": null
},
{
"field": "properties.incidentType",
"equals": "Maintenance",
"containsAny": null
}
]
},
{
"field": "properties.impactedServices[*].ServiceName",
"equals": null,
"containsAny": [
"Backup",
"Load Balancer",
"Network Infrastructure",
"Virtual Machines",
"Virtual Network"
]
},
{
"field": "properties.impactedServices[*].ImpactedRegions[*].RegionName",
"equals": null,
"containsAny": [
"East US",
"West Europe",
"Global"
]
}
]
}
The second (anyOf), third (ServiceName), and fourth (RegionName) conditions here cannot currently be represented in the SDK.
I require this support in order to implement terraform-providers/terraform-provider-azurerm#2996 and this also appears related to Azure/azure-rest-api-specs#3610.
Providing this support would not only allow those of us who use Templates to manage alerts to also configure health alerts but would also allow more consistent feature coverage.
Thank you for looking at this, @lewinski and @ArcturusZhang
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @AzMonEssential.
This is I believe an issue for the Azure Monitor Alerts team, not Essentials. However, I don't know what exact API is being called by the example code.
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @AzmonAlerts.
@lewinski Thanks for reaching out.
Activity Log Alerts already supports creating Alert rules with above fields (ContainsAny, Anyof)
I can see, via the links supplied- that the documentation is indeed missing this.
Alert rules with these fields are already being created through the portal, and using Templates.
Can you clarify where these features are missing so I can look into it?
Also, I will create a task for our team to update the swagger.
Hi @TamRuas it is missing in this swagger, and it would be fine if these were added to a newer api-version.
@ArcturusZhang Thanks, Yes I'm opening a task to fix the swagger documented here.
Its not a new API version, just additional fields.
@TamRuas This issue is about the Go SDK. It still exists in the most recent SDK and API version available.
To explain more fully: An activity log alert has a Condition field. This is modeled by the ActivityLogAlertAllOfCondition type here:
This type just contains a bunch of ActivityLogAlertLeafConditions:
ActivityLogAlertLeafCondition has Field and Equals fields and that's it.
This means that it is impossible to model three of the the alert conditions in my initial description. There is no field in which to put a list of values to test against (ActivityLogAlertLeafCondition only supports a single value), or an anyOf condition (since the only condition type is ActivityLogAlertLeafCondition).
The activity log alert that I'm using as an example is one that the Azure portal created for me. I would like the ability for the Go SDK to create the same alert, but it doesn't have the support.
Exactly and thank you @lewinski
Hi @lewinski our go SDK under the services directory is generated from the swaggers in the azure-rest-api-specs, therefore the go SDK should be equivalent to the REST API defined in the azure-rest-api-specs.
The portal may or may not be using the actual REST API of this service (for instance, they may be using the ARM Templates to provision this resource), therefore you may find that portal support something but the SDK does not.
@lewinski , @ArcturusZhang- Thanks for bridging the gap. Got it.
So the fix on our part is in the Swagger, I opened Bug 7359079 for July.
Most helpful comment
@TamRuas This issue is about the Go SDK. It still exists in the most recent SDK and API version available.
To explain more fully: An activity log alert has a Condition field. This is modeled by the ActivityLogAlertAllOfCondition type here:
https://github.com/Azure/azure-sdk-for-go/blob/4f14e3d53fba12172734d383af647730d06412d2/services/preview/monitor/mgmt/2019-06-01/insights/models.go#L938-L949
This type just contains a bunch of ActivityLogAlertLeafConditions:
https://github.com/Azure/azure-sdk-for-go/blob/4f14e3d53fba12172734d383af647730d06412d2/services/preview/monitor/mgmt/2019-06-01/insights/models.go#L979-L982
ActivityLogAlertLeafCondition has Field and Equals fields and that's it.
https://github.com/Azure/azure-sdk-for-go/blob/4f14e3d53fba12172734d383af647730d06412d2/services/preview/monitor/mgmt/2019-06-01/insights/models.go#L986-L991
This means that it is impossible to model three of the the alert conditions in my initial description. There is no field in which to put a list of values to test against (ActivityLogAlertLeafCondition only supports a single value), or an anyOf condition (since the only condition type is ActivityLogAlertLeafCondition).
The activity log alert that I'm using as an example is one that the Azure portal created for me. I would like the ability for the Go SDK to create the same alert, but it doesn't have the support.