Quantcast
Channel: Active questions tagged rest - Stack Overflow
Viewing all articles
Browse latest Browse all 3630

How do I update an azure monitor LogSearchRuleResource using the python sdk?

$
0
0

I'd like to use the python sdk to retrieve and then update alerts in azure monitor. However, there seems to be an issue with the sdk where it will not understand that I'm updating an existing alert - as apposed to creating a new one. Here is my example:

from azure.core.credentials import AccessToken, TokenCredentialfrom azure.mgmt.monitor import MonitorManagementClientcredentials = AccessTokenCredential(AZURE_ACCESS_TOKEN)monitor_client = MonitorManagementClient(credentials, AZURE_SUBSCRIPTION_ID)alert_rule_name = "This is my alert_rule"resource_group_name = "myresourcegroup"alert_rule = monitor_client.scheduled_query_rules.get(    resource_group_name,    alert_rule_name)monitor_client.scheduled_query_rules.create_or_update(    resource_group_name,    alert_rule_name,    alert_rule)

This code is very simple - it authenticates (successfully in my case), retrieves an alert_rule (also successfully) of type from azure.mgmt.monitor.models.LogSearchRuleResource, and then sends it right back.

The result:

HttpResponseError: (BadRequest) The query of a metric measurement alert rule must include an AggregatedValue column of a numeric type

This suggests to me that the sdk doesn't recognize this as an update, but instead a new alert. But it could also be some other issue with the SDK.

I would expect this resource - when returned to the API - to be a valid transaction with the server. Server gives me a resource that I requested. I give it back to the server - server should accept it. No?


Viewing all articles
Browse latest Browse all 3630

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>