From d52033958ebcadc83ff66e9705846d1d13b47508 Mon Sep 17 00:00:00 2001 From: MyronFanQiu Date: Mon, 6 Jan 2020 10:08:21 +0800 Subject: [PATCH 1/2] fix one --- .../test_metric_alert_v2_scenario.yaml | 1286 +---------------- .../test_monitor_metric_alert_scenarios.py | 6 +- 2 files changed, 77 insertions(+), 1215 deletions(-) diff --git a/src/azure-cli/azure/cli/command_modules/monitor/tests/latest/recordings/test_metric_alert_v2_scenario.yaml b/src/azure-cli/azure/cli/command_modules/monitor/tests/latest/recordings/test_metric_alert_v2_scenario.yaml index 976e9f582ee..0de98d3e6ed 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/tests/latest/recordings/test_metric_alert_v2_scenario.yaml +++ b/src/azure-cli/azure/cli/command_modules/monitor/tests/latest/recordings/test_metric_alert_v2_scenario.yaml @@ -1,7 +1,10 @@ interactions: - request: body: '{"location": "global", "properties": {"groupShortName": "ag1", "enabled": - true, "emailReceivers": [], "smsReceivers": [], "webhookReceivers": []}}' + true, "emailReceivers": [], "smsReceivers": [], "webhookReceivers": [], "itsmReceivers": + [], "azureAppPushReceivers": [], "automationRunbookReceivers": [], "voiceReceivers": + [], "logicAppReceivers": [], "azureFunctionReceivers": [], "armRoleReceivers": + []}}' headers: Accept: - application/json @@ -12,14 +15,14 @@ interactions: Connection: - keep-alive Content-Length: - - '146' + - '331' Content-Type: - application/json; charset=utf-8 ParameterSetName: - -g -n User-Agent: - - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.2 - azure-mgmt-monitor/0.5.2 Azure-SDK-For-Python AZURECLI/2.0.75 + - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.9 msrest_azure/0.6.2 azure-mgmt-monitor/0.7.0 + Azure-SDK-For-Python AZURECLI/2.0.79 accept-language: - en-US method: PUT @@ -35,7 +38,7 @@ interactions: content-type: - application/json; charset=utf-8 date: - - Mon, 21 Oct 2019 11:36:08 GMT + - Mon, 06 Jan 2020 02:06:47 GMT expires: - '-1' pragma: @@ -47,13 +50,16 @@ interactions: x-content-type-options: - nosniff x-ms-ratelimit-remaining-subscription-writes: - - '1114' + - '1198' status: code: 201 message: Created - request: body: '{"location": "global", "properties": {"groupShortName": "ag2", "enabled": - true, "emailReceivers": [], "smsReceivers": [], "webhookReceivers": []}}' + true, "emailReceivers": [], "smsReceivers": [], "webhookReceivers": [], "itsmReceivers": + [], "azureAppPushReceivers": [], "automationRunbookReceivers": [], "voiceReceivers": + [], "logicAppReceivers": [], "azureFunctionReceivers": [], "armRoleReceivers": + []}}' headers: Accept: - application/json @@ -64,14 +70,14 @@ interactions: Connection: - keep-alive Content-Length: - - '146' + - '331' Content-Type: - application/json; charset=utf-8 ParameterSetName: - -g -n User-Agent: - - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.2 - azure-mgmt-monitor/0.5.2 Azure-SDK-For-Python AZURECLI/2.0.75 + - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.9 msrest_azure/0.6.2 azure-mgmt-monitor/0.7.0 + Azure-SDK-For-Python AZURECLI/2.0.79 accept-language: - en-US method: PUT @@ -87,7 +93,7 @@ interactions: content-type: - application/json; charset=utf-8 date: - - Mon, 21 Oct 2019 11:36:12 GMT + - Mon, 06 Jan 2020 02:06:53 GMT expires: - '-1' pragma: @@ -99,7 +105,7 @@ interactions: x-content-type-options: - nosniff x-ms-ratelimit-remaining-subscription-writes: - - '1169' + - '1199' status: code: 201 message: Created @@ -108,13 +114,14 @@ interactions: 2, "enabled": true, "scopes": ["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/Microsoft.Storage/storageAccounts/clitest000002"], "evaluationFrequency": "PT1M", "windowSize": "PT5M", "criteria": {"odata.type": "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria", "allOf": [{"name": - "cond0", "metricName": "transactions", "operator": "GreaterThan", "timeAggregation": - "Total", "threshold": 5.0, "dimensions": [{"name": "ResponseType", "operator": - "Include", "values": ["Success"]}, {"name": "ApiName", "operator": "Include", - "values": ["GetBlob"]}]}, {"name": "cond1", "metricName": "SuccessE2ELatency", - "operator": "GreaterThan", "timeAggregation": "Average", "threshold": 250.0, - "dimensions": [{"name": "ApiName", "operator": "Include", "values": ["GetBlob", - "PutBlob"]}]}]}, "actions": [{"actionGroupId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/microsoft.insights/actionGroups/ag1"}]}}\''''' + "cond0", "metricName": "transactions", "timeAggregation": "Total", "dimensions": + [{"name": "ResponseType", "operator": "Include", "values": ["Success"]}, {"name": + "ApiName", "operator": "Include", "values": ["GetBlob"]}], "criterionType": + "StaticThresholdCriterion", "operator": "GreaterThan", "threshold": 5.0}, {"name": + "cond1", "metricName": "SuccessE2ELatency", "timeAggregation": "Average", "dimensions": + [{"name": "ApiName", "operator": "Include", "values": ["GetBlob"]}], "criterionType": + "StaticThresholdCriterion", "operator": "GreaterThan", "threshold": 250.0}]}, + "actions": [{"actionGroupId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/microsoft.insights/actionGroups/ag1"}]}}\''''' headers: Accept: - application/json @@ -125,14 +132,14 @@ interactions: Connection: - keep-alive Content-Length: - - '1202' + - '1281' Content-Type: - application/json; charset=utf-8 ParameterSetName: - -g -n --scopes --action --description --condition --condition User-Agent: - - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.2 - azure-mgmt-monitor/0.5.2 Azure-SDK-For-Python AZURECLI/2.0.75 + - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.9 msrest_azure/0.6.2 azure-mgmt-monitor/0.7.0 + Azure-SDK-For-Python AZURECLI/2.0.79 accept-language: - en-US method: PUT @@ -159,23 +166,23 @@ interactions: \"cond1\",\r\n \"metricNamespace\": \"microsoft.storage/storageaccounts\",\r\n \ \"metricName\": \"SuccessE2ELatency\",\r\n \"dimensions\": [\r\n {\r\n \"name\": \"ApiName\",\r\n \"operator\": - \"Include\",\r\n \"values\": [\r\n \"GetBlob\",\r\n - \ \"PutBlob\"\r\n ]\r\n }\r\n ],\r\n - \ \"operator\": \"GreaterThan\",\r\n \"timeAggregation\": - \"Average\",\r\n \"criterionType\": \"StaticThresholdCriterion\"\r\n - \ }\r\n ],\r\n \"odata.type\": \"Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria\"\r\n - \ },\r\n \"targetResourceType\": \"microsoft.storage/storageaccounts\",\r\n - \ \"actions\": [\r\n {\r\n \"actionGroupId\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/microsoft.insights/actionGroups/ag1\"\r\n + \"Include\",\r\n \"values\": [\r\n \"GetBlob\"\r\n + \ ]\r\n }\r\n ],\r\n \"operator\": + \"GreaterThan\",\r\n \"timeAggregation\": \"Average\",\r\n \"criterionType\": + \"StaticThresholdCriterion\"\r\n }\r\n ],\r\n \"odata.type\": + \"Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria\"\r\n },\r\n + \ \"targetResourceType\": \"microsoft.storage/storageaccounts\",\r\n \"actions\": + [\r\n {\r\n \"actionGroupId\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/microsoft.insights/actionGroups/ag1\"\r\n \ }\r\n ]\r\n }\r\n}" headers: cache-control: - no-cache content-length: - - '2473' + - '2445' content-type: - application/json; charset=utf-8 date: - - Mon, 21 Oct 2019 11:36:44 GMT + - Mon, 06 Jan 2020 02:07:02 GMT expires: - '-1' pragma: @@ -192,8 +199,8 @@ interactions: - 4.0.30319 x-content-type-options: - nosniff - x-ms-ratelimit-remaining-subscription-writes: - - '1141' + x-ms-ratelimit-remaining-subscription-resource-requests: + - '299' x-powered-by: - ASP.NET status: @@ -210,14 +217,12 @@ interactions: - monitor metrics alert update Connection: - keep-alive - Content-Type: - - application/json; charset=utf-8 ParameterSetName: - - -g -n --severity --description --add-action --remove-action --remove-condition + - -g -n --severity --description --add-action --remove-action --remove-conditions --add-condition --evaluation-frequency --window-size --tags --auto-mitigate User-Agent: - - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.2 - azure-mgmt-monitor/0.5.2 Azure-SDK-For-Python AZURECLI/2.0.75 + - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.9 msrest_azure/0.6.2 azure-mgmt-monitor/0.7.0 + Azure-SDK-For-Python AZURECLI/2.0.79 accept-language: - en-US method: GET @@ -244,23 +249,23 @@ interactions: \"cond1\",\r\n \"metricNamespace\": \"microsoft.storage/storageaccounts\",\r\n \ \"metricName\": \"SuccessE2ELatency\",\r\n \"dimensions\": [\r\n {\r\n \"name\": \"ApiName\",\r\n \"operator\": - \"Include\",\r\n \"values\": [\r\n \"GetBlob\",\r\n - \ \"PutBlob\"\r\n ]\r\n }\r\n ],\r\n - \ \"operator\": \"GreaterThan\",\r\n \"timeAggregation\": - \"Average\",\r\n \"criterionType\": \"StaticThresholdCriterion\"\r\n - \ }\r\n ],\r\n \"odata.type\": \"Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria\"\r\n - \ },\r\n \"targetResourceType\": \"microsoft.storage/storageaccounts\",\r\n - \ \"actions\": [\r\n {\r\n \"actionGroupId\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/microsoft.insights/actionGroups/ag1\"\r\n + \"Include\",\r\n \"values\": [\r\n \"GetBlob\"\r\n + \ ]\r\n }\r\n ],\r\n \"operator\": + \"GreaterThan\",\r\n \"timeAggregation\": \"Average\",\r\n \"criterionType\": + \"StaticThresholdCriterion\"\r\n }\r\n ],\r\n \"odata.type\": + \"Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria\"\r\n },\r\n + \ \"targetResourceType\": \"microsoft.storage/storageaccounts\",\r\n \"actions\": + [\r\n {\r\n \"actionGroupId\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/microsoft.insights/actionGroups/ag1\"\r\n \ }\r\n ]\r\n }\r\n}" headers: cache-control: - no-cache content-length: - - '2473' + - '2445' content-type: - application/json; charset=utf-8 date: - - Mon, 21 Oct 2019 11:36:48 GMT + - Mon, 06 Jan 2020 02:07:03 GMT expires: - '-1' pragma: @@ -285,14 +290,15 @@ interactions: - request: body: 'b''b\''{"location": "global", "tags": {"foo": "boo"}, "properties": {"description": "alt desc", "severity": 3, "enabled": true, "scopes": ["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/Microsoft.Storage/storageAccounts/clitest000002"], - "evaluationFrequency": "PT5M", "windowSize": "PT15M", "criteria": {"odata.type": - "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria", "allOf": [{"name": - "cond1", "metricName": "SuccessE2ELatency", "metricNamespace": "microsoft.storage/storageaccounts", - "operator": "GreaterThan", "timeAggregation": "Average", "threshold": 250.0, - "dimensions": [{"name": "ApiName", "operator": "Include", "values": ["GetBlob", - "PutBlob"]}]}, {"name": "cond0", "metricName": "transactions", "operator": "LessThan", - "timeAggregation": "Total", "threshold": 100.0, "dimensions": []}]}, "autoMitigate": - true, "actions": [{"actionGroupId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/microsoft.insights/actionGroups/ag2", + "evaluationFrequency": "PT5M", "windowSize": "PT15M", "targetResourceType": + "microsoft.storage/storageaccounts", "criteria": {"odata.type": "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria", + "allOf": [{"name": "cond1", "metricName": "SuccessE2ELatency", "metricNamespace": + "microsoft.storage/storageaccounts", "timeAggregation": "Average", "dimensions": + [{"name": "ApiName", "operator": "Include", "values": ["GetBlob"]}], "criterionType": + "StaticThresholdCriterion", "operator": "GreaterThan", "threshold": 250.0}, + {"name": "cond0", "metricName": "transactions", "timeAggregation": "Total", + "dimensions": [], "criterionType": "StaticThresholdCriterion", "operator": "LessThan", + "threshold": 100.0}]}, "autoMitigate": true, "actions": [{"actionGroupId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/microsoft.insights/actionGroups/ag2", "webhookProperties": {"test": "best"}}]}}\''''' headers: Accept: @@ -304,386 +310,33 @@ interactions: Connection: - keep-alive Content-Length: - - '1210' + - '1348' Content-Type: - application/json; charset=utf-8 ParameterSetName: - - -g -n --severity --description --add-action --remove-action --remove-condition + - -g -n --severity --description --add-action --remove-action --remove-conditions --add-condition --evaluation-frequency --window-size --tags --auto-mitigate User-Agent: - - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.2 - azure-mgmt-monitor/0.5.2 Azure-SDK-For-Python AZURECLI/2.0.75 - accept-language: - - en-US - method: PUT - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/Microsoft.Insights/metricAlerts/alert1?api-version=2018-03-01 - response: - body: - string: "{\r\n \"location\": \"global\",\r\n \"type\": \"Microsoft.Insights/metricAlerts\",\r\n - \ \"name\": \"alert1\",\r\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/Microsoft.Insights/metricAlerts/alert1\",\r\n - \ \"tags\": {\r\n \"foo\": \"boo\"\r\n },\r\n \"properties\": {\r\n \"description\": - \"alt desc\",\r\n \"severity\": 3,\r\n \"enabled\": true,\r\n \"scopes\": - [\r\n \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/Microsoft.Storage/storageAccounts/clitest000002\"\r\n - \ ],\r\n \"evaluationFrequency\": \"PT5M\",\r\n \"windowSize\": \"PT15M\",\r\n - \ \"templateType\": 8,\r\n \"criteria\": {\r\n \"allOf\": [\r\n - \ {\r\n \"threshold\": 250.0,\r\n \"name\": \"cond1\",\r\n - \ \"metricNamespace\": \"microsoft.storage/storageaccounts\",\r\n - \ \"metricName\": \"SuccessE2ELatency\",\r\n \"dimensions\": - [\r\n {\r\n \"name\": \"ApiName\",\r\n \"operator\": - \"Include\",\r\n \"values\": [\r\n \"GetBlob\",\r\n - \ \"PutBlob\"\r\n ]\r\n }\r\n ],\r\n - \ \"operator\": \"GreaterThan\",\r\n \"timeAggregation\": - \"Average\",\r\n \"criterionType\": \"StaticThresholdCriterion\"\r\n - \ },\r\n {\r\n \"threshold\": 100.0,\r\n \"name\": - \"cond0\",\r\n \"metricNamespace\": \"microsoft.storage/storageaccounts\",\r\n - \ \"metricName\": \"transactions\",\r\n \"dimensions\": [],\r\n - \ \"operator\": \"LessThan\",\r\n \"timeAggregation\": \"Total\",\r\n - \ \"criterionType\": \"StaticThresholdCriterion\"\r\n }\r\n - \ ],\r\n \"odata.type\": \"Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria\"\r\n - \ },\r\n \"autoMitigate\": true,\r\n \"targetResourceType\": \"microsoft.storage/storageaccounts\",\r\n - \ \"actions\": [\r\n {\r\n \"actionGroupId\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/microsoft.insights/actionGroups/ag2\",\r\n - \ \"webHookProperties\": {\r\n \"test\": \"best\"\r\n }\r\n - \ }\r\n ]\r\n }\r\n}" - headers: - cache-control: - - no-cache - content-length: - - '2247' - content-type: - - application/json; charset=utf-8 - date: - - Mon, 21 Oct 2019 11:37:33 GMT - expires: - - '-1' - pragma: - - no-cache - server: - - Microsoft-IIS/10.0 - strict-transport-security: - - max-age=31536000; includeSubDomains - transfer-encoding: - - chunked - vary: - - Accept-Encoding - x-aspnet-version: - - 4.0.30319 - x-content-type-options: - - nosniff - x-ms-ratelimit-remaining-subscription-writes: - - '1107' - x-powered-by: - - ASP.NET - status: - code: 200 - message: OK -- request: - body: null - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - CommandName: - - monitor metrics alert update - Connection: - - keep-alive - Content-Type: - - application/json; charset=utf-8 - ParameterSetName: - - -g -n --enabled - User-Agent: - - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.2 - azure-mgmt-monitor/0.5.2 Azure-SDK-For-Python AZURECLI/2.0.75 - accept-language: - - en-US - method: GET - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/Microsoft.Insights/metricAlerts/alert1?api-version=2018-03-01 - response: - body: - string: "{\r\n \"location\": \"global\",\r\n \"type\": \"Microsoft.Insights/metricAlerts\",\r\n - \ \"name\": \"alert1\",\r\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/Microsoft.Insights/metricAlerts/alert1\",\r\n - \ \"tags\": {\r\n \"foo\": \"boo\"\r\n },\r\n \"properties\": {\r\n \"description\": - \"alt desc\",\r\n \"severity\": 3,\r\n \"enabled\": true,\r\n \"scopes\": - [\r\n \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/Microsoft.Storage/storageAccounts/clitest000002\"\r\n - \ ],\r\n \"evaluationFrequency\": \"PT5M\",\r\n \"windowSize\": \"PT15M\",\r\n - \ \"templateType\": 8,\r\n \"criteria\": {\r\n \"allOf\": [\r\n - \ {\r\n \"threshold\": 250.0,\r\n \"name\": \"cond1\",\r\n - \ \"metricNamespace\": \"microsoft.storage/storageaccounts\",\r\n - \ \"metricName\": \"SuccessE2ELatency\",\r\n \"dimensions\": - [\r\n {\r\n \"name\": \"ApiName\",\r\n \"operator\": - \"Include\",\r\n \"values\": [\r\n \"GetBlob\",\r\n - \ \"PutBlob\"\r\n ]\r\n }\r\n ],\r\n - \ \"operator\": \"GreaterThan\",\r\n \"timeAggregation\": - \"Average\",\r\n \"criterionType\": \"StaticThresholdCriterion\"\r\n - \ },\r\n {\r\n \"threshold\": 100.0,\r\n \"name\": - \"cond0\",\r\n \"metricNamespace\": \"microsoft.storage/storageaccounts\",\r\n - \ \"metricName\": \"transactions\",\r\n \"dimensions\": [],\r\n - \ \"operator\": \"LessThan\",\r\n \"timeAggregation\": \"Total\",\r\n - \ \"criterionType\": \"StaticThresholdCriterion\"\r\n }\r\n - \ ],\r\n \"odata.type\": \"Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria\"\r\n - \ },\r\n \"autoMitigate\": true,\r\n \"targetResourceType\": \"microsoft.storage/storageaccounts\",\r\n - \ \"actions\": [\r\n {\r\n \"actionGroupId\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/microsoft.insights/actionGroups/ag2\",\r\n - \ \"webHookProperties\": {\r\n \"test\": \"best\"\r\n }\r\n - \ }\r\n ]\r\n }\r\n}" - headers: - cache-control: - - no-cache - content-length: - - '2247' - content-type: - - application/json; charset=utf-8 - date: - - Mon, 21 Oct 2019 11:37:35 GMT - expires: - - '-1' - pragma: - - no-cache - server: - - Microsoft-IIS/10.0 - strict-transport-security: - - max-age=31536000; includeSubDomains - transfer-encoding: - - chunked - vary: - - Accept-Encoding - x-aspnet-version: - - 4.0.30319 - x-content-type-options: - - nosniff - x-powered-by: - - ASP.NET - status: - code: 200 - message: OK -- request: - body: 'b''b\''{"location": "global", "tags": {"foo": "boo"}, "properties": {"description": - "alt desc", "severity": 3, "enabled": false, "scopes": ["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/Microsoft.Storage/storageAccounts/clitest000002"], - "evaluationFrequency": "PT5M", "windowSize": "PT15M", "criteria": {"odata.type": - "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria", "allOf": [{"name": - "cond1", "metricName": "SuccessE2ELatency", "metricNamespace": "microsoft.storage/storageaccounts", - "operator": "GreaterThan", "timeAggregation": "Average", "threshold": 250.0, - "dimensions": [{"name": "ApiName", "operator": "Include", "values": ["GetBlob", - "PutBlob"]}]}, {"name": "cond0", "metricName": "transactions", "metricNamespace": - "microsoft.storage/storageaccounts", "operator": "LessThan", "timeAggregation": - "Total", "threshold": 100.0, "dimensions": []}]}, "autoMitigate": true, "actions": - [{"actionGroupId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/microsoft.insights/actionGroups/ag2"}]}}\''''' - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - CommandName: - - monitor metrics alert update - Connection: - - keep-alive - Content-Length: - - '1228' - Content-Type: - - application/json; charset=utf-8 - ParameterSetName: - - -g -n --enabled - User-Agent: - - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.2 - azure-mgmt-monitor/0.5.2 Azure-SDK-For-Python AZURECLI/2.0.75 + - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.9 msrest_azure/0.6.2 azure-mgmt-monitor/0.7.0 + Azure-SDK-For-Python AZURECLI/2.0.79 accept-language: - en-US method: PUT uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/Microsoft.Insights/metricAlerts/alert1?api-version=2018-03-01 response: body: - string: "{\r\n \"location\": \"global\",\r\n \"type\": \"Microsoft.Insights/metricAlerts\",\r\n - \ \"name\": \"alert1\",\r\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/Microsoft.Insights/metricAlerts/alert1\",\r\n - \ \"tags\": {\r\n \"foo\": \"boo\"\r\n },\r\n \"properties\": {\r\n \"description\": - \"alt desc\",\r\n \"severity\": 3,\r\n \"enabled\": false,\r\n \"scopes\": - [\r\n \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/Microsoft.Storage/storageAccounts/clitest000002\"\r\n - \ ],\r\n \"evaluationFrequency\": \"PT5M\",\r\n \"windowSize\": \"PT15M\",\r\n - \ \"templateType\": 0,\r\n \"criteria\": {\r\n \"allOf\": [\r\n - \ {\r\n \"threshold\": 250.0,\r\n \"name\": \"cond1\",\r\n - \ \"metricNamespace\": \"microsoft.storage/storageaccounts\",\r\n - \ \"metricName\": \"SuccessE2ELatency\",\r\n \"dimensions\": - [\r\n {\r\n \"name\": \"ApiName\",\r\n \"operator\": - \"Include\",\r\n \"values\": [\r\n \"GetBlob\",\r\n - \ \"PutBlob\"\r\n ]\r\n }\r\n ],\r\n - \ \"operator\": \"GreaterThan\",\r\n \"timeAggregation\": - \"Average\",\r\n \"criterionType\": \"StaticThresholdCriterion\"\r\n - \ },\r\n {\r\n \"threshold\": 100.0,\r\n \"name\": - \"cond0\",\r\n \"metricNamespace\": \"microsoft.storage/storageaccounts\",\r\n - \ \"metricName\": \"transactions\",\r\n \"dimensions\": [],\r\n - \ \"operator\": \"LessThan\",\r\n \"timeAggregation\": \"Total\",\r\n - \ \"criterionType\": \"StaticThresholdCriterion\"\r\n }\r\n - \ ],\r\n \"odata.type\": \"Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria\"\r\n - \ },\r\n \"autoMitigate\": true,\r\n \"targetResourceType\": \"microsoft.storage/storageaccounts\",\r\n - \ \"actions\": [\r\n {\r\n \"actionGroupId\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/microsoft.insights/actionGroups/ag2\"\r\n - \ }\r\n ]\r\n }\r\n}" - headers: - cache-control: - - no-cache - content-length: - - '2178' - content-type: - - application/json; charset=utf-8 - date: - - Mon, 21 Oct 2019 11:38:08 GMT - expires: - - '-1' - pragma: - - no-cache - server: - - Microsoft-IIS/10.0 - strict-transport-security: - - max-age=31536000; includeSubDomains - transfer-encoding: - - chunked - vary: - - Accept-Encoding - x-aspnet-version: - - 4.0.30319 - x-content-type-options: - - nosniff - x-ms-ratelimit-remaining-subscription-writes: - - '1106' - x-powered-by: - - ASP.NET - status: - code: 200 - message: OK -- request: - body: null - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - CommandName: - - monitor metrics alert list - Connection: - - keep-alive - Content-Type: - - application/json; charset=utf-8 - ParameterSetName: - - -g - User-Agent: - - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.2 - azure-mgmt-monitor/0.5.2 Azure-SDK-For-Python AZURECLI/2.0.75 - accept-language: - - en-US - method: GET - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/Microsoft.Insights/metricAlerts?api-version=2018-03-01 - response: - body: - string: "{\r\n \"value\": [\r\n {\r\n \"location\": \"global\",\r\n - \ \"type\": \"Microsoft.Insights/metricAlerts\",\r\n \"name\": \"alert1\",\r\n - \ \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/Microsoft.Insights/metricAlerts/alert1\",\r\n - \ \"tags\": {\r\n \"foo\": \"boo\"\r\n },\r\n \"properties\": - {\r\n \"description\": \"alt desc\",\r\n \"severity\": 3,\r\n - \ \"enabled\": false,\r\n \"scopes\": [\r\n \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/Microsoft.Storage/storageAccounts/clitest000002\"\r\n - \ ],\r\n \"evaluationFrequency\": \"PT5M\",\r\n \"windowSize\": - \"PT15M\",\r\n \"templateType\": 0,\r\n \"criteria\": {\r\n - \ \"allOf\": [\r\n {\r\n \"threshold\": 250.0,\r\n - \ \"name\": \"cond1\",\r\n \"metricNamespace\": \"microsoft.storage/storageaccounts\",\r\n - \ \"metricName\": \"SuccessE2ELatency\",\r\n \"dimensions\": - [\r\n {\r\n \"name\": \"ApiName\",\r\n \"operator\": - \"Include\",\r\n \"values\": [\r\n \"GetBlob\",\r\n - \ \"PutBlob\"\r\n ]\r\n }\r\n - \ ],\r\n \"operator\": \"GreaterThan\",\r\n \"timeAggregation\": - \"Average\",\r\n \"criterionType\": \"StaticThresholdCriterion\"\r\n - \ },\r\n {\r\n \"threshold\": 100.0,\r\n - \ \"name\": \"cond0\",\r\n \"metricNamespace\": \"microsoft.storage/storageaccounts\",\r\n - \ \"metricName\": \"transactions\",\r\n \"dimensions\": - [],\r\n \"operator\": \"LessThan\",\r\n \"timeAggregation\": - \"Total\",\r\n \"criterionType\": \"StaticThresholdCriterion\"\r\n - \ }\r\n ],\r\n \"odata.type\": \"Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria\"\r\n - \ },\r\n \"autoMitigate\": true,\r\n \"targetResourceType\": - \"microsoft.storage/storageaccounts\",\r\n \"actions\": [\r\n {\r\n - \ \"actionGroupId\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/microsoft.insights/actionGroups/ag2\"\r\n - \ }\r\n ]\r\n }\r\n }\r\n ]\r\n}" - headers: - cache-control: - - no-cache - content-length: - - '2447' - content-type: - - application/json; charset=utf-8 - date: - - Mon, 21 Oct 2019 11:38:11 GMT - expires: - - '-1' - pragma: - - no-cache - server: - - Microsoft-IIS/10.0 - strict-transport-security: - - max-age=31536000; includeSubDomains - transfer-encoding: - - chunked - vary: - - Accept-Encoding - x-aspnet-version: - - 4.0.30319 - x-content-type-options: - - nosniff - x-powered-by: - - ASP.NET - status: - code: 200 - message: OK -- request: - body: null - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - CommandName: - - monitor metrics alert show - Connection: - - keep-alive - Content-Type: - - application/json; charset=utf-8 - ParameterSetName: - - -g -n - User-Agent: - - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.2 - azure-mgmt-monitor/0.5.2 Azure-SDK-For-Python AZURECLI/2.0.75 - accept-language: - - en-US - method: GET - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/Microsoft.Insights/metricAlerts/alert1?api-version=2018-03-01 - response: - body: - string: "{\r\n \"location\": \"global\",\r\n \"type\": \"Microsoft.Insights/metricAlerts\",\r\n - \ \"name\": \"alert1\",\r\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/Microsoft.Insights/metricAlerts/alert1\",\r\n - \ \"tags\": {\r\n \"foo\": \"boo\"\r\n },\r\n \"properties\": {\r\n \"description\": - \"alt desc\",\r\n \"severity\": 3,\r\n \"enabled\": false,\r\n \"scopes\": - [\r\n \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/Microsoft.Storage/storageAccounts/clitest000002\"\r\n - \ ],\r\n \"evaluationFrequency\": \"PT5M\",\r\n \"windowSize\": \"PT15M\",\r\n - \ \"templateType\": 0,\r\n \"criteria\": {\r\n \"allOf\": [\r\n - \ {\r\n \"threshold\": 250.0,\r\n \"name\": \"cond1\",\r\n - \ \"metricNamespace\": \"microsoft.storage/storageaccounts\",\r\n - \ \"metricName\": \"SuccessE2ELatency\",\r\n \"dimensions\": - [\r\n {\r\n \"name\": \"ApiName\",\r\n \"operator\": - \"Include\",\r\n \"values\": [\r\n \"GetBlob\",\r\n - \ \"PutBlob\"\r\n ]\r\n }\r\n ],\r\n - \ \"operator\": \"GreaterThan\",\r\n \"timeAggregation\": - \"Average\",\r\n \"criterionType\": \"StaticThresholdCriterion\"\r\n - \ },\r\n {\r\n \"threshold\": 100.0,\r\n \"name\": - \"cond0\",\r\n \"metricNamespace\": \"microsoft.storage/storageaccounts\",\r\n - \ \"metricName\": \"transactions\",\r\n \"dimensions\": [],\r\n - \ \"operator\": \"LessThan\",\r\n \"timeAggregation\": \"Total\",\r\n - \ \"criterionType\": \"StaticThresholdCriterion\"\r\n }\r\n - \ ],\r\n \"odata.type\": \"Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria\"\r\n - \ },\r\n \"autoMitigate\": true,\r\n \"targetResourceType\": \"microsoft.storage/storageaccounts\",\r\n - \ \"actions\": [\r\n {\r\n \"actionGroupId\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/microsoft.insights/actionGroups/ag2\"\r\n - \ }\r\n ]\r\n }\r\n}" + string: '{"Code":"BadRequest","Message":"When the alert rule contains multiple + criteria, the use of dimensions is limited to one value per dimension within + each criterion."}' headers: cache-control: - no-cache content-length: - - '2178' + - '164' content-type: - application/json; charset=utf-8 date: - - Mon, 21 Oct 2019 11:38:12 GMT + - Mon, 06 Jan 2020 02:07:05 GMT expires: - '-1' pragma: @@ -692,806 +345,15 @@ interactions: - Microsoft-IIS/10.0 strict-transport-security: - max-age=31536000; includeSubDomains - transfer-encoding: - - chunked - vary: - - Accept-Encoding x-aspnet-version: - 4.0.30319 x-content-type-options: - nosniff + x-ms-ratelimit-remaining-subscription-resource-requests: + - '298' x-powered-by: - ASP.NET status: - code: 200 - message: OK -- request: - body: null - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - CommandName: - - monitor metrics alert delete - Connection: - - keep-alive - Content-Length: - - '0' - Content-Type: - - application/json; charset=utf-8 - ParameterSetName: - - -g -n - User-Agent: - - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.2 - azure-mgmt-monitor/0.5.2 Azure-SDK-For-Python AZURECLI/2.0.75 - accept-language: - - en-US - method: DELETE - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/Microsoft.Insights/metricAlerts/alert1?api-version=2018-03-01 - response: - body: - string: '' - headers: - cache-control: - - no-cache - content-length: - - '0' - date: - - Mon, 21 Oct 2019 11:38:19 GMT - expires: - - '-1' - pragma: - - no-cache - server: - - Microsoft-IIS/10.0 - strict-transport-security: - - max-age=31536000; includeSubDomains - x-aspnet-version: - - 4.0.30319 - x-content-type-options: - - nosniff - x-ms-ratelimit-remaining-subscription-deletes: - - '14988' - x-powered-by: - - ASP.NET - status: - code: 200 - message: OK -- request: - body: null - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - CommandName: - - monitor metrics alert list - Connection: - - keep-alive - Content-Type: - - application/json; charset=utf-8 - ParameterSetName: - - -g - User-Agent: - - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.2 - azure-mgmt-monitor/0.5.2 Azure-SDK-For-Python AZURECLI/2.0.75 - accept-language: - - en-US - method: GET - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/Microsoft.Insights/metricAlerts?api-version=2018-03-01 - response: - body: - string: "{\r\n \"value\": []\r\n}" - headers: - cache-control: - - no-cache - content-length: - - '19' - content-type: - - application/json; charset=utf-8 - date: - - Mon, 21 Oct 2019 11:38:21 GMT - expires: - - '-1' - pragma: - - no-cache - server: - - Microsoft-IIS/10.0 - strict-transport-security: - - max-age=31536000; includeSubDomains - transfer-encoding: - - chunked - vary: - - Accept-Encoding - x-aspnet-version: - - 4.0.30319 - x-content-type-options: - - nosniff - x-powered-by: - - ASP.NET - status: - code: 200 - message: OK -- request: - body: 'b''b\''{"location": "global", "properties": {"description": "Test2", "severity": - 2, "enabled": true, "scopes": ["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/Microsoft.Storage/storageAccounts/clitest000002"], - "evaluationFrequency": "PT1M", "windowSize": "PT5M", "criteria": {"odata.type": - "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria", "allOf": [{"name": - "cond0", "metricName": "SuccessE2ELatency", "operator": "GreaterThan", "timeAggregation": - "Average", "threshold": 250.0, "dimensions": [{"name": "ApiName", "operator": - "Include", "values": ["GetBlob:", "PutBlob"]}]}]}, "actions": [{"actionGroupId": - "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/microsoft.insights/actionGroups/ag1"}]}}\''''' - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - CommandName: - - monitor metrics alert create - Connection: - - keep-alive - Content-Length: - - '927' - Content-Type: - - application/json; charset=utf-8 - ParameterSetName: - - -g -n --scopes --action --description --condition - User-Agent: - - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.2 - azure-mgmt-monitor/0.5.2 Azure-SDK-For-Python AZURECLI/2.0.75 - accept-language: - - en-US - method: PUT - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/Microsoft.Insights/metricAlerts/alert1?api-version=2018-03-01 - response: - body: - string: "{\r\n \"location\": \"global\",\r\n \"type\": \"Microsoft.Insights/metricAlerts\",\r\n - \ \"name\": \"alert1\",\r\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/Microsoft.Insights/metricAlerts/alert1\",\r\n - \ \"properties\": {\r\n \"description\": \"Test2\",\r\n \"severity\": - 2,\r\n \"enabled\": true,\r\n \"scopes\": [\r\n \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/Microsoft.Storage/storageAccounts/clitest000002\"\r\n - \ ],\r\n \"evaluationFrequency\": \"PT1M\",\r\n \"windowSize\": \"PT5M\",\r\n - \ \"templateType\": 8,\r\n \"criteria\": {\r\n \"allOf\": [\r\n - \ {\r\n \"threshold\": 250.0,\r\n \"name\": \"cond0\",\r\n - \ \"metricNamespace\": \"microsoft.storage/storageaccounts\",\r\n - \ \"metricName\": \"SuccessE2ELatency\",\r\n \"dimensions\": - [\r\n {\r\n \"name\": \"ApiName\",\r\n \"operator\": - \"Include\",\r\n \"values\": [\r\n \"GetBlob:\",\r\n - \ \"PutBlob\"\r\n ]\r\n }\r\n ],\r\n - \ \"operator\": \"GreaterThan\",\r\n \"timeAggregation\": - \"Average\",\r\n \"criterionType\": \"StaticThresholdCriterion\"\r\n - \ }\r\n ],\r\n \"odata.type\": \"Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria\"\r\n - \ },\r\n \"targetResourceType\": \"microsoft.storage/storageaccounts\",\r\n - \ \"actions\": [\r\n {\r\n \"actionGroupId\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/microsoft.insights/actionGroups/ag1\"\r\n - \ }\r\n ]\r\n }\r\n}" - headers: - cache-control: - - no-cache - content-length: - - '1762' - content-type: - - application/json; charset=utf-8 - date: - - Mon, 21 Oct 2019 11:38:54 GMT - expires: - - '-1' - pragma: - - no-cache - server: - - Microsoft-IIS/10.0 - strict-transport-security: - - max-age=31536000; includeSubDomains - transfer-encoding: - - chunked - vary: - - Accept-Encoding - x-aspnet-version: - - 4.0.30319 - x-content-type-options: - - nosniff - x-ms-ratelimit-remaining-subscription-writes: - - '1165' - x-powered-by: - - ASP.NET - status: - code: 200 - message: OK -- request: - body: null - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - CommandName: - - appservice plan create - Connection: - - keep-alive - ParameterSetName: - - -g -n - User-Agent: - - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.2 - azure-mgmt-resource/4.0.0 Azure-SDK-For-Python AZURECLI/2.0.75 - accept-language: - - en-US - method: GET - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_metric_alert_v2000001?api-version=2019-07-01 - response: - body: - string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001","name":"cli_test_metric_alert_v2000001","type":"Microsoft.Resources/resourceGroups","location":"westus","tags":{"product":"azurecli","cause":"automation","date":"2019-10-21T11:35:35Z"},"properties":{"provisioningState":"Succeeded"}}' - headers: - cache-control: - - no-cache - content-length: - - '428' - content-type: - - application/json; charset=utf-8 - date: - - Mon, 21 Oct 2019 11:38:55 GMT - expires: - - '-1' - pragma: - - no-cache - strict-transport-security: - - max-age=31536000; includeSubDomains - vary: - - Accept-Encoding - x-content-type-options: - - nosniff - status: - code: 200 - message: OK -- request: - body: '{"name": "plan1", "type": "Microsoft.Web/serverfarms", "location": "westus", - "properties": {"skuName": "B1", "capacity": 1}}' - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - CommandName: - - appservice plan create - Connection: - - keep-alive - Content-Length: - - '124' - Content-Type: - - application/json; charset=utf-8 - ParameterSetName: - - -g -n - User-Agent: - - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.2 - azure-mgmt-web/0.42.0 Azure-SDK-For-Python AZURECLI/2.0.75 - accept-language: - - en-US - method: POST - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/Microsoft.Web/validate?api-version=2018-02-01 - response: - body: - string: '{"status":"Success","error":null}' - headers: - cache-control: - - no-cache - content-length: - - '33' - content-type: - - application/json - date: - - Mon, 21 Oct 2019 11:38:57 GMT - expires: - - '-1' - pragma: - - no-cache - server: - - Microsoft-IIS/10.0 - strict-transport-security: - - max-age=31536000; includeSubDomains - transfer-encoding: - - chunked - vary: - - Accept-Encoding - x-aspnet-version: - - 4.0.30319 - x-content-type-options: - - nosniff - x-ms-ratelimit-remaining-subscription-writes: - - '1186' - x-powered-by: - - ASP.NET - status: - code: 200 - message: OK -- request: - body: null - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - CommandName: - - appservice plan create - Connection: - - keep-alive - ParameterSetName: - - -g -n - User-Agent: - - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.2 - azure-mgmt-resource/4.0.0 Azure-SDK-For-Python AZURECLI/2.0.75 - accept-language: - - en-US - method: GET - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_metric_alert_v2000001?api-version=2019-07-01 - response: - body: - string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001","name":"cli_test_metric_alert_v2000001","type":"Microsoft.Resources/resourceGroups","location":"westus","tags":{"product":"azurecli","cause":"automation","date":"2019-10-21T11:35:35Z"},"properties":{"provisioningState":"Succeeded"}}' - headers: - cache-control: - - no-cache - content-length: - - '428' - content-type: - - application/json; charset=utf-8 - date: - - Mon, 21 Oct 2019 11:38:59 GMT - expires: - - '-1' - pragma: - - no-cache - strict-transport-security: - - max-age=31536000; includeSubDomains - vary: - - Accept-Encoding - x-content-type-options: - - nosniff - status: - code: 200 - message: OK -- request: - body: '{"location": "westus", "properties": {"perSiteScaling": false, "isXenon": - false}, "sku": {"name": "B1", "tier": "BASIC", "capacity": 1}}' - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - CommandName: - - appservice plan create - Connection: - - keep-alive - Content-Length: - - '136' - Content-Type: - - application/json; charset=utf-8 - ParameterSetName: - - -g -n - User-Agent: - - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.2 - azure-mgmt-web/0.42.0 Azure-SDK-For-Python AZURECLI/2.0.75 - accept-language: - - en-US - method: PUT - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/Microsoft.Web/serverfarms/plan1?api-version=2018-02-01 - response: - body: - string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/Microsoft.Web/serverfarms/plan1","name":"plan1","type":"Microsoft.Web/serverfarms","kind":"app","location":"West - US","properties":{"serverFarmId":31680,"name":"plan1","workerSize":"Default","workerSizeId":0,"workerTierName":null,"numberOfWorkers":1,"currentWorkerSize":"Default","currentWorkerSizeId":0,"currentNumberOfWorkers":1,"status":"Ready","webSpace":"cli_test_metric_alert_v2000001-WestUSwebspace","subscription":"0b1f6471-1bf0-4dda-aec3-cb9272f09590","adminSiteName":null,"hostingEnvironment":null,"hostingEnvironmentProfile":null,"maximumNumberOfWorkers":3,"planName":"VirtualDedicatedPlan","adminRuntimeSiteName":null,"computeMode":"Dedicated","siteMode":null,"geoRegion":"West - US","perSiteScaling":false,"maximumElasticWorkerCount":1,"numberOfSites":0,"hostingEnvironmentId":null,"isSpot":false,"spotExpirationTime":null,"freeOfferExpirationTime":null,"tags":null,"kind":"app","resourceGroup":"cli_test_metric_alert_v2000001","reserved":false,"isXenon":false,"hyperV":false,"mdmId":"waws-prod-bay-051_31680","targetWorkerCount":0,"targetWorkerSizeId":0,"provisioningState":"Succeeded","webSiteId":null,"existingServerFarmIds":null},"sku":{"name":"B1","tier":"Basic","size":"B1","family":"B","capacity":1}}' - headers: - cache-control: - - no-cache - content-length: - - '1467' - content-type: - - application/json - date: - - Mon, 21 Oct 2019 11:39:08 GMT - expires: - - '-1' - pragma: - - no-cache - server: - - Microsoft-IIS/10.0 - strict-transport-security: - - max-age=31536000; includeSubDomains - transfer-encoding: - - chunked - vary: - - Accept-Encoding - x-aspnet-version: - - 4.0.30319 - x-content-type-options: - - nosniff - x-ms-ratelimit-remaining-subscription-writes: - - '1161' - x-powered-by: - - ASP.NET - status: - code: 200 - message: OK -- request: - body: null - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - CommandName: - - webapp create - Connection: - - keep-alive - ParameterSetName: - - -g -n -p - User-Agent: - - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.2 - azure-mgmt-web/0.42.0 Azure-SDK-For-Python AZURECLI/2.0.75 - accept-language: - - en-US - method: GET - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/Microsoft.Web/serverfarms/plan1?api-version=2018-02-01 - response: - body: - string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/Microsoft.Web/serverfarms/plan1","name":"plan1","type":"Microsoft.Web/serverfarms","kind":"app","location":"West - US","properties":{"serverFarmId":31680,"name":"plan1","workerSize":"Default","workerSizeId":0,"workerTierName":null,"numberOfWorkers":1,"currentWorkerSize":"Default","currentWorkerSizeId":0,"currentNumberOfWorkers":1,"status":"Ready","webSpace":"cli_test_metric_alert_v2000001-WestUSwebspace","subscription":"0b1f6471-1bf0-4dda-aec3-cb9272f09590","adminSiteName":null,"hostingEnvironment":null,"hostingEnvironmentProfile":null,"maximumNumberOfWorkers":3,"planName":"VirtualDedicatedPlan","adminRuntimeSiteName":null,"computeMode":"Dedicated","siteMode":null,"geoRegion":"West - US","perSiteScaling":false,"maximumElasticWorkerCount":1,"numberOfSites":0,"hostingEnvironmentId":null,"isSpot":false,"spotExpirationTime":null,"freeOfferExpirationTime":null,"tags":null,"kind":"app","resourceGroup":"cli_test_metric_alert_v2000001","reserved":false,"isXenon":false,"hyperV":false,"mdmId":"waws-prod-bay-051_31680","targetWorkerCount":0,"targetWorkerSizeId":0,"provisioningState":"Succeeded","webSiteId":null,"existingServerFarmIds":null},"sku":{"name":"B1","tier":"Basic","size":"B1","family":"B","capacity":1}}' - headers: - cache-control: - - no-cache - content-length: - - '1467' - content-type: - - application/json - date: - - Mon, 21 Oct 2019 11:39:10 GMT - expires: - - '-1' - pragma: - - no-cache - server: - - Microsoft-IIS/10.0 - strict-transport-security: - - max-age=31536000; includeSubDomains - transfer-encoding: - - chunked - vary: - - Accept-Encoding - x-aspnet-version: - - 4.0.30319 - x-content-type-options: - - nosniff - x-powered-by: - - ASP.NET - status: - code: 200 - message: OK -- request: - body: 'b''{"name": "app000003", "type": "Microsoft.Web/sites", "location": "West - US", "properties": {"serverFarmId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/Microsoft.Web/serverfarms/plan1"}}''' - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - CommandName: - - webapp create - Connection: - - keep-alive - Content-Length: - - '301' - Content-Type: - - application/json; charset=utf-8 - ParameterSetName: - - -g -n -p - User-Agent: - - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.2 - azure-mgmt-web/0.42.0 Azure-SDK-For-Python AZURECLI/2.0.75 - accept-language: - - en-US - method: POST - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/Microsoft.Web/validate?api-version=2018-02-01 - response: - body: - string: '{"status":"Success","error":null}' - headers: - cache-control: - - no-cache - content-length: - - '33' - content-type: - - application/json - date: - - Mon, 21 Oct 2019 11:39:12 GMT - expires: - - '-1' - pragma: - - no-cache - server: - - Microsoft-IIS/10.0 - strict-transport-security: - - max-age=31536000; includeSubDomains - transfer-encoding: - - chunked - vary: - - Accept-Encoding - x-aspnet-version: - - 4.0.30319 - x-content-type-options: - - nosniff - x-ms-ratelimit-remaining-subscription-writes: - - '1180' - x-powered-by: - - ASP.NET - status: - code: 200 - message: OK -- request: - body: null - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - CommandName: - - webapp create - Connection: - - keep-alive - ParameterSetName: - - -g -n -p - User-Agent: - - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.2 - azure-mgmt-web/0.42.0 Azure-SDK-For-Python AZURECLI/2.0.75 - accept-language: - - en-US - method: GET - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/Microsoft.Web/serverfarms/plan1?api-version=2018-02-01 - response: - body: - string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/Microsoft.Web/serverfarms/plan1","name":"plan1","type":"Microsoft.Web/serverfarms","kind":"app","location":"West - US","properties":{"serverFarmId":31680,"name":"plan1","workerSize":"Default","workerSizeId":0,"workerTierName":null,"numberOfWorkers":1,"currentWorkerSize":"Default","currentWorkerSizeId":0,"currentNumberOfWorkers":1,"status":"Ready","webSpace":"cli_test_metric_alert_v2000001-WestUSwebspace","subscription":"0b1f6471-1bf0-4dda-aec3-cb9272f09590","adminSiteName":null,"hostingEnvironment":null,"hostingEnvironmentProfile":null,"maximumNumberOfWorkers":3,"planName":"VirtualDedicatedPlan","adminRuntimeSiteName":null,"computeMode":"Dedicated","siteMode":null,"geoRegion":"West - US","perSiteScaling":false,"maximumElasticWorkerCount":1,"numberOfSites":0,"hostingEnvironmentId":null,"isSpot":false,"spotExpirationTime":null,"freeOfferExpirationTime":null,"tags":null,"kind":"app","resourceGroup":"cli_test_metric_alert_v2000001","reserved":false,"isXenon":false,"hyperV":false,"mdmId":"waws-prod-bay-051_31680","targetWorkerCount":0,"targetWorkerSizeId":0,"provisioningState":"Succeeded","webSiteId":null,"existingServerFarmIds":null},"sku":{"name":"B1","tier":"Basic","size":"B1","family":"B","capacity":1}}' - headers: - cache-control: - - no-cache - content-length: - - '1467' - content-type: - - application/json - date: - - Mon, 21 Oct 2019 11:39:13 GMT - expires: - - '-1' - pragma: - - no-cache - server: - - Microsoft-IIS/10.0 - strict-transport-security: - - max-age=31536000; includeSubDomains - transfer-encoding: - - chunked - vary: - - Accept-Encoding - x-aspnet-version: - - 4.0.30319 - x-content-type-options: - - nosniff - x-powered-by: - - ASP.NET - status: - code: 200 - message: OK -- request: - body: 'b''{"location": "West US", "properties": {"serverFarmId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/Microsoft.Web/serverfarms/plan1", - "reserved": false, "isXenon": false, "hyperV": false, "siteConfig": {"netFrameworkVersion": - "v4.6", "appSettings": [{"name": "WEBSITE_NODE_DEFAULT_VERSION", "value": "10.14"}], - "localMySqlEnabled": false, "http20Enabled": true}, "scmSiteAlsoStopped": false}}''' - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - CommandName: - - webapp create - Connection: - - keep-alive - Content-Length: - - '501' - Content-Type: - - application/json; charset=utf-8 - ParameterSetName: - - -g -n -p - User-Agent: - - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.2 - azure-mgmt-web/0.42.0 Azure-SDK-For-Python AZURECLI/2.0.75 - accept-language: - - en-US - method: PUT - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/Microsoft.Web/sites/app000003?api-version=2018-11-01 - response: - body: - string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/Microsoft.Web/sites/app000003","name":"app000003","type":"Microsoft.Web/sites","kind":"app","location":"West - US","properties":{"name":"app000003","state":"Running","hostNames":["app000003.azurewebsites.net"],"webSpace":"cli_test_metric_alert_v2000001-WestUSwebspace","selfLink":"https://waws-prod-bay-051.api.azurewebsites.windows.net:454/subscriptions/00000000-0000-0000-0000-000000000000/webspaces/cli_test_metric_alert_v2000001-WestUSwebspace/sites/app000003","repositorySiteName":"app000003","owner":null,"usageState":"Normal","enabled":true,"adminEnabled":true,"enabledHostNames":["app000003.azurewebsites.net","app000003.scm.azurewebsites.net"],"siteProperties":{"metadata":null,"properties":[{"name":"LinuxFxVersion","value":""},{"name":"WindowsFxVersion","value":null}],"appSettings":null},"availabilityState":"Normal","sslCertificates":null,"csrs":[],"cers":null,"siteMode":null,"hostNameSslStates":[{"name":"app000003.azurewebsites.net","sslState":"Disabled","ipBasedSslResult":null,"virtualIP":null,"thumbprint":null,"toUpdate":null,"toUpdateIpBasedSsl":null,"ipBasedSslState":"NotConfigured","hostType":"Standard"},{"name":"app000003.scm.azurewebsites.net","sslState":"Disabled","ipBasedSslResult":null,"virtualIP":null,"thumbprint":null,"toUpdate":null,"toUpdateIpBasedSsl":null,"ipBasedSslState":"NotConfigured","hostType":"Repository"}],"computeMode":null,"serverFarm":null,"serverFarmId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/Microsoft.Web/serverfarms/plan1","reserved":false,"isXenon":false,"hyperV":false,"lastModifiedTimeUtc":"2019-10-21T11:39:19.763","storageRecoveryDefaultState":"Running","contentAvailabilityState":"Normal","runtimeAvailabilityState":"Normal","siteConfig":null,"deploymentId":"app000003","trafficManagerHostNames":null,"sku":"Basic","scmSiteAlsoStopped":false,"targetSwapSlot":null,"hostingEnvironment":null,"hostingEnvironmentProfile":null,"clientAffinityEnabled":true,"clientCertEnabled":false,"clientCertExclusionPaths":null,"hostNamesDisabled":false,"domainVerificationIdentifiers":null,"customDomainVerificationId":"1064DF0D28E9F61D7FD80FC971E47C173C4689B1AF200D019CDE122E6196E70B","kind":"app","inboundIpAddress":"40.78.18.232","possibleInboundIpAddresses":"40.78.18.232","outboundIpAddresses":"40.78.17.157,40.78.21.191,40.78.22.38,40.78.21.180","possibleOutboundIpAddresses":"40.78.17.157,40.78.21.191,40.78.22.38,40.78.21.180","containerSize":0,"dailyMemoryTimeQuota":0,"suspendedTill":null,"siteDisabledReason":0,"functionExecutionUnitsCache":null,"maxNumberOfWorkers":null,"homeStamp":"waws-prod-bay-051","cloningInfo":null,"hostingEnvironmentId":null,"tags":null,"resourceGroup":"cli_test_metric_alert_v2000001","defaultHostName":"app000003.azurewebsites.net","slotSwapStatus":null,"httpsOnly":false,"redundancyMode":"None","inProgressOperationId":null,"geoDistributions":null,"privateEndpointConnections":null,"buildVersion":null,"targetBuildVersion":null}}' - headers: - cache-control: - - no-cache - content-length: - - '3393' - content-type: - - application/json - date: - - Mon, 21 Oct 2019 11:39:37 GMT - etag: - - '"1D588042D8E12B0"' - expires: - - '-1' - pragma: - - no-cache - server: - - Microsoft-IIS/10.0 - strict-transport-security: - - max-age=31536000; includeSubDomains - transfer-encoding: - - chunked - vary: - - Accept-Encoding - x-aspnet-version: - - 4.0.30319 - x-content-type-options: - - nosniff - x-ms-ratelimit-remaining-subscription-resource-requests: - - '499' - x-powered-by: - - ASP.NET - status: - code: 200 - message: OK -- request: - body: '{}' - headers: - Accept: - - application/xml - Accept-Encoding: - - gzip, deflate - CommandName: - - webapp create - Connection: - - keep-alive - Content-Length: - - '2' - Content-Type: - - application/json; charset=utf-8 - ParameterSetName: - - -g -n -p - User-Agent: - - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.2 - azure-mgmt-web/0.42.0 Azure-SDK-For-Python AZURECLI/2.0.75 - accept-language: - - en-US - method: POST - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/Microsoft.Web/sites/app000003/publishxml?api-version=2018-11-01 - response: - body: - string: - headers: - cache-control: - - no-cache - content-length: - - '1613' - content-type: - - application/xml - date: - - Mon, 21 Oct 2019 11:39:38 GMT - expires: - - '-1' - pragma: - - no-cache - server: - - Microsoft-IIS/10.0 - strict-transport-security: - - max-age=31536000; includeSubDomains - x-aspnet-version: - - 4.0.30319 - x-content-type-options: - - nosniff - x-ms-ratelimit-remaining-subscription-resource-requests: - - '11995' - x-powered-by: - - ASP.NET - status: - code: 200 - message: OK -- request: - body: 'b''{"location": "global", "properties": {"description": "Test *", "severity": - 2, "enabled": true, "scopes": ["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/Microsoft.Web/sites/app000003"], - "evaluationFrequency": "PT1M", "windowSize": "PT5M", "criteria": {"odata.type": - "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria", "allOf": [{"name": - "cond0", "metricName": "Http4xx", "operator": "GreaterThan", "timeAggregation": - "Total", "threshold": 10.0, "dimensions": [{"name": "Instance", "operator": - "Include", "values": ["*"]}]}]}, "actions": [{"actionGroupId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/microsoft.insights/actionGroups/ag1"}]}}''' - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - CommandName: - - monitor metrics alert create - Connection: - - keep-alive - Content-Length: - - '875' - Content-Type: - - application/json; charset=utf-8 - ParameterSetName: - - -g -n --scopes --action --description --condition - User-Agent: - - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.2 - azure-mgmt-monitor/0.5.2 Azure-SDK-For-Python AZURECLI/2.0.75 - accept-language: - - en-US - method: PUT - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/Microsoft.Insights/metricAlerts/alert12?api-version=2018-03-01 - response: - body: - string: "{\r\n \"location\": \"global\",\r\n \"type\": \"Microsoft.Insights/metricAlerts\",\r\n - \ \"name\": \"alert12\",\r\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/Microsoft.Insights/metricAlerts/alert12\",\r\n - \ \"properties\": {\r\n \"description\": \"Test *\",\r\n \"severity\": - 2,\r\n \"enabled\": true,\r\n \"scopes\": [\r\n \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/Microsoft.Web/sites/app000003\"\r\n - \ ],\r\n \"evaluationFrequency\": \"PT1M\",\r\n \"windowSize\": \"PT5M\",\r\n - \ \"templateType\": 8,\r\n \"criteria\": {\r\n \"allOf\": [\r\n - \ {\r\n \"threshold\": 10.0,\r\n \"name\": \"cond0\",\r\n - \ \"metricNamespace\": \"microsoft.web/sites\",\r\n \"metricName\": - \"Http4xx\",\r\n \"dimensions\": [\r\n {\r\n \"name\": - \"Instance\",\r\n \"operator\": \"Include\",\r\n \"values\": - [\r\n \"*\"\r\n ]\r\n }\r\n ],\r\n - \ \"operator\": \"GreaterThan\",\r\n \"timeAggregation\": - \"Total\",\r\n \"criterionType\": \"StaticThresholdCriterion\"\r\n - \ }\r\n ],\r\n \"odata.type\": \"Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria\"\r\n - \ },\r\n \"targetResourceType\": \"microsoft.web/sites\",\r\n \"actions\": - [\r\n {\r\n \"actionGroupId\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/microsoft.insights/actionGroups/ag1\"\r\n - \ }\r\n ]\r\n }\r\n}" - headers: - cache-control: - - no-cache - content-length: - - '1667' - content-type: - - application/json; charset=utf-8 - date: - - Mon, 21 Oct 2019 11:39:55 GMT - expires: - - '-1' - pragma: - - no-cache - server: - - Microsoft-IIS/10.0 - strict-transport-security: - - max-age=31536000; includeSubDomains - transfer-encoding: - - chunked - vary: - - Accept-Encoding - x-aspnet-version: - - 4.0.30319 - x-content-type-options: - - nosniff - x-ms-ratelimit-remaining-subscription-writes: - - '1139' - x-powered-by: - - ASP.NET - status: - code: 200 - message: OK + code: 400 + message: BadRequest version: 1 diff --git a/src/azure-cli/azure/cli/command_modules/monitor/tests/latest/test_monitor_metric_alert_scenarios.py b/src/azure-cli/azure/cli/command_modules/monitor/tests/latest/test_monitor_metric_alert_scenarios.py index ac8c9aac6f2..ba733a3e3d6 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/tests/latest/test_monitor_metric_alert_scenarios.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/tests/latest/test_monitor_metric_alert_scenarios.py @@ -32,7 +32,7 @@ def test_metric_alert_v2_scenario(self, resource_group, storage_account): }) self.cmd('monitor action-group create -g {rg} -n {ag1}') self.cmd('monitor action-group create -g {rg} -n {ag2}') - self.cmd('monitor metrics alert create -g {rg} -n {alert} --scopes {sa_id} --action {ag1} --description "Test" --condition "total transactions > 5 where ResponseType includes Success and ApiName includes GetBlob" --condition "avg SuccessE2ELatency > 250 where ApiName includes GetBlob or PutBlob"', checks=[ + self.cmd('monitor metrics alert create -g {rg} -n {alert} --scopes {sa_id} --action {ag1} --description "Test" --condition "total transactions > 5 where ResponseType includes Success and ApiName includes GetBlob" --condition "avg SuccessE2ELatency > 250 where ApiName includes GetBlob"', checks=[ self.check('description', 'Test'), self.check('severity', 2), self.check('autoMitigate', None), @@ -42,7 +42,7 @@ def test_metric_alert_v2_scenario(self, resource_group, storage_account): self.check('length(criteria.allOf[0].dimensions)', 2), self.check('length(criteria.allOf[1].dimensions)', 1) ]) - self.cmd('monitor metrics alert update -g {rg} -n {alert} --severity 3 --description "alt desc" --add-action ag2 test=best --remove-action ag1 --remove-condition cond0 --add-condition "total transactions < 100" --evaluation-frequency 5m --window-size 15m --tags foo=boo --auto-mitigate', checks=[ + self.cmd('monitor metrics alert update -g {rg} -n {alert} --severity 3 --description "alt desc" --add-action ag2 test=best --remove-action ag1 --remove-conditions cond0 --add-condition "total transactions < 100" --evaluation-frequency 5m --window-size 15m --tags foo=boo --auto-mitigate', checks=[ self.check('description', 'alt desc'), self.check('severity', 3), self.check('autoMitigate', True), @@ -64,7 +64,7 @@ def test_metric_alert_v2_scenario(self, resource_group, storage_account): self.cmd('monitor metrics alert list -g {rg}', checks=self.check('length(@)', 0)) - self.cmd('monitor metrics alert create -g {rg} -n {alert} --scopes {sa_id} --action {ag1} --description "Test2" --condition "avg SuccessE2ELatency > 250 where ApiName includes GetBlob: or PutBlob"', checks=[ + self.cmd('monitor metrics alert create -g {rg} -n {alert} --scopes {sa_id} --action {ag1} --description "Test2" --condition "avg SuccessE2ELatency > 250 where ApiName includes GetBlob:"', checks=[ self.check('description', 'Test2'), self.check('severity', 2), self.check('length(criteria.allOf)', 1), From 6d60528fd3e5f10dbbfe3284be7bff51dab9ab9f Mon Sep 17 00:00:00 2001 From: MyronFanQiu Date: Mon, 6 Jan 2020 12:31:34 +0800 Subject: [PATCH 2/2] fix test by deleting one condition --- .../test_metric_alert_v2_scenario.yaml | 1144 ++++++++++++++++- .../test_monitor_metric_alert_scenarios.py | 5 +- 2 files changed, 1127 insertions(+), 22 deletions(-) diff --git a/src/azure-cli/azure/cli/command_modules/monitor/tests/latest/recordings/test_metric_alert_v2_scenario.yaml b/src/azure-cli/azure/cli/command_modules/monitor/tests/latest/recordings/test_metric_alert_v2_scenario.yaml index 0de98d3e6ed..a5216aefc1d 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/tests/latest/recordings/test_metric_alert_v2_scenario.yaml +++ b/src/azure-cli/azure/cli/command_modules/monitor/tests/latest/recordings/test_metric_alert_v2_scenario.yaml @@ -38,7 +38,7 @@ interactions: content-type: - application/json; charset=utf-8 date: - - Mon, 06 Jan 2020 02:06:47 GMT + - Mon, 06 Jan 2020 04:28:04 GMT expires: - '-1' pragma: @@ -50,7 +50,7 @@ interactions: x-content-type-options: - nosniff x-ms-ratelimit-remaining-subscription-writes: - - '1198' + - '1196' status: code: 201 message: Created @@ -93,7 +93,7 @@ interactions: content-type: - application/json; charset=utf-8 date: - - Mon, 06 Jan 2020 02:06:53 GMT + - Mon, 06 Jan 2020 04:28:11 GMT expires: - '-1' pragma: @@ -182,7 +182,7 @@ interactions: content-type: - application/json; charset=utf-8 date: - - Mon, 06 Jan 2020 02:07:02 GMT + - Mon, 06 Jan 2020 04:28:19 GMT expires: - '-1' pragma: @@ -219,7 +219,7 @@ interactions: - keep-alive ParameterSetName: - -g -n --severity --description --add-action --remove-action --remove-conditions - --add-condition --evaluation-frequency --window-size --tags --auto-mitigate + --evaluation-frequency --window-size --tags --auto-mitigate User-Agent: - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.9 msrest_azure/0.6.2 azure-mgmt-monitor/0.7.0 Azure-SDK-For-Python AZURECLI/2.0.79 @@ -265,7 +265,7 @@ interactions: content-type: - application/json; charset=utf-8 date: - - Mon, 06 Jan 2020 02:07:03 GMT + - Mon, 06 Jan 2020 04:28:20 GMT expires: - '-1' pragma: @@ -295,10 +295,8 @@ interactions: "allOf": [{"name": "cond1", "metricName": "SuccessE2ELatency", "metricNamespace": "microsoft.storage/storageaccounts", "timeAggregation": "Average", "dimensions": [{"name": "ApiName", "operator": "Include", "values": ["GetBlob"]}], "criterionType": - "StaticThresholdCriterion", "operator": "GreaterThan", "threshold": 250.0}, - {"name": "cond0", "metricName": "transactions", "timeAggregation": "Total", - "dimensions": [], "criterionType": "StaticThresholdCriterion", "operator": "LessThan", - "threshold": 100.0}]}, "autoMitigate": true, "actions": [{"actionGroupId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/microsoft.insights/actionGroups/ag2", + "StaticThresholdCriterion", "operator": "GreaterThan", "threshold": 250.0}]}, + "autoMitigate": true, "actions": [{"actionGroupId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/microsoft.insights/actionGroups/ag2", "webhookProperties": {"test": "best"}}]}}\''''' headers: Accept: @@ -310,12 +308,12 @@ interactions: Connection: - keep-alive Content-Length: - - '1348' + - '1164' Content-Type: - application/json; charset=utf-8 ParameterSetName: - -g -n --severity --description --add-action --remove-action --remove-conditions - --add-condition --evaluation-frequency --window-size --tags --auto-mitigate + --evaluation-frequency --window-size --tags --auto-mitigate User-Agent: - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.9 msrest_azure/0.6.2 azure-mgmt-monitor/0.7.0 Azure-SDK-For-Python AZURECLI/2.0.79 @@ -325,18 +323,35 @@ interactions: uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/Microsoft.Insights/metricAlerts/alert1?api-version=2018-03-01 response: body: - string: '{"Code":"BadRequest","Message":"When the alert rule contains multiple - criteria, the use of dimensions is limited to one value per dimension within - each criterion."}' + string: "{\r\n \"location\": \"global\",\r\n \"type\": \"Microsoft.Insights/metricAlerts\",\r\n + \ \"name\": \"alert1\",\r\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/Microsoft.Insights/metricAlerts/alert1\",\r\n + \ \"tags\": {\r\n \"foo\": \"boo\"\r\n },\r\n \"properties\": {\r\n \"description\": + \"alt desc\",\r\n \"severity\": 3,\r\n \"enabled\": true,\r\n \"scopes\": + [\r\n \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/Microsoft.Storage/storageAccounts/clitest000002\"\r\n + \ ],\r\n \"evaluationFrequency\": \"PT5M\",\r\n \"windowSize\": \"PT15M\",\r\n + \ \"templateType\": 8,\r\n \"criteria\": {\r\n \"allOf\": [\r\n + \ {\r\n \"threshold\": 250.0,\r\n \"name\": \"cond1\",\r\n + \ \"metricNamespace\": \"microsoft.storage/storageaccounts\",\r\n + \ \"metricName\": \"SuccessE2ELatency\",\r\n \"dimensions\": + [\r\n {\r\n \"name\": \"ApiName\",\r\n \"operator\": + \"Include\",\r\n \"values\": [\r\n \"GetBlob\"\r\n + \ ]\r\n }\r\n ],\r\n \"operator\": + \"GreaterThan\",\r\n \"timeAggregation\": \"Average\",\r\n \"criterionType\": + \"StaticThresholdCriterion\"\r\n }\r\n ],\r\n \"odata.type\": + \"Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria\"\r\n },\r\n + \ \"autoMitigate\": true,\r\n \"targetResourceType\": \"microsoft.storage/storageaccounts\",\r\n + \ \"actions\": [\r\n {\r\n \"actionGroupId\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/microsoft.insights/actionGroups/ag2\",\r\n + \ \"webHookProperties\": {\r\n \"test\": \"best\"\r\n }\r\n + \ }\r\n ]\r\n }\r\n}" headers: cache-control: - no-cache content-length: - - '164' + - '1871' content-type: - application/json; charset=utf-8 date: - - Mon, 06 Jan 2020 02:07:05 GMT + - Mon, 06 Jan 2020 04:28:26 GMT expires: - '-1' pragma: @@ -345,6 +360,10 @@ interactions: - Microsoft-IIS/10.0 strict-transport-security: - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding x-aspnet-version: - 4.0.30319 x-content-type-options: @@ -354,6 +373,1093 @@ interactions: x-powered-by: - ASP.NET status: - code: 400 - message: BadRequest + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - monitor metrics alert update + Connection: + - keep-alive + ParameterSetName: + - -g -n --enabled + User-Agent: + - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.9 msrest_azure/0.6.2 azure-mgmt-monitor/0.7.0 + Azure-SDK-For-Python AZURECLI/2.0.79 + accept-language: + - en-US + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/Microsoft.Insights/metricAlerts/alert1?api-version=2018-03-01 + response: + body: + string: "{\r\n \"location\": \"global\",\r\n \"type\": \"Microsoft.Insights/metricAlerts\",\r\n + \ \"name\": \"alert1\",\r\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/Microsoft.Insights/metricAlerts/alert1\",\r\n + \ \"tags\": {\r\n \"foo\": \"boo\"\r\n },\r\n \"properties\": {\r\n \"description\": + \"alt desc\",\r\n \"severity\": 3,\r\n \"enabled\": true,\r\n \"scopes\": + [\r\n \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/Microsoft.Storage/storageAccounts/clitest000002\"\r\n + \ ],\r\n \"evaluationFrequency\": \"PT5M\",\r\n \"windowSize\": \"PT15M\",\r\n + \ \"templateType\": 8,\r\n \"criteria\": {\r\n \"allOf\": [\r\n + \ {\r\n \"threshold\": 250.0,\r\n \"name\": \"cond1\",\r\n + \ \"metricNamespace\": \"microsoft.storage/storageaccounts\",\r\n + \ \"metricName\": \"SuccessE2ELatency\",\r\n \"dimensions\": + [\r\n {\r\n \"name\": \"ApiName\",\r\n \"operator\": + \"Include\",\r\n \"values\": [\r\n \"GetBlob\"\r\n + \ ]\r\n }\r\n ],\r\n \"operator\": + \"GreaterThan\",\r\n \"timeAggregation\": \"Average\",\r\n \"criterionType\": + \"StaticThresholdCriterion\"\r\n }\r\n ],\r\n \"odata.type\": + \"Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria\"\r\n },\r\n + \ \"autoMitigate\": true,\r\n \"targetResourceType\": \"microsoft.storage/storageaccounts\",\r\n + \ \"actions\": [\r\n {\r\n \"actionGroupId\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/microsoft.insights/actionGroups/ag2\",\r\n + \ \"webHookProperties\": {\r\n \"test\": \"best\"\r\n }\r\n + \ }\r\n ]\r\n }\r\n}" + headers: + cache-control: + - no-cache + content-length: + - '1871' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 06 Jan 2020 04:28:27 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-IIS/10.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-aspnet-version: + - 4.0.30319 + x-content-type-options: + - nosniff + x-powered-by: + - ASP.NET + status: + code: 200 + message: OK +- request: + body: 'b''b\''{"location": "global", "tags": {"foo": "boo"}, "properties": {"description": + "alt desc", "severity": 3, "enabled": false, "scopes": ["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/Microsoft.Storage/storageAccounts/clitest000002"], + "evaluationFrequency": "PT5M", "windowSize": "PT15M", "targetResourceType": + "microsoft.storage/storageaccounts", "criteria": {"odata.type": "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria", + "allOf": [{"name": "cond1", "metricName": "SuccessE2ELatency", "metricNamespace": + "microsoft.storage/storageaccounts", "timeAggregation": "Average", "dimensions": + [{"name": "ApiName", "operator": "Include", "values": ["GetBlob"]}], "criterionType": + "StaticThresholdCriterion", "operator": "GreaterThan", "threshold": 250.0}]}, + "autoMitigate": true, "actions": [{"actionGroupId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/microsoft.insights/actionGroups/ag2"}]}}\''''' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - monitor metrics alert update + Connection: + - keep-alive + Content-Length: + - '1126' + Content-Type: + - application/json; charset=utf-8 + ParameterSetName: + - -g -n --enabled + User-Agent: + - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.9 msrest_azure/0.6.2 azure-mgmt-monitor/0.7.0 + Azure-SDK-For-Python AZURECLI/2.0.79 + accept-language: + - en-US + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/Microsoft.Insights/metricAlerts/alert1?api-version=2018-03-01 + response: + body: + string: "{\r\n \"location\": \"global\",\r\n \"type\": \"Microsoft.Insights/metricAlerts\",\r\n + \ \"name\": \"alert1\",\r\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/Microsoft.Insights/metricAlerts/alert1\",\r\n + \ \"tags\": {\r\n \"foo\": \"boo\"\r\n },\r\n \"properties\": {\r\n \"description\": + \"alt desc\",\r\n \"severity\": 3,\r\n \"enabled\": false,\r\n \"scopes\": + [\r\n \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/Microsoft.Storage/storageAccounts/clitest000002\"\r\n + \ ],\r\n \"evaluationFrequency\": \"PT5M\",\r\n \"windowSize\": \"PT15M\",\r\n + \ \"templateType\": 0,\r\n \"criteria\": {\r\n \"allOf\": [\r\n + \ {\r\n \"threshold\": 250.0,\r\n \"name\": \"cond1\",\r\n + \ \"metricNamespace\": \"microsoft.storage/storageaccounts\",\r\n + \ \"metricName\": \"SuccessE2ELatency\",\r\n \"dimensions\": + [\r\n {\r\n \"name\": \"ApiName\",\r\n \"operator\": + \"Include\",\r\n \"values\": [\r\n \"GetBlob\"\r\n + \ ]\r\n }\r\n ],\r\n \"operator\": + \"GreaterThan\",\r\n \"timeAggregation\": \"Average\",\r\n \"criterionType\": + \"StaticThresholdCriterion\"\r\n }\r\n ],\r\n \"odata.type\": + \"Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria\"\r\n },\r\n + \ \"autoMitigate\": true,\r\n \"targetResourceType\": \"microsoft.storage/storageaccounts\",\r\n + \ \"actions\": [\r\n {\r\n \"actionGroupId\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/microsoft.insights/actionGroups/ag2\"\r\n + \ }\r\n ]\r\n }\r\n}" + headers: + cache-control: + - no-cache + content-length: + - '1802' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 06 Jan 2020 04:28:31 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-IIS/10.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-aspnet-version: + - 4.0.30319 + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-resource-requests: + - '297' + x-powered-by: + - ASP.NET + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - monitor metrics alert list + Connection: + - keep-alive + ParameterSetName: + - -g + User-Agent: + - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.9 msrest_azure/0.6.2 azure-mgmt-monitor/0.7.0 + Azure-SDK-For-Python AZURECLI/2.0.79 + accept-language: + - en-US + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/Microsoft.Insights/metricAlerts?api-version=2018-03-01 + response: + body: + string: "{\r\n \"value\": [\r\n {\r\n \"location\": \"global\",\r\n + \ \"type\": \"Microsoft.Insights/metricAlerts\",\r\n \"name\": \"alert1\",\r\n + \ \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/Microsoft.Insights/metricAlerts/alert1\",\r\n + \ \"tags\": {\r\n \"foo\": \"boo\"\r\n },\r\n \"properties\": + {\r\n \"description\": \"alt desc\",\r\n \"severity\": 3,\r\n + \ \"enabled\": false,\r\n \"scopes\": [\r\n \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/Microsoft.Storage/storageAccounts/clitest000002\"\r\n + \ ],\r\n \"evaluationFrequency\": \"PT5M\",\r\n \"windowSize\": + \"PT15M\",\r\n \"templateType\": 0,\r\n \"criteria\": {\r\n + \ \"allOf\": [\r\n {\r\n \"threshold\": 250.0,\r\n + \ \"name\": \"cond1\",\r\n \"metricNamespace\": \"microsoft.storage/storageaccounts\",\r\n + \ \"metricName\": \"SuccessE2ELatency\",\r\n \"dimensions\": + [\r\n {\r\n \"name\": \"ApiName\",\r\n \"operator\": + \"Include\",\r\n \"values\": [\r\n \"GetBlob\"\r\n + \ ]\r\n }\r\n ],\r\n \"operator\": + \"GreaterThan\",\r\n \"timeAggregation\": \"Average\",\r\n \"criterionType\": + \"StaticThresholdCriterion\"\r\n }\r\n ],\r\n \"odata.type\": + \"Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria\"\r\n },\r\n + \ \"autoMitigate\": true,\r\n \"targetResourceType\": \"microsoft.storage/storageaccounts\",\r\n + \ \"actions\": [\r\n {\r\n \"actionGroupId\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/microsoft.insights/actionGroups/ag2\"\r\n + \ }\r\n ]\r\n }\r\n }\r\n ]\r\n}" + headers: + cache-control: + - no-cache + content-length: + - '2027' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 06 Jan 2020 04:28:33 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-IIS/10.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-aspnet-version: + - 4.0.30319 + x-content-type-options: + - nosniff + x-powered-by: + - ASP.NET + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - monitor metrics alert show + Connection: + - keep-alive + ParameterSetName: + - -g -n + User-Agent: + - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.9 msrest_azure/0.6.2 azure-mgmt-monitor/0.7.0 + Azure-SDK-For-Python AZURECLI/2.0.79 + accept-language: + - en-US + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/Microsoft.Insights/metricAlerts/alert1?api-version=2018-03-01 + response: + body: + string: "{\r\n \"location\": \"global\",\r\n \"type\": \"Microsoft.Insights/metricAlerts\",\r\n + \ \"name\": \"alert1\",\r\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/Microsoft.Insights/metricAlerts/alert1\",\r\n + \ \"tags\": {\r\n \"foo\": \"boo\"\r\n },\r\n \"properties\": {\r\n \"description\": + \"alt desc\",\r\n \"severity\": 3,\r\n \"enabled\": false,\r\n \"scopes\": + [\r\n \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/Microsoft.Storage/storageAccounts/clitest000002\"\r\n + \ ],\r\n \"evaluationFrequency\": \"PT5M\",\r\n \"windowSize\": \"PT15M\",\r\n + \ \"templateType\": 0,\r\n \"criteria\": {\r\n \"allOf\": [\r\n + \ {\r\n \"threshold\": 250.0,\r\n \"name\": \"cond1\",\r\n + \ \"metricNamespace\": \"microsoft.storage/storageaccounts\",\r\n + \ \"metricName\": \"SuccessE2ELatency\",\r\n \"dimensions\": + [\r\n {\r\n \"name\": \"ApiName\",\r\n \"operator\": + \"Include\",\r\n \"values\": [\r\n \"GetBlob\"\r\n + \ ]\r\n }\r\n ],\r\n \"operator\": + \"GreaterThan\",\r\n \"timeAggregation\": \"Average\",\r\n \"criterionType\": + \"StaticThresholdCriterion\"\r\n }\r\n ],\r\n \"odata.type\": + \"Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria\"\r\n },\r\n + \ \"autoMitigate\": true,\r\n \"targetResourceType\": \"microsoft.storage/storageaccounts\",\r\n + \ \"actions\": [\r\n {\r\n \"actionGroupId\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/microsoft.insights/actionGroups/ag2\"\r\n + \ }\r\n ]\r\n }\r\n}" + headers: + cache-control: + - no-cache + content-length: + - '1802' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 06 Jan 2020 04:28:35 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-IIS/10.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-aspnet-version: + - 4.0.30319 + x-content-type-options: + - nosniff + x-powered-by: + - ASP.NET + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - monitor metrics alert delete + Connection: + - keep-alive + Content-Length: + - '0' + ParameterSetName: + - -g -n + User-Agent: + - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.9 msrest_azure/0.6.2 azure-mgmt-monitor/0.7.0 + Azure-SDK-For-Python AZURECLI/2.0.79 + accept-language: + - en-US + method: DELETE + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/Microsoft.Insights/metricAlerts/alert1?api-version=2018-03-01 + response: + body: + string: '' + headers: + cache-control: + - no-cache + content-length: + - '0' + date: + - Mon, 06 Jan 2020 04:28:41 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-IIS/10.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + x-aspnet-version: + - 4.0.30319 + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-deletes: + - '14999' + x-powered-by: + - ASP.NET + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - monitor metrics alert list + Connection: + - keep-alive + ParameterSetName: + - -g + User-Agent: + - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.9 msrest_azure/0.6.2 azure-mgmt-monitor/0.7.0 + Azure-SDK-For-Python AZURECLI/2.0.79 + accept-language: + - en-US + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/Microsoft.Insights/metricAlerts?api-version=2018-03-01 + response: + body: + string: "{\r\n \"value\": []\r\n}" + headers: + cache-control: + - no-cache + content-length: + - '19' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 06 Jan 2020 04:28:43 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-IIS/10.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-aspnet-version: + - 4.0.30319 + x-content-type-options: + - nosniff + x-powered-by: + - ASP.NET + status: + code: 200 + message: OK +- request: + body: 'b''b\''{"location": "global", "properties": {"description": "Test2", "severity": + 2, "enabled": true, "scopes": ["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/Microsoft.Storage/storageAccounts/clitest000002"], + "evaluationFrequency": "PT1M", "windowSize": "PT5M", "criteria": {"odata.type": + "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria", "allOf": [{"name": + "cond0", "metricName": "SuccessE2ELatency", "timeAggregation": "Average", "dimensions": + [{"name": "ApiName", "operator": "Include", "values": ["GetBlob:"]}], "criterionType": + "StaticThresholdCriterion", "operator": "GreaterThan", "threshold": 250.0}]}, + "actions": [{"actionGroupId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/microsoft.insights/actionGroups/ag1"}]}}\''''' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - monitor metrics alert create + Connection: + - keep-alive + Content-Length: + - '961' + Content-Type: + - application/json; charset=utf-8 + ParameterSetName: + - -g -n --scopes --action --description --condition + User-Agent: + - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.9 msrest_azure/0.6.2 azure-mgmt-monitor/0.7.0 + Azure-SDK-For-Python AZURECLI/2.0.79 + accept-language: + - en-US + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/Microsoft.Insights/metricAlerts/alert1?api-version=2018-03-01 + response: + body: + string: "{\r\n \"location\": \"global\",\r\n \"type\": \"Microsoft.Insights/metricAlerts\",\r\n + \ \"name\": \"alert1\",\r\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/Microsoft.Insights/metricAlerts/alert1\",\r\n + \ \"properties\": {\r\n \"description\": \"Test2\",\r\n \"severity\": + 2,\r\n \"enabled\": true,\r\n \"scopes\": [\r\n \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/Microsoft.Storage/storageAccounts/clitest000002\"\r\n + \ ],\r\n \"evaluationFrequency\": \"PT1M\",\r\n \"windowSize\": \"PT5M\",\r\n + \ \"templateType\": 8,\r\n \"criteria\": {\r\n \"allOf\": [\r\n + \ {\r\n \"threshold\": 250.0,\r\n \"name\": \"cond0\",\r\n + \ \"metricNamespace\": \"microsoft.storage/storageaccounts\",\r\n + \ \"metricName\": \"SuccessE2ELatency\",\r\n \"dimensions\": + [\r\n {\r\n \"name\": \"ApiName\",\r\n \"operator\": + \"Include\",\r\n \"values\": [\r\n \"GetBlob:\"\r\n + \ ]\r\n }\r\n ],\r\n \"operator\": + \"GreaterThan\",\r\n \"timeAggregation\": \"Average\",\r\n \"criterionType\": + \"StaticThresholdCriterion\"\r\n }\r\n ],\r\n \"odata.type\": + \"Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria\"\r\n },\r\n + \ \"targetResourceType\": \"microsoft.storage/storageaccounts\",\r\n \"actions\": + [\r\n {\r\n \"actionGroupId\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/microsoft.insights/actionGroups/ag1\"\r\n + \ }\r\n ]\r\n }\r\n}" + headers: + cache-control: + - no-cache + content-length: + - '1734' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 06 Jan 2020 04:28:54 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-IIS/10.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-aspnet-version: + - 4.0.30319 + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-resource-requests: + - '299' + x-powered-by: + - ASP.NET + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - appservice plan create + Connection: + - keep-alive + ParameterSetName: + - -g -n + User-Agent: + - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.9 msrest_azure/0.6.2 azure-mgmt-resource/6.0.0 + Azure-SDK-For-Python AZURECLI/2.0.79 + accept-language: + - en-US + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_metric_alert_v2000001?api-version=2019-07-01 + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001","name":"cli_test_metric_alert_v2000001","type":"Microsoft.Resources/resourceGroups","location":"westus","tags":{"product":"azurecli","cause":"automation","date":"2020-01-06T04:27:26Z"},"properties":{"provisioningState":"Succeeded"}}' + headers: + cache-control: + - no-cache + content-length: + - '428' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 06 Jan 2020 04:28:56 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: '{"name": "plan1", "type": "Microsoft.Web/serverfarms", "location": "westus", + "properties": {"skuName": "B1", "capacity": 1}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - appservice plan create + Connection: + - keep-alive + Content-Length: + - '124' + Content-Type: + - application/json; charset=utf-8 + ParameterSetName: + - -g -n + User-Agent: + - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.9 msrest_azure/0.6.2 azure-mgmt-web/0.42.0 + Azure-SDK-For-Python AZURECLI/2.0.79 + accept-language: + - en-US + method: POST + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/Microsoft.Web/validate?api-version=2018-02-01 + response: + body: + string: '{"status":"Success","error":null}' + headers: + cache-control: + - no-cache + content-length: + - '33' + content-type: + - application/json + date: + - Mon, 06 Jan 2020 04:28:56 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-IIS/10.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-aspnet-version: + - 4.0.30319 + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-writes: + - '1198' + x-powered-by: + - ASP.NET + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - appservice plan create + Connection: + - keep-alive + ParameterSetName: + - -g -n + User-Agent: + - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.9 msrest_azure/0.6.2 azure-mgmt-resource/6.0.0 + Azure-SDK-For-Python AZURECLI/2.0.79 + accept-language: + - en-US + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_metric_alert_v2000001?api-version=2019-07-01 + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001","name":"cli_test_metric_alert_v2000001","type":"Microsoft.Resources/resourceGroups","location":"westus","tags":{"product":"azurecli","cause":"automation","date":"2020-01-06T04:27:26Z"},"properties":{"provisioningState":"Succeeded"}}' + headers: + cache-control: + - no-cache + content-length: + - '428' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 06 Jan 2020 04:28:58 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: '{"location": "westus", "properties": {"perSiteScaling": false, "isXenon": + false}, "sku": {"name": "B1", "tier": "BASIC", "capacity": 1}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - appservice plan create + Connection: + - keep-alive + Content-Length: + - '136' + Content-Type: + - application/json; charset=utf-8 + ParameterSetName: + - -g -n + User-Agent: + - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.9 msrest_azure/0.6.2 azure-mgmt-web/0.42.0 + Azure-SDK-For-Python AZURECLI/2.0.79 + accept-language: + - en-US + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/Microsoft.Web/serverfarms/plan1?api-version=2018-02-01 + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/Microsoft.Web/serverfarms/plan1","name":"plan1","type":"Microsoft.Web/serverfarms","kind":"app","location":"West + US","properties":{"serverFarmId":23792,"name":"plan1","workerSize":"Default","workerSizeId":0,"workerTierName":null,"numberOfWorkers":1,"currentWorkerSize":"Default","currentWorkerSizeId":0,"currentNumberOfWorkers":1,"status":"Ready","webSpace":"cli_test_metric_alert_v2000001-WestUSwebspace","subscription":"0b1f6471-1bf0-4dda-aec3-cb9272f09590","adminSiteName":null,"hostingEnvironment":null,"hostingEnvironmentProfile":null,"maximumNumberOfWorkers":3,"planName":"VirtualDedicatedPlan","adminRuntimeSiteName":null,"computeMode":"Dedicated","siteMode":null,"geoRegion":"West + US","perSiteScaling":false,"maximumElasticWorkerCount":1,"numberOfSites":0,"hostingEnvironmentId":null,"isSpot":false,"spotExpirationTime":null,"freeOfferExpirationTime":null,"tags":null,"kind":"app","resourceGroup":"cli_test_metric_alert_v2000001","reserved":false,"isXenon":false,"hyperV":false,"mdmId":"waws-prod-bay-053_23792","targetWorkerCount":0,"targetWorkerSizeId":0,"provisioningState":"Succeeded","webSiteId":null,"existingServerFarmIds":null},"sku":{"name":"B1","tier":"Basic","size":"B1","family":"B","capacity":1}}' + headers: + cache-control: + - no-cache + content-length: + - '1467' + content-type: + - application/json + date: + - Mon, 06 Jan 2020 04:29:10 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-IIS/10.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-aspnet-version: + - 4.0.30319 + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-writes: + - '1196' + x-powered-by: + - ASP.NET + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - webapp create + Connection: + - keep-alive + ParameterSetName: + - -g -n -p + User-Agent: + - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.9 msrest_azure/0.6.2 azure-mgmt-web/0.42.0 + Azure-SDK-For-Python AZURECLI/2.0.79 + accept-language: + - en-US + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/Microsoft.Web/serverfarms/plan1?api-version=2018-02-01 + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/Microsoft.Web/serverfarms/plan1","name":"plan1","type":"Microsoft.Web/serverfarms","kind":"app","location":"West + US","properties":{"serverFarmId":23792,"name":"plan1","workerSize":"Default","workerSizeId":0,"workerTierName":null,"numberOfWorkers":1,"currentWorkerSize":"Default","currentWorkerSizeId":0,"currentNumberOfWorkers":1,"status":"Ready","webSpace":"cli_test_metric_alert_v2000001-WestUSwebspace","subscription":"0b1f6471-1bf0-4dda-aec3-cb9272f09590","adminSiteName":null,"hostingEnvironment":null,"hostingEnvironmentProfile":null,"maximumNumberOfWorkers":3,"planName":"VirtualDedicatedPlan","adminRuntimeSiteName":null,"computeMode":"Dedicated","siteMode":null,"geoRegion":"West + US","perSiteScaling":false,"maximumElasticWorkerCount":1,"numberOfSites":0,"hostingEnvironmentId":null,"isSpot":false,"spotExpirationTime":null,"freeOfferExpirationTime":null,"tags":null,"kind":"app","resourceGroup":"cli_test_metric_alert_v2000001","reserved":false,"isXenon":false,"hyperV":false,"mdmId":"waws-prod-bay-053_23792","targetWorkerCount":0,"targetWorkerSizeId":0,"provisioningState":"Succeeded","webSiteId":null,"existingServerFarmIds":null},"sku":{"name":"B1","tier":"Basic","size":"B1","family":"B","capacity":1}}' + headers: + cache-control: + - no-cache + content-length: + - '1467' + content-type: + - application/json + date: + - Mon, 06 Jan 2020 04:29:12 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-IIS/10.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-aspnet-version: + - 4.0.30319 + x-content-type-options: + - nosniff + x-powered-by: + - ASP.NET + status: + code: 200 + message: OK +- request: + body: 'b''{"name": "app000003", "type": "Microsoft.Web/sites", "location": "West + US", "properties": {"serverFarmId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/Microsoft.Web/serverfarms/plan1"}}''' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - webapp create + Connection: + - keep-alive + Content-Length: + - '301' + Content-Type: + - application/json; charset=utf-8 + ParameterSetName: + - -g -n -p + User-Agent: + - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.9 msrest_azure/0.6.2 azure-mgmt-web/0.42.0 + Azure-SDK-For-Python AZURECLI/2.0.79 + accept-language: + - en-US + method: POST + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/Microsoft.Web/validate?api-version=2018-02-01 + response: + body: + string: '{"status":"Success","error":null}' + headers: + cache-control: + - no-cache + content-length: + - '33' + content-type: + - application/json + date: + - Mon, 06 Jan 2020 04:29:14 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-IIS/10.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-aspnet-version: + - 4.0.30319 + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-writes: + - '1199' + x-powered-by: + - ASP.NET + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - webapp create + Connection: + - keep-alive + ParameterSetName: + - -g -n -p + User-Agent: + - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.9 msrest_azure/0.6.2 azure-mgmt-web/0.42.0 + Azure-SDK-For-Python AZURECLI/2.0.79 + accept-language: + - en-US + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/Microsoft.Web/serverfarms/plan1?api-version=2018-02-01 + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/Microsoft.Web/serverfarms/plan1","name":"plan1","type":"Microsoft.Web/serverfarms","kind":"app","location":"West + US","properties":{"serverFarmId":23792,"name":"plan1","workerSize":"Default","workerSizeId":0,"workerTierName":null,"numberOfWorkers":1,"currentWorkerSize":"Default","currentWorkerSizeId":0,"currentNumberOfWorkers":1,"status":"Ready","webSpace":"cli_test_metric_alert_v2000001-WestUSwebspace","subscription":"0b1f6471-1bf0-4dda-aec3-cb9272f09590","adminSiteName":null,"hostingEnvironment":null,"hostingEnvironmentProfile":null,"maximumNumberOfWorkers":3,"planName":"VirtualDedicatedPlan","adminRuntimeSiteName":null,"computeMode":"Dedicated","siteMode":null,"geoRegion":"West + US","perSiteScaling":false,"maximumElasticWorkerCount":1,"numberOfSites":0,"hostingEnvironmentId":null,"isSpot":false,"spotExpirationTime":null,"freeOfferExpirationTime":null,"tags":null,"kind":"app","resourceGroup":"cli_test_metric_alert_v2000001","reserved":false,"isXenon":false,"hyperV":false,"mdmId":"waws-prod-bay-053_23792","targetWorkerCount":0,"targetWorkerSizeId":0,"provisioningState":"Succeeded","webSiteId":null,"existingServerFarmIds":null},"sku":{"name":"B1","tier":"Basic","size":"B1","family":"B","capacity":1}}' + headers: + cache-control: + - no-cache + content-length: + - '1467' + content-type: + - application/json + date: + - Mon, 06 Jan 2020 04:29:16 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-IIS/10.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-aspnet-version: + - 4.0.30319 + x-content-type-options: + - nosniff + x-powered-by: + - ASP.NET + status: + code: 200 + message: OK +- request: + body: 'b''{"location": "West US", "properties": {"serverFarmId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/Microsoft.Web/serverfarms/plan1", + "reserved": false, "isXenon": false, "hyperV": false, "siteConfig": {"netFrameworkVersion": + "v4.6", "appSettings": [{"name": "WEBSITE_NODE_DEFAULT_VERSION", "value": "10.14"}], + "localMySqlEnabled": false, "http20Enabled": true}, "scmSiteAlsoStopped": false, + "httpsOnly": false}}''' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - webapp create + Connection: + - keep-alive + Content-Length: + - '521' + Content-Type: + - application/json; charset=utf-8 + ParameterSetName: + - -g -n -p + User-Agent: + - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.9 msrest_azure/0.6.2 azure-mgmt-web/0.42.0 + Azure-SDK-For-Python AZURECLI/2.0.79 + accept-language: + - en-US + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/Microsoft.Web/sites/app000003?api-version=2018-11-01 + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/Microsoft.Web/sites/app000003","name":"app000003","type":"Microsoft.Web/sites","kind":"app","location":"West + US","properties":{"name":"app000003","state":"Running","hostNames":["app000003.azurewebsites.net"],"webSpace":"cli_test_metric_alert_v2000001-WestUSwebspace","selfLink":"https://waws-prod-bay-053.api.azurewebsites.windows.net:454/subscriptions/00000000-0000-0000-0000-000000000000/webspaces/cli_test_metric_alert_v2000001-WestUSwebspace/sites/app000003","repositorySiteName":"app000003","owner":null,"usageState":"Normal","enabled":true,"adminEnabled":true,"enabledHostNames":["app000003.azurewebsites.net","app000003.scm.azurewebsites.net"],"siteProperties":{"metadata":null,"properties":[{"name":"LinuxFxVersion","value":""},{"name":"WindowsFxVersion","value":null}],"appSettings":null},"availabilityState":"Normal","sslCertificates":null,"csrs":[],"cers":null,"siteMode":null,"hostNameSslStates":[{"name":"app000003.azurewebsites.net","sslState":"Disabled","ipBasedSslResult":null,"virtualIP":null,"thumbprint":null,"toUpdate":null,"toUpdateIpBasedSsl":null,"ipBasedSslState":"NotConfigured","hostType":"Standard"},{"name":"app000003.scm.azurewebsites.net","sslState":"Disabled","ipBasedSslResult":null,"virtualIP":null,"thumbprint":null,"toUpdate":null,"toUpdateIpBasedSsl":null,"ipBasedSslState":"NotConfigured","hostType":"Repository"}],"computeMode":null,"serverFarm":null,"serverFarmId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/Microsoft.Web/serverfarms/plan1","reserved":false,"isXenon":false,"hyperV":false,"lastModifiedTimeUtc":"2020-01-06T04:29:22.7233333","storageRecoveryDefaultState":"Running","contentAvailabilityState":"Normal","runtimeAvailabilityState":"Normal","siteConfig":null,"deploymentId":"app000003","trafficManagerHostNames":null,"sku":"Basic","scmSiteAlsoStopped":false,"targetSwapSlot":null,"hostingEnvironment":null,"hostingEnvironmentProfile":null,"clientAffinityEnabled":true,"clientCertEnabled":false,"clientCertExclusionPaths":null,"hostNamesDisabled":false,"domainVerificationIdentifiers":null,"customDomainVerificationId":"E3DC0535C9C32C7919A1E64809EC7743CEB7AC5DD4113286F72952B4CA5CB435","kind":"app","inboundIpAddress":"40.83.184.25","possibleInboundIpAddresses":"40.83.184.25","outboundIpAddresses":"40.83.189.163,40.83.189.130,40.83.188.201,40.83.187.134","possibleOutboundIpAddresses":"40.83.189.163,40.83.189.130,40.83.188.201,40.83.187.134","containerSize":0,"dailyMemoryTimeQuota":0,"suspendedTill":null,"siteDisabledReason":0,"functionExecutionUnitsCache":null,"maxNumberOfWorkers":null,"homeStamp":"waws-prod-bay-053","cloningInfo":null,"hostingEnvironmentId":null,"tags":null,"resourceGroup":"cli_test_metric_alert_v2000001","defaultHostName":"app000003.azurewebsites.net","slotSwapStatus":null,"httpsOnly":false,"redundancyMode":"None","inProgressOperationId":null,"geoDistributions":null,"privateEndpointConnections":null,"buildVersion":null,"targetBuildVersion":null}}' + headers: + cache-control: + - no-cache + content-length: + - '3407' + content-type: + - application/json + date: + - Mon, 06 Jan 2020 04:29:40 GMT + etag: + - '"1D5C449DF395EB5"' + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-IIS/10.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-aspnet-version: + - 4.0.30319 + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-resource-requests: + - '499' + x-powered-by: + - ASP.NET + status: + code: 200 + message: OK +- request: + body: '{}' + headers: + Accept: + - application/xml + Accept-Encoding: + - gzip, deflate + CommandName: + - webapp create + Connection: + - keep-alive + Content-Length: + - '2' + Content-Type: + - application/json; charset=utf-8 + ParameterSetName: + - -g -n -p + User-Agent: + - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.9 msrest_azure/0.6.2 azure-mgmt-web/0.42.0 + Azure-SDK-For-Python AZURECLI/2.0.79 + accept-language: + - en-US + method: POST + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/Microsoft.Web/sites/app000003/publishxml?api-version=2018-11-01 + response: + body: + string: + headers: + cache-control: + - no-cache + content-length: + - '1613' + content-type: + - application/xml + date: + - Mon, 06 Jan 2020 04:29:40 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-IIS/10.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + x-aspnet-version: + - 4.0.30319 + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-resource-requests: + - '11999' + x-powered-by: + - ASP.NET + status: + code: 200 + message: OK +- request: + body: 'b''{"location": "global", "properties": {"description": "Test *", "severity": + 2, "enabled": true, "scopes": ["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/Microsoft.Web/sites/app000003"], + "evaluationFrequency": "PT1M", "windowSize": "PT5M", "criteria": {"odata.type": + "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria", "allOf": [{"name": + "cond0", "metricName": "Http4xx", "timeAggregation": "Total", "dimensions": + [{"name": "Instance", "operator": "Include", "values": ["*"]}], "criterionType": + "StaticThresholdCriterion", "operator": "GreaterThan", "threshold": 10.0}]}, + "actions": [{"actionGroupId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/microsoft.insights/actionGroups/ag1"}]}}''' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - monitor metrics alert create + Connection: + - keep-alive + Content-Length: + - '920' + Content-Type: + - application/json; charset=utf-8 + ParameterSetName: + - -g -n --scopes --action --description --condition + User-Agent: + - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.9 msrest_azure/0.6.2 azure-mgmt-monitor/0.7.0 + Azure-SDK-For-Python AZURECLI/2.0.79 + accept-language: + - en-US + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/Microsoft.Insights/metricAlerts/alert12?api-version=2018-03-01 + response: + body: + string: "{\r\n \"location\": \"global\",\r\n \"type\": \"Microsoft.Insights/metricAlerts\",\r\n + \ \"name\": \"alert12\",\r\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/Microsoft.Insights/metricAlerts/alert12\",\r\n + \ \"properties\": {\r\n \"description\": \"Test *\",\r\n \"severity\": + 2,\r\n \"enabled\": true,\r\n \"scopes\": [\r\n \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/Microsoft.Web/sites/app000003\"\r\n + \ ],\r\n \"evaluationFrequency\": \"PT1M\",\r\n \"windowSize\": \"PT5M\",\r\n + \ \"templateType\": 8,\r\n \"criteria\": {\r\n \"allOf\": [\r\n + \ {\r\n \"threshold\": 10.0,\r\n \"name\": \"cond0\",\r\n + \ \"metricNamespace\": \"microsoft.web/sites\",\r\n \"metricName\": + \"Http4xx\",\r\n \"dimensions\": [\r\n {\r\n \"name\": + \"Instance\",\r\n \"operator\": \"Include\",\r\n \"values\": + [\r\n \"*\"\r\n ]\r\n }\r\n ],\r\n + \ \"operator\": \"GreaterThan\",\r\n \"timeAggregation\": + \"Total\",\r\n \"criterionType\": \"StaticThresholdCriterion\"\r\n + \ }\r\n ],\r\n \"odata.type\": \"Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria\"\r\n + \ },\r\n \"targetResourceType\": \"microsoft.web/sites\",\r\n \"actions\": + [\r\n {\r\n \"actionGroupId\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_metric_alert_v2000001/providers/microsoft.insights/actionGroups/ag1\"\r\n + \ }\r\n ]\r\n }\r\n}" + headers: + cache-control: + - no-cache + content-length: + - '1667' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 06 Jan 2020 04:29:56 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-IIS/10.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-aspnet-version: + - 4.0.30319 + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-resource-requests: + - '298' + x-powered-by: + - ASP.NET + status: + code: 200 + message: OK version: 1 diff --git a/src/azure-cli/azure/cli/command_modules/monitor/tests/latest/test_monitor_metric_alert_scenarios.py b/src/azure-cli/azure/cli/command_modules/monitor/tests/latest/test_monitor_metric_alert_scenarios.py index ba733a3e3d6..7cf9d000493 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/tests/latest/test_monitor_metric_alert_scenarios.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/tests/latest/test_monitor_metric_alert_scenarios.py @@ -42,15 +42,14 @@ def test_metric_alert_v2_scenario(self, resource_group, storage_account): self.check('length(criteria.allOf[0].dimensions)', 2), self.check('length(criteria.allOf[1].dimensions)', 1) ]) - self.cmd('monitor metrics alert update -g {rg} -n {alert} --severity 3 --description "alt desc" --add-action ag2 test=best --remove-action ag1 --remove-conditions cond0 --add-condition "total transactions < 100" --evaluation-frequency 5m --window-size 15m --tags foo=boo --auto-mitigate', checks=[ + self.cmd('monitor metrics alert update -g {rg} -n {alert} --severity 3 --description "alt desc" --add-action ag2 test=best --remove-action ag1 --remove-conditions cond0 --evaluation-frequency 5m --window-size 15m --tags foo=boo --auto-mitigate', checks=[ self.check('description', 'alt desc'), self.check('severity', 3), self.check('autoMitigate', True), self.check('windowSize', '0:15:00'), self.check('evaluationFrequency', '0:05:00'), - self.check('length(criteria.allOf)', 2), + self.check('length(criteria.allOf)', 1), self.check('length(criteria.allOf[0].dimensions)', 1), - self.check('length(criteria.allOf[1].dimensions)', 0), self.check("contains(actions[0].actionGroupId, 'actionGroups/ag2')", True), self.check('length(actions)', 1) ])