Azure / Azure/azure-rest-api-specs

The status code is 200 when Monitor Scheduled Query Rules Alert API failed

Open
#17,902 0 comments 0 reactions 0 assignees View on GitHub
Insights Service Attention
Dominant language
TypeSpec
Stars
3.1k
Forks
5.9k
Avg merge
2d 22h
Merged PRs (30d)
444

Description

I tried to set `autoMitigate` as `true` while creating [Monitor Scheduled Query Rules Alert](https://github.com/Azure/azure-rest-api-specs/blob/99b9fbc1db1e9a62ce1bdf0bddc4bacade05a3d8/specification/monitor/resource-manager/Microsoft.Insights/stable/2021-08-01/scheduledQueryRule_API.json#L164) but it failed. Though API failed but the status code is still 200. I assume it doesn't make sense. Per my understanding, the status code should be 400 or others. Seems it's a bug. Could you help take a look? Thanks.

PUT https://management.azure.com/subscriptions/xx-xx-xx-xx/resourceGroups/acctestRG-monitor-test01/providers/Microsoft.Insights/scheduledQueryRules/acctest-neil-8?api-version=2021-08-01

Request body:
```
{
"name": "acctest-neil-8",
"location": "westeurope",
"tags": {},
"properties": {
"description": "test neil 3",
"severity": 4,
"enabled": true,
"evaluationFrequency": "P1D",
"scopes": [
"/subscriptions/xx-xx-xx-xx/resourceGroups/acctestRG-monitor-test01/providers/Microsoft.Insights/components/acctestAppInsights-test01"
],
"windowSize": "P1D",
"criteria": {
"allOf": [
{
"query": "let d=datatable(TimeGenerated: datetime, usage_percent: double) [ '2022-01-02T12:59:00Z', 25.4, '2022-01-03T12:59:00Z', 75.4 ];\r\nd | summarize AggregatedValue=avg(usage_percent) by bin(TimeGenerated, 1h)\r\n",
"timeAggregation": "Count",
"metricMeasureColumn": "",
"operator": "GreaterThanOrEqual",
"threshold": 1,
"failingPeriods": {
"numberOfEvaluationPeriods": 1,
"minFailingPeriodsToAlert": 1
}
}
]
},
"autoMitigate": true
}
}
```

Status code of API response: 200

API response body:
```
{
"error": {
"code": "InvalidRequestContent",
"message": "The request content was invalid and could not be deserialized: 'Stateful rules can not run in a frequency greater than 12 hours. Either reduce frequency, or set 'AutoMitigate' property to false'"
}
}
```

Contributor guide

Open the contributing guide

Research direction

Start with specification/monitor/resource-manager/Microsoft.Insights/stable/2021-08-01/scheduledQueryRule_API.json and inspect how the failed PUT response and InvalidRequestContent error are represented. Compare the documented responses with the observed 200 response; done when this validation failure is represented with the appropriate non-success status. No test or entry point is mentioned.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, openapi
Domain
api, backend-api-design
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.