Azure / Azure/azure-rest-api-specs
scheduledQueryRules@2021-08-01 `windowSize` should be enums.
- Dominant language
- TypeSpec
- Stars
- 3.1k
- Forks
- 6k
- Avg merge
- 2d 22h
- Merged PRs (30d)
- 444
Description
# scheduledQueryRules@2021-08-01 `windowSize` should be enums `PT1M`, `PT5M`, `PT10M`, `PT15M`, `PT30M`, `PT45M`, `PT1H`, `PT2H`, `PT3H`, `PT4H`, `PT5H`, `PT6H`, `P1D` and `P2D`.
If use `"evaluationFrequency": "PT1M"`, `windowSize` can use `PT1M`, `PT5M`, `PT10M`, `PT15M`, `PT30M`, `PT45M`, `PT1H`, `PT2H`, `PT3H`, `PT4H`, `PT5H`, `PT6H`.
Otherwise, `windowSize` can use`PT5M`, `PT10M`, `PT15M`, `PT30M`, `PT45M`, `PT1H`, `PT2H`, `PT3H`, `PT4H`, `PT5H`, `PT6H`, `P1D` and `P2D`.
## swagger
https://github.com/Azure/azure-rest-api-specs/blob/fe9ddfb05b8159ef05bef0f7fbcf81b14bbecf2b/specification/monitor/resource-manager/Microsoft.Insights/stable/2021-08-01/scheduledQueryRule_API.json#L386-L390
## Example API flow 1: use `"windowSize": "P3D"` can get the real possible values
use intended error `"windowSize": "P3D"` in request body, the response contains the real possible values: `Supported granularities are: 5, 10, 15, 30, 45, 60, 120, 180, 240, 300, 360, 1440, 2880`.
PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/wt-example-resources/providers/microsoft.insights/scheduledqueryrules/test?api-version=2021-08-01
x-ms-request-id = 15e7cf34-6fec-4f70-88ca-4f915684b8b3
```json
{
"name": "test",
"location": "westeurope",
"tags": {},
"properties": {
"displayName": "test",
"description": "",
"severity": 3,
"enabled": false,
"evaluationFrequency": "P1D",
"scopes": [
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/wt-example-resources/providers/microsoft.insights/components/example-ai"
],
"targetResourceTypes": [
"microsoft.insights/components"
],
"windowSize": "P3D", # intended error
"overrideQueryTimeRange": "P2D",
"criteria": {
"allOf": [
{
"query": "pageViews\n| where notempty(duration) and client_Type == 'Browser'\n| extend total_duration=duration*itemCount\n| summarize avg_duration=(sum(total_duration)/sum(itemCount)) by operation_Name",
"timeAggregation": "Count",
"dimensions": [],
"resourceIdColumn": "",
"operator": "GreaterThan",
"threshold": 123.0,
"failingPeriods": {
"numberOfEvaluationPeriods": 1,
"minFailingPeriodsToAlert": 1
}
}
]
},
"autoMitigate": false,
"muteActionsDuration": "P2D"
}
}
```
response:
400 Bad Request
```json
{
"error": {
"code": "InvalidRequestContent",
"message": "The request content was invalid and could not be deserialized: 'WindowSize of 4320 minutes is not supported. Supported granularities are: 5, 10, 15, 30, 45, 60, 120, 180, 240, 300, 360, 1440, 2880'"
}
}
```
## Example API flow 2: use `"windowSize": "PT1440M"` in request body, the response return `"windowSize": "P1D"`, break the PUT request and response consistence
PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/wt-example-resources/providers/microsoft.insights/scheduledqueryrules/test?api-version=2021-08-01
x-ms-request-id =
```json
{
"name": "test",
"location": "westeurope",
"tags": {},
"properties": {
"displayName": "test",
"description": "",
"severity": 3,
"enabled": false,
"evaluationFrequency": "P1D",
"scopes": [
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/wt-example-resources/providers/microsoft.insights/components/example-ai"
],
"targetResourceTypes": [
"microsoft.insights/components"
],
"windowSize": "PT1440M", # intended
"overrideQueryTimeRange": "P2D",
"criteria": {
"allOf": [
{
"query": "pageViews\n| where notempty(duration) and client_Type == 'Browser'\n| extend total_duration=duration*itemCount\n| summarize avg_duration=(sum(total_duration)/sum(itemCount)) by operation_Name",
"timeAggregation": "Count",
"dimensions": [],
"resourceIdColumn": "",
"operator": "GreaterThan",
"threshold": 123.0,
"failingPeriods": {
"numberOfEvaluationPeriods": 1,
"minFailingPeriodsToAlert": 1
}
}
]
},
"autoMitigate": false,
"muteActionsDuration": "P2D"
}
}
```
response
200 OK
```json
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/wt-example-resources/providers/microsoft.insights/scheduledqueryrules/test",
"name": "test",
"type": "microsoft.insights/scheduledqueryrules",
"location": "westeurope",
"tags": {},
"systemData": {
"createdBy": "xxx@xxx.com",
"createdByType": "User",
"createdAt": "2022-10-25T02:39:30.2472201Z",
"lastModifiedBy": "00000000-0000-0000-0000-000000000000",
"lastModifiedByType": "Application",
"lastModifiedAt": "2022-10-25T05:48:15.1595396Z"
},
"properties": {
"displayName": "test",
"description": "",
"severity": 3,
"enabled": false,
"evaluationFrequency": "P1D",
"scopes": [
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/wt-example-resources/providers/microsoft.insights/components/example-ai"
],
"targetResourceTypes": [
"microsoft.insights/components"
],
"windowSize": "P1D", # Not consistent with PUT request here
"overrideQueryTimeRange": "P2D",
"criteria": {
"allOf": [
{
"query": "pageViews\n| where notempty(duration) and client_Type == 'Browser'\n| extend total_duration=duration*itemCount\n| summarize avg_duration=(sum(total_duration)/sum(itemCount)) by operation_Name",
"timeAggregation": "Count",
"dimensions": [],
"resourceIdColumn": "",
"operator": "GreaterThan",
"threshold": 123.0,
"failingPeriods": {
"numberOfEvaluationPeriods": 1,
"minFailingPeriodsToAlert": 1
}
}
]
},
"autoMitigate": false,
"muteActionsDuration": "P2D"
}
}
```
## Example API flow 3: one minute alert rules, use `"windowSize": "P1D"` and `"evaluationFrequency": "PT1M"` can get the real possible values
Use `"windowSize": "P1D"` and `"evaluationFrequency": "PT1M"` in request body, the response contains the real possible values: `Supported granularities are: Supported granularities are: 1, 5, 10, 15, 30, 45, 60, 120, 180, 240, 300, 360'"
PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/wt-example-resources/providers/microsoft.insights/scheduledqueryrules/test?api-version=2021-08-01
x-ms-request-id = 7d48137c-38f7-4f7d-a97e-e068a3a761fe
```json
{
"type": "microsoft.insights/scheduledqueryrules",
"location": "westeurope",
"tags": {},
"properties": {
"displayName": "123",
"description": "",
"severity": 3,
"enabled": true,
"evaluationFrequency": "PT1M", # intended
"scopes": [
"/subscriptions/85b3dbca-5974-4067-9669-67a141095a76/resourceGroups/wt-example-resources/providers/microsoft.insights/components/example-ai"
],
"targetResourceTypes": [
"microsoft.insights/components"
],
"windowSize": "P1D", # intended
"overrideQueryTimeRange": "P1D",
"criteria": {
"allOf": [
{
"query": "// Slowest pages \n// What are the 3 slowest pages, and how slow are they? \npageViews\n| where notempty(duration) and client_Type == 'Browser'\n| extend total_duration=duration*itemCount\n| summarize avg_duration=(sum(total_duration)/sum(itemCount)) by operation_Name\n\n",
"timeAggregation": "Count",
"dimensions": [
{
"name": "operation_Name",
"operator": "Include",
"values": [
"*"
]
}
],
"resourceIdColumn": "",
"operator": "GreaterThan",
"threshold": 123.0,
"failingPeriods": {
"numberOfEvaluationPeriods": 1,
"minFailingPeriodsToAlert": 1
}
}
]
},
"autoMitigate": false
}
}
```
response:
400 Bad Request
```json
{
"error": {
"code": "InvalidRequestContent",
"message": "The request content was invalid and could not be deserialized: 'WindowSize of 1440 minutes is not supported for one minute alert rules. Supported granularities are: 1, 5, 10, 15, 30, 45, 60, 120, 180, 240, 300, 360'"
}
}
```
Contributor guide
Research direction
Start with specification/monitor/resource-manager/Microsoft.Insights/stable/2021-08-01/scheduledQueryRule_API.json at lines 386-390. Inspect how windowSize and evaluationFrequency are defined, then run the repository's specification validation. Done means the schema reflects the documented supported values and their dependency on evaluationFrequency without changing valid API examples.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- openapi
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100