From 825ca3400fd2c913830abb009846b012a13ac195 Mon Sep 17 00:00:00 2001 From: Meydan Dayan Date: Tue, 16 Jul 2019 23:48:26 +0300 Subject: [PATCH 1/2] Added unit tests for dynamic metric alert --- .../tests/BasicTests/MetricAlertsTests.cs | 221 +++++++++++- .../tests/Scenarios/MetricAlertsTests.cs | 325 ++++++++++++++++++ .../DynamicMetricAlertRuleFlow.json | 275 +++++++++++++++ ...ourceGroupLevelDynamicMetricAlertRule.json | 275 +++++++++++++++ ...sourceLevelDynamicMetricAlertRuleFlow.json | 275 +++++++++++++++ ...bscriptionLevelDynamicMetricAlertRule.json | 275 +++++++++++++++ 6 files changed, 1644 insertions(+), 2 deletions(-) create mode 100644 sdk/monitor/Microsoft.Azure.Management.Monitor/tests/SessionRecords/Monitor.Tests.Scenarios.MetricAlertsTests/DynamicMetricAlertRuleFlow.json create mode 100644 sdk/monitor/Microsoft.Azure.Management.Monitor/tests/SessionRecords/Monitor.Tests.Scenarios.MetricAlertsTests/MultiResResourceGroupLevelDynamicMetricAlertRule.json create mode 100644 sdk/monitor/Microsoft.Azure.Management.Monitor/tests/SessionRecords/Monitor.Tests.Scenarios.MetricAlertsTests/MultiResResourceLevelDynamicMetricAlertRuleFlow.json create mode 100644 sdk/monitor/Microsoft.Azure.Management.Monitor/tests/SessionRecords/Monitor.Tests.Scenarios.MetricAlertsTests/MultiResSubscriptionLevelDynamicMetricAlertRule.json diff --git a/sdk/monitor/Microsoft.Azure.Management.Monitor/tests/BasicTests/MetricAlertsTests.cs b/sdk/monitor/Microsoft.Azure.Management.Monitor/tests/BasicTests/MetricAlertsTests.cs index fe5be63799cd1..81d6c21e82de7 100644 --- a/sdk/monitor/Microsoft.Azure.Management.Monitor/tests/BasicTests/MetricAlertsTests.cs +++ b/sdk/monitor/Microsoft.Azure.Management.Monitor/tests/BasicTests/MetricAlertsTests.cs @@ -57,6 +57,27 @@ public void CreateUpdateMultiResourceMetricAlertRuleTest() Utilities.AreEqual(expectedParams, result); } + [Fact] + [Trait("Category", "Mock")] + public void CreateUpdateDynamicMetricAlertRuleTest() + { + MetricAlertResource expectedParams = GetSampleDynamicMetricRuleResourceParams(); + var handler = new RecordedDelegatingHandler(); + var insightClient = GetMonitorManagementClient(handler); + var serializedObject = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(expectedParams, insightClient.SerializationSettings); + + var expectedResponse = new HttpResponseMessage(HttpStatusCode.OK) + { + Content = new StringContent(serializedObject) + }; + + handler = new RecordedDelegatingHandler(expectedResponse); + insightClient = GetMonitorManagementClient(handler); + + var result = insightClient.MetricAlerts.CreateOrUpdate(resourceGroupName: "rg1", ruleName: "Rule1", parameters: expectedParams); + Utilities.AreEqual(expectedParams, result); + } + [Fact] [Trait("Category", "Mock")] public void ListMetricAlertRuleByResourceGroupTest() @@ -78,6 +99,27 @@ public void ListMetricAlertRuleByResourceGroupTest() Utilities.AreEqual(expectedResponseValue, actualResponse.ToList()); } + [Fact] + [Trait("Category", "Mock")] + public void CreateUpdateDynamicMultiResourceMetricAlertRuleTest() + { + MetricAlertResource expectedParams = GetSampleMultiResourceDynamicMetricRuleResourceParams(); + var handler = new RecordedDelegatingHandler(); + var insightClient = GetMonitorManagementClient(handler); + var serializedObject = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(expectedParams, insightClient.SerializationSettings); + + var expectedResponse = new HttpResponseMessage(HttpStatusCode.OK) + { + Content = new StringContent(serializedObject) + }; + + handler = new RecordedDelegatingHandler(expectedResponse); + insightClient = GetMonitorManagementClient(handler); + + var result = insightClient.MetricAlerts.CreateOrUpdate(resourceGroupName: "rg1", ruleName: "Rule2", parameters: expectedParams); + Utilities.AreEqual(expectedParams, result); + } + [Fact] [Trait("Category", "Mock")] public void ListMetricAlertsBySubscriptionTest() @@ -162,6 +204,48 @@ public void GetMultiResourceMetricAlertTest() Utilities.AreEqual(expectedParams, result); } + [Fact] + [Trait("Category", "Mock")] + public void GetDynamicMetricAlertTest() + { + MetricAlertResource expectedParams = GetSampleDynamicMetricRuleResourceParams(); + var handler = new RecordedDelegatingHandler(); + var insightClient = GetMonitorManagementClient(handler); + var serializedObject = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(expectedParams, insightClient.SerializationSettings); + + var expectedResponse = new HttpResponseMessage(HttpStatusCode.OK) + { + Content = new StringContent(serializedObject) + }; + + handler = new RecordedDelegatingHandler(expectedResponse); + insightClient = GetMonitorManagementClient(handler); + + var result = insightClient.MetricAlerts.Get(resourceGroupName: "rg1", ruleName: "Rule1"); + Utilities.AreEqual(expectedParams, result); + } + + [Fact] + [Trait("Category", "Mock")] + public void GetMultiResourceDynamicMetricAlertTest() + { + MetricAlertResource expectedParams = GetSampleMultiResourceDynamicMetricRuleResourceParams(); + var handler = new RecordedDelegatingHandler(); + var insightClient = GetMonitorManagementClient(handler); + var serializedObject = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(expectedParams, insightClient.SerializationSettings); + + var expectedResponse = new HttpResponseMessage(HttpStatusCode.OK) + { + Content = new StringContent(serializedObject) + }; + + handler = new RecordedDelegatingHandler(expectedResponse); + insightClient = GetMonitorManagementClient(handler); + + var result = insightClient.MetricAlerts.Get(resourceGroupName: "rg1", ruleName: "Rule1"); + Utilities.AreEqual(expectedParams, result); + } + private MetricAlertStatusCollection GetMetricAlertStatus() { MetricAlertStatusProperties statusProps = new MetricAlertStatusProperties() @@ -225,8 +309,49 @@ private List GetSampleMetricAlertCollection() { ActionGroupId = "/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourcegroups/default-activitylogalerts/providers/microsoft.insights/actiongroups/anashah" } - } - ) + }), + new MetricAlertResource( + description: "alert description", + severity: 3, + location: "Location", + enabled: true, + scopes: new List() + { + "/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourceGroups/SanjaychResourceGroup/providers/Microsoft.Compute/virtualMachines/SCCMDemo2" + }, + evaluationFrequency: new TimeSpan(hours: 0, minutes: 5, seconds: 0), + windowSize: new TimeSpan(hours: 0, minutes: 5, seconds: 0), + criteria: GetSampleDynamicMetricCriteria(), + actions: new List() + { + new MetricAlertAction() + { + ActionGroupId = "/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourcegroups/custommetricdemo/providers/microsoft.insights/actiongroups/scactiongroup" + } + } + ), + new MetricAlertResource( + description: "alert description", + severity: 3, + location: "global", + enabled: true, + targetResourceRegion: "southcentralus", + targetResourceType: "Microsoft.Compute/virtualMachines", + scopes: new List() + { + "/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourceGroups/SanjaychResourceGroup/providers/Microsoft.Compute/virtualMachines/SCCMDemo2", + "/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourceGroups/SanjaychResourceGroup/providers/Microsoft.Compute/virtualMachines/SCCMDemo3" + }, + evaluationFrequency: new TimeSpan(hours: 0, minutes: 5, seconds: 0), + windowSize: new TimeSpan(hours: 0, minutes: 5 ,seconds: 0), + criteria: GetSampleDynamicMetricCriteria(), + actions: new List() + { + new MetricAlertAction() + { + ActionGroupId = "/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourcegroups/default-activitylogalerts/providers/microsoft.insights/actiongroups/anashah" + } + }) }; } @@ -256,6 +381,32 @@ private MetricAlertResource GetSampleMetricRuleResourceParams() ); } + private MetricAlertResource GetSampleDynamicMetricRuleResourceParams() + { + MetricAlertMultipleResourceMultipleMetricCriteria metricCriteria = GetSampleDynamicMetricCriteria(); + + return new MetricAlertResource( + description: "alert description", + severity: 3, + location: "Location", + enabled: true, + scopes: new List() + { + "/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourceGroups/SanjaychResourceGroup/providers/Microsoft.Compute/virtualMachines/SCCMDemo2" + }, + evaluationFrequency: new TimeSpan(hours: 0, minutes: 5, seconds: 0), + windowSize: new TimeSpan(hours: 0, minutes: 5, seconds: 0), + criteria: metricCriteria, + actions: new List() + { + new MetricAlertAction() + { + ActionGroupId = "/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourcegroups/custommetricdemo/providers/microsoft.insights/actiongroups/scactiongroup" + } + } + ); + } + private MetricAlertResource GetSampleMultiResourceMetricRuleResourceParams() { MetricAlertMultipleResourceMultipleMetricCriteria metricCriteria = GetSampleMultiResourceMetricCriteria(); @@ -285,6 +436,35 @@ private MetricAlertResource GetSampleMultiResourceMetricRuleResourceParams() ); } + private MetricAlertResource GetSampleMultiResourceDynamicMetricRuleResourceParams() + { + MetricAlertMultipleResourceMultipleMetricCriteria metricCriteria = GetSampleDynamicMetricCriteria(); + + return new MetricAlertResource( + description: "alert description", + severity: 3, + location: "global", + enabled: true, + targetResourceRegion: "southcentralus", + targetResourceType: "Microsoft.Compute/virtualMachines", + scopes: new List() + { + "/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourceGroups/SanjaychResourceGroup/providers/Microsoft.Compute/virtualMachines/SCCMDemo2", + "/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourceGroups/SanjaychResourceGroup/providers/Microsoft.Compute/virtualMachines/SCCMDemo3" + }, + evaluationFrequency: new TimeSpan(hours: 0, minutes: 5, seconds: 0), + windowSize: new TimeSpan(hours: 0, minutes: 5, seconds: 0), + criteria: metricCriteria, + actions: new List() + { + new MetricAlertAction() + { + ActionGroupId = "/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourcegroups/default-activitylogalerts/providers/microsoft.insights/actiongroups/anashah" + } + } + ); + } + private static MetricAlertSingleResourceMultipleMetricCriteria GetSampleMetricCriteria() { MetricDimension metricDimension = new MetricDimension() @@ -315,6 +495,43 @@ private static MetricAlertSingleResourceMultipleMetricCriteria GetSampleMetricCr ); } + private static MetricAlertMultipleResourceMultipleMetricCriteria GetSampleDynamicMetricCriteria() + { + MetricDimension metricDimension = new MetricDimension() + { + Name = "name1", + OperatorProperty = "Include", + Values = new List() + { + "Primary" + } + }; + + MetricDimension[] metricDimensions = new MetricDimension[1] { metricDimension }; + + return new MetricAlertMultipleResourceMultipleMetricCriteria( + allOf: new List() + { + new DynamicMetricCriteria() + { + MetricName = "Metric Name", + Name = "metric1", + Dimensions = metricDimensions, + MetricNamespace = "Namespace", + AlertSensitivity= "High", + IgnoreDataBefore = null, + FailingPeriods = new DynamicThresholdFailingPeriods() + { + MinFailingPeriodsToAlert = 4, + NumberOfEvaluationPeriods = 4 + }, + OperatorProperty = "GreaterThan", + TimeAggregation = "Avergage" + } + } + ) ; + } + private static MetricAlertMultipleResourceMultipleMetricCriteria GetSampleMultiResourceMetricCriteria() { MetricDimension metricDimension = new MetricDimension() diff --git a/sdk/monitor/Microsoft.Azure.Management.Monitor/tests/Scenarios/MetricAlertsTests.cs b/sdk/monitor/Microsoft.Azure.Management.Monitor/tests/Scenarios/MetricAlertsTests.cs index 1f06b83739a71..f77e56721d48f 100644 --- a/sdk/monitor/Microsoft.Azure.Management.Monitor/tests/Scenarios/MetricAlertsTests.cs +++ b/sdk/monitor/Microsoft.Azure.Management.Monitor/tests/Scenarios/MetricAlertsTests.cs @@ -22,6 +22,10 @@ public class MetricAlertsTests : TestBase private const string MultiResResourceLevelRuleName = "MultiResResourceMetricAlert"; private const string MultiResResourceGroupLevelRuleName = "MultiResRGMetricAlert"; private const string MultiResSubscriptionLevelRuleName = "MultiResSubsMetricAlert"; + private const string DynamicRuleName = "DynamicMetricAlertSDKTestRule1"; + private const string MultiResResourceLevelDynamicRuleName = "MultiResResourceDynamicMetricAlert"; + private const string MultiResResourceGroupLevelDynamicRuleName = "MultiResRGMDynamicetricAlert"; + private const string MultiResSubscriptionLevelDynamicRuleName = "MultiResSubsDynamicMetricAlert"; private const string ResourceId = "/subscriptions/{0}/resourceGroups/" + ResourceGroupName + "/providers/microsoft.insights/metricAlerts/" + RuleName; private const string Location = "southcentralus"; @@ -47,6 +51,21 @@ public void MetricAlertRuleFlow() } } + [Fact] + [Trait("Category", "Scenario")] + public void DynamicMetricAlertRuleFlow() + { + using (MockContext context = MockContext.Start(this.GetType().FullName)) + { + MonitorManagementClient insightsClient = GetMonitorManagementClient(context, handler); + this.VerifyExistenceOrCreateResourceGroup(resourceGroupName: ResourceGroupName, location: Location); + + CreateOrUpdateDynamicMetricAlertRule(insightsClient); + GetDynamicMetricAlertRule(insightsClient); + DeleteDynamicMetricAlertRule(insightsClient); + } + } + [Fact] [Trait("Category", "Scenario")] public void MultiResResourceLevelMetricAlertRuleFlow() @@ -62,6 +81,21 @@ public void MultiResResourceLevelMetricAlertRuleFlow() } } + [Fact] + [Trait("Category", "Scenario")] + public void MultiResResourceLevelDynamicMetricAlertRuleFlow() + { + using (MockContext context = MockContext.Start(this.GetType().FullName)) + { + MonitorManagementClient insightsClient = GetMonitorManagementClient(context, handler); + this.VerifyExistenceOrCreateResourceGroup(resourceGroupName: ResourceGroupName, location: Location); + + CreateOrUpdateMultiResResourceLevelDynamicMetricAlertRule(insightsClient); + GetMultiResResourceLevelDynamicMetricAlertRule(insightsClient); + DeleteMultiResResourceLevelDynamicMetricAlertRule(insightsClient); + } + } + [Fact] [Trait("Category", "Scenario")] private void MultiResResourceGroupLevelMetricAlertRule() @@ -77,6 +111,21 @@ private void MultiResResourceGroupLevelMetricAlertRule() } } + [Fact] + [Trait("Category", "Scenario")] + private void MultiResResourceGroupLevelDynamicMetricAlertRule() + { + using (MockContext context = MockContext.Start(this.GetType().FullName)) + { + MonitorManagementClient insightsClient = GetMonitorManagementClient(context, handler); + this.VerifyExistenceOrCreateResourceGroup(resourceGroupName: ResourceGroupName, location: Location); + + CreateOrUpdateMultiResResourceGroupLevelDynamicMetricAlertRule(insightsClient); + GetMultiResResourceGroupLevelDynamicMetricAlertRule(insightsClient); + DeleteMultiResResourceGroupLevelDynamicMetricAlertRule(insightsClient); + } + } + [Fact] [Trait("Category", "Scenario")] private void MultiResSubscriptionLevelMetricAlertRule() @@ -92,6 +141,21 @@ private void MultiResSubscriptionLevelMetricAlertRule() } } + [Fact] + [Trait("Category", "Scenario")] + private void MultiResSubscriptionLevelDynamicMetricAlertRule() + { + using (MockContext context = MockContext.Start(this.GetType().FullName)) + { + MonitorManagementClient insightsClient = GetMonitorManagementClient(context, handler); + this.VerifyExistenceOrCreateResourceGroup(resourceGroupName: ResourceGroupName, location: Location); + + CreateOrUpdateMultiResSubscriptionLevelDynamicMetricAlertRule(insightsClient); + GetMultiResSubscriptionLevelDynamicMetricAlertRule(insightsClient); + DeleteMultiResSubscriptionLevelDynamicMetricAlertRule(insightsClient); + } + } + private void CreateOrUpdateMetricAlertRule(MonitorManagementClient insightsClient) { MetricAlertResource expectedParameters = GetCreateOrUpdateRuleParameters(); @@ -103,6 +167,17 @@ private void CreateOrUpdateMetricAlertRule(MonitorManagementClient insightsClien Utilities.AreEqual(expectedParameters, result); } + private void CreateOrUpdateDynamicMetricAlertRule(MonitorManagementClient insightsClient) + { + MetricAlertResource expectedParameters = GetCreateOrUpdateDynamicRuleParameters(); + MetricAlertResource result = insightsClient.MetricAlerts.CreateOrUpdate( + resourceGroupName: ResourceGroupName, + ruleName: DynamicRuleName, + parameters: expectedParameters); + + Utilities.AreEqual(expectedParameters, result); + } + private void CreateOrUpdateMultiResResourceLevelMetricAlertRule(MonitorManagementClient insightsClient) { MetricAlertResource expectedParameters = GetCreateOrUpdateMultiResResourceLevelRuleParameters(); @@ -114,6 +189,17 @@ private void CreateOrUpdateMultiResResourceLevelMetricAlertRule(MonitorManagemen Utilities.AreEqual(expectedParameters, result); } + private void CreateOrUpdateMultiResResourceLevelDynamicMetricAlertRule(MonitorManagementClient insightsClient) + { + MetricAlertResource expectedParameters = GetCreateOrUpdateMultiResResourceLevelDynamicRuleParameters(); + MetricAlertResource result = insightsClient.MetricAlerts.CreateOrUpdate( + resourceGroupName: ResourceGroupName, + ruleName: MultiResResourceLevelDynamicRuleName, + parameters: expectedParameters + ); + Utilities.AreEqual(expectedParameters, result); + } + private void CreateOrUpdateMultiResResourceGroupLevelMetricAlertRule(MonitorManagementClient insightsClient) { MetricAlertResource expectedParameters = GetCreateOrUpdateMultiResResourceGroupLevelRuleParameters(); @@ -125,6 +211,17 @@ private void CreateOrUpdateMultiResResourceGroupLevelMetricAlertRule(MonitorMana Utilities.AreEqual(expectedParameters, result); } + private void CreateOrUpdateMultiResResourceGroupLevelDynamicMetricAlertRule(MonitorManagementClient insightsClient) + { + MetricAlertResource expectedParameters = GetCreateOrUpdateMultiResResourceGroupLevelDynamicRuleParameters(); + MetricAlertResource result = insightsClient.MetricAlerts.CreateOrUpdate( + resourceGroupName: ResourceGroupName, + ruleName: MultiResResourceGroupLevelDynamicRuleName, + parameters: expectedParameters + ); + Utilities.AreEqual(expectedParameters, result); + } + private void CreateOrUpdateMultiResSubscriptionLevelMetricAlertRule(MonitorManagementClient insightsClient) { MetricAlertResource expectedParameters = GetCreateOrUpdateMultiResSubscriptionLevelRuleParameters(); @@ -136,6 +233,17 @@ private void CreateOrUpdateMultiResSubscriptionLevelMetricAlertRule(MonitorManag Utilities.AreEqual(expectedParameters, result); } + private void CreateOrUpdateMultiResSubscriptionLevelDynamicMetricAlertRule(MonitorManagementClient insightsClient) + { + MetricAlertResource expectedParameters = GetCreateOrUpdateMultiResSubscriptionLevelDynamicRuleParameters(); + MetricAlertResource result = insightsClient.MetricAlerts.CreateOrUpdate( + resourceGroupName: ResourceGroupName, + ruleName: MultiResSubscriptionLevelDynamicRuleName, + parameters: expectedParameters + ); + Utilities.AreEqual(expectedParameters, result); + } + private void GetMetricAlertRule(MonitorManagementClient insightsClient) { MetricAlertResource expectedParameters = GetCreateOrUpdateRuleParameters(); @@ -143,6 +251,13 @@ private void GetMetricAlertRule(MonitorManagementClient insightsClient) Utilities.AreEqual(expectedParameters, alertRule); } + private void GetDynamicMetricAlertRule(MonitorManagementClient insightsClient) + { + MetricAlertResource expectedParameters = GetCreateOrUpdateDynamicRuleParameters(); + MetricAlertResource alertRule = insightsClient.MetricAlerts.Get(resourceGroupName: ResourceGroupName, ruleName: DynamicRuleName); + Utilities.AreEqual(expectedParameters, alertRule); + } + private void GetMultiResResourceLevelMetricAlertRule(MonitorManagementClient insightsClient) { MetricAlertResource expectedParameters = GetCreateOrUpdateMultiResResourceLevelRuleParameters(); @@ -150,6 +265,13 @@ private void GetMultiResResourceLevelMetricAlertRule(MonitorManagementClient ins Utilities.AreEqual(expectedParameters, alertRule); } + private void GetMultiResResourceLevelDynamicMetricAlertRule(MonitorManagementClient insightsClient) + { + MetricAlertResource expectedParameters = GetCreateOrUpdateMultiResResourceLevelDynamicRuleParameters(); + MetricAlertResource alertRule = insightsClient.MetricAlerts.Get(resourceGroupName: ResourceGroupName, ruleName: MultiResResourceLevelDynamicRuleName); + Utilities.AreEqual(expectedParameters, alertRule); + } + private void GetMultiResResourceGroupLevelMetricAlertRule(MonitorManagementClient insightsClient) { MetricAlertResource expectedParameters = GetCreateOrUpdateMultiResResourceGroupLevelRuleParameters(); @@ -157,6 +279,13 @@ private void GetMultiResResourceGroupLevelMetricAlertRule(MonitorManagementClien Utilities.AreEqual(expectedParameters, alertRule); } + private void GetMultiResResourceGroupLevelDynamicMetricAlertRule(MonitorManagementClient insightsClient) + { + MetricAlertResource expectedParameters = GetCreateOrUpdateMultiResResourceGroupLevelDynamicRuleParameters(); + MetricAlertResource alertRule = insightsClient.MetricAlerts.Get(resourceGroupName: ResourceGroupName, ruleName: MultiResResourceGroupLevelDynamicRuleName); + Utilities.AreEqual(expectedParameters, alertRule); + } + private void GetMultiResSubscriptionLevelMetricAlertRule(MonitorManagementClient insightsClient) { MetricAlertResource expectedParameters = GetCreateOrUpdateMultiResSubscriptionLevelRuleParameters(); @@ -164,26 +293,53 @@ private void GetMultiResSubscriptionLevelMetricAlertRule(MonitorManagementClient Utilities.AreEqual(expectedParameters, alertRule); } + private void GetMultiResSubscriptionLevelDynamicMetricAlertRule(MonitorManagementClient insightsClient) + { + MetricAlertResource expectedParameters = GetCreateOrUpdateMultiResSubscriptionLevelDynamicRuleParameters(); + MetricAlertResource alertRule = insightsClient.MetricAlerts.Get(resourceGroupName: ResourceGroupName, ruleName: MultiResSubscriptionLevelDynamicRuleName); + Utilities.AreEqual(expectedParameters, alertRule); + } + private void DeleteMetricAlertRule(MonitorManagementClient insightsClient) { insightsClient.MetricAlerts.Delete(resourceGroupName: ResourceGroupName, ruleName: RuleName); } + private void DeleteDynamicMetricAlertRule(MonitorManagementClient insightsClient) + { + insightsClient.MetricAlerts.Delete(resourceGroupName: ResourceGroupName, ruleName: DynamicRuleName); + } + private void DeleteMultiResResourceLevelMetricAlertRule(MonitorManagementClient insightsClient) { insightsClient.MetricAlerts.Delete(resourceGroupName: ResourceGroupName, ruleName: MultiResResourceLevelRuleName); } + private void DeleteMultiResResourceLevelDynamicMetricAlertRule(MonitorManagementClient insightsClient) + { + insightsClient.MetricAlerts.Delete(resourceGroupName: ResourceGroupName, ruleName: MultiResResourceLevelDynamicRuleName); + } + private void DeleteMultiResResourceGroupLevelMetricAlertRule(MonitorManagementClient insightsClient) { insightsClient.MetricAlerts.Delete(resourceGroupName: ResourceGroupName, ruleName: MultiResResourceGroupLevelRuleName); } + private void DeleteMultiResResourceGroupLevelDynamicMetricAlertRule(MonitorManagementClient insightsClient) + { + insightsClient.MetricAlerts.Delete(resourceGroupName: ResourceGroupName, ruleName: MultiResResourceGroupLevelDynamicRuleName); + } + private void DeleteMultiResSubscriptionLevelMetricAlertRule(MonitorManagementClient insightsClient) { insightsClient.MetricAlerts.Delete(resourceGroupName: ResourceGroupName, ruleName: MultiResSubscriptionLevelRuleName); } + private void DeleteMultiResSubscriptionLevelDynamicMetricAlertRule(MonitorManagementClient insightsClient) + { + insightsClient.MetricAlerts.Delete(resourceGroupName: ResourceGroupName, ruleName: MultiResSubscriptionLevelDynamicRuleName); + } + private MetricAlertResource GetCreateOrUpdateRuleParameters() { MetricAlertSingleResourceMultipleMetricCriteria metricCriteria = new MetricAlertSingleResourceMultipleMetricCriteria( @@ -225,6 +381,52 @@ private MetricAlertResource GetCreateOrUpdateRuleParameters() ); } + private MetricAlertResource GetCreateOrUpdateDynamicRuleParameters() + { + MetricAlertMultipleResourceMultipleMetricCriteria metricCriteria = new MetricAlertMultipleResourceMultipleMetricCriteria( + allOf: new List() + { + new DynamicMetricCriteria + { + MetricName = "Transactions", + MetricNamespace = "Microsoft.Storage/storageAccounts", + Name = "metric1", + Dimensions = new MetricDimension[0], + OperatorProperty = "GreaterThan", + TimeAggregation = "Total", + AlertSensitivity = "High", + IgnoreDataBefore = null, + FailingPeriods = new DynamicThresholdFailingPeriods() + { + MinFailingPeriodsToAlert = 4, + NumberOfEvaluationPeriods = 4 + }, + } + } + ); + + return new MetricAlertResource( + description: " This is for Dynamic Metric Alert SDK Scenario Test", + severity: 3, + location: "global", + enabled: true, + scopes: new List() + { + "/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourceGroups/SanjaychResourceGroup/providers/Microsoft.Storage/storageAccounts/metricalertsdktestacc" + }, + evaluationFrequency: new TimeSpan(hours: 0, minutes: 15, seconds: 0), + windowSize: new TimeSpan(hours: 0, minutes: 15, seconds: 0), + criteria: metricCriteria, + actions: new List() + { + new MetricAlertAction() + { + ActionGroupId = "/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourcegroups/sanjaychresourcegroup/providers/microsoft.insights/actiongroups/scnewactiongroup" + } + } + ); + } + private MetricAlertResource GetCreateOrUpdateMultiResResourceLevelRuleParameters() { MetricAlertMultipleResourceMultipleMetricCriteria metricCriteria = new MetricAlertMultipleResourceMultipleMetricCriteria( @@ -268,6 +470,40 @@ private MetricAlertResource GetCreateOrUpdateMultiResResourceLevelRuleParameters ); } + private MetricAlertResource GetCreateOrUpdateMultiResResourceLevelDynamicRuleParameters() + { + MetricAlertMultipleResourceMultipleMetricCriteria metricCriteria = new MetricAlertMultipleResourceMultipleMetricCriteria( + allOf: new List() + { + this.GetDynamicMetricCriteria() + } + ); + + return new MetricAlertResource( + description: " This is for Multi Resource Dynamic Metric Alert SDK Scenario Test", + severity: 3, + location: "global", + enabled: true, + scopes: new List() + { + "/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourceGroups/SanjaychResourceGroup/providers/Microsoft.Compute/virtualMachines/SCCMDemo2", + "/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourceGroups/SanjaychResourceGroup/providers/Microsoft.Compute/virtualMachines/SCCMDemo3" + }, + targetResourceRegion: "southcentralus", + targetResourceType: "Microsoft.Compute/virtualMachines", + evaluationFrequency: new TimeSpan(hours: 0, minutes: 15, seconds: 0), + windowSize: new TimeSpan(hours: 0, minutes: 15, seconds: 0), + criteria: metricCriteria, + actions: new List() + { + new MetricAlertAction() + { + ActionGroupId = "/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourcegroups/default-activitylogalerts/providers/microsoft.insights/actiongroups/anashah" + } + } + ); + } + private MetricAlertResource GetCreateOrUpdateMultiResResourceGroupLevelRuleParameters() { MetricAlertMultipleResourceMultipleMetricCriteria metricCriteria = new MetricAlertMultipleResourceMultipleMetricCriteria( @@ -312,6 +548,41 @@ private MetricAlertResource GetCreateOrUpdateMultiResResourceGroupLevelRuleParam ); } + private MetricAlertResource GetCreateOrUpdateMultiResResourceGroupLevelDynamicRuleParameters() + { + MetricAlertMultipleResourceMultipleMetricCriteria metricCriteria = new MetricAlertMultipleResourceMultipleMetricCriteria( + allOf: new List() + { + this.GetDynamicMetricCriteria() + } + ); + + return new MetricAlertResource( + description: " This is for Multi Resource Metric Alert SDK Scenario Test (ResourceGroup Level)", + severity: 3, + location: "global", + enabled: true, + scopes: new List() + { + "/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourceGroups/SanjaychResourceGroup", + "/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourceGroups/RG2" + + }, + targetResourceRegion: "southcentralus", + targetResourceType: "Microsoft.Compute/virtualMachines", + evaluationFrequency: new TimeSpan(hours: 0, minutes: 15, seconds: 0), + windowSize: new TimeSpan(hours: 0, minutes: 15, seconds: 0), + criteria: metricCriteria, + actions: new List() + { + new MetricAlertAction() + { + ActionGroupId = "/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourcegroups/default-activitylogalerts/providers/microsoft.insights/actiongroups/anashah" + } + } + ); + } + private MetricAlertResource GetCreateOrUpdateMultiResSubscriptionLevelRuleParameters() { MetricAlertMultipleResourceMultipleMetricCriteria metricCriteria = new MetricAlertMultipleResourceMultipleMetricCriteria( @@ -354,5 +625,59 @@ private MetricAlertResource GetCreateOrUpdateMultiResSubscriptionLevelRuleParame } ); } + + private MetricAlertResource GetCreateOrUpdateMultiResSubscriptionLevelDynamicRuleParameters() + { + MetricAlertMultipleResourceMultipleMetricCriteria metricCriteria = new MetricAlertMultipleResourceMultipleMetricCriteria( + allOf: new List() + { + this.GetDynamicMetricCriteria() + } + ); + + return new MetricAlertResource( + description: " This is for Multi Resource Metric Alert SDK Scenario Test (ResourceGroup Level)", + severity: 3, + location: "global", + enabled: true, + scopes: new List() + { + "/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6" + + }, + targetResourceRegion: "southcentralus", + targetResourceType: "Microsoft.Compute/virtualMachines", + evaluationFrequency: new TimeSpan(hours: 0, minutes: 15, seconds: 0), + windowSize: new TimeSpan(hours: 0, minutes: 15, seconds: 0), + criteria: metricCriteria, + actions: new List() + { + new MetricAlertAction() + { + ActionGroupId = "/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourcegroups/default-activitylogalerts/providers/microsoft.insights/actiongroups/anashah" + } + } + ); + } + + private DynamicMetricCriteria GetDynamicMetricCriteria() + { + return new DynamicMetricCriteria() + { + MetricName = "Percentage CPU", + MetricNamespace = "microsoft.compute/virtualmachines", + Name = "metric1", + Dimensions = new MetricDimension[0], + OperatorProperty = "GreaterThan", + AlertSensitivity = "High", + IgnoreDataBefore = null, + FailingPeriods = new DynamicThresholdFailingPeriods() + { + MinFailingPeriodsToAlert = 4, + NumberOfEvaluationPeriods = 4 + }, + TimeAggregation = "Average", + }; + } } } diff --git a/sdk/monitor/Microsoft.Azure.Management.Monitor/tests/SessionRecords/Monitor.Tests.Scenarios.MetricAlertsTests/DynamicMetricAlertRuleFlow.json b/sdk/monitor/Microsoft.Azure.Management.Monitor/tests/SessionRecords/Monitor.Tests.Scenarios.MetricAlertsTests/DynamicMetricAlertRuleFlow.json new file mode 100644 index 0000000000000..a27d6be7a3456 --- /dev/null +++ b/sdk/monitor/Microsoft.Azure.Management.Monitor/tests/SessionRecords/Monitor.Tests.Scenarios.MetricAlertsTests/DynamicMetricAlertRuleFlow.json @@ -0,0 +1,275 @@ +{ + "Entries": [ + { + "RequestUri": "/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourcegroups/SanjaychResourceGroup?api-version=2017-05-10", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvODA0MzAwMTgtMjRlZS00YjI4LWE3YmQtZmIyM2I1YTIyMWQ2L3Jlc291cmNlZ3JvdXBzL1NhbmpheWNoUmVzb3VyY2VHcm91cD9hcGktdmVyc2lvbj0yMDE3LTA1LTEw", + "RequestMethod": "HEAD", + "RequestBody": "", + "RequestHeaders": { + "x-ms-client-request-id": [ + "881548cc-b138-4e8b-9a58-70d7e25968ae" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.26614.01", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.18362.", + "Microsoft.Azure.Management.ResourceManager.ResourceManagementClient/1.6.0.0" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Tue, 16 Jul 2019 20:28:17 GMT" + ], + "Pragma": [ + "no-cache" + ], + "x-ms-ratelimit-remaining-subscription-reads": [ + "11999" + ], + "x-ms-request-id": [ + "008ceac0-3c26-4d1e-a8c8-5665cd75969c" + ], + "x-ms-correlation-request-id": [ + "008ceac0-3c26-4d1e-a8c8-5665cd75969c" + ], + "x-ms-routing-request-id": [ + "UKSOUTH2:20190716T202818Z:008ceac0-3c26-4d1e-a8c8-5665cd75969c" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Content-Length": [ + "0" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "", + "StatusCode": 204 + }, + { + "RequestUri": "/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourceGroups/SanjaychResourceGroup/providers/Microsoft.Insights/metricAlerts/DynamicMetricAlertSDKTestRule1?api-version=2018-03-01", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvODA0MzAwMTgtMjRlZS00YjI4LWE3YmQtZmIyM2I1YTIyMWQ2L3Jlc291cmNlR3JvdXBzL1NhbmpheWNoUmVzb3VyY2VHcm91cC9wcm92aWRlcnMvTWljcm9zb2Z0Lkluc2lnaHRzL21ldHJpY0FsZXJ0cy9EeW5hbWljTWV0cmljQWxlcnRTREtUZXN0UnVsZTE/YXBpLXZlcnNpb249MjAxOC0wMy0wMQ==", + "RequestMethod": "PUT", + "RequestBody": "{\r\n \"properties\": {\r\n \"description\": \" This is for Dynamic Metric Alert SDK Scenario Test\",\r\n \"severity\": 3,\r\n \"enabled\": true,\r\n \"scopes\": [\r\n \"/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourceGroups/SanjaychResourceGroup/providers/Microsoft.Storage/storageAccounts/metricalertsdktestacc\"\r\n ],\r\n \"evaluationFrequency\": \"PT15M\",\r\n \"windowSize\": \"PT15M\",\r\n \"criteria\": {\r\n \"odata.type\": \"Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria\",\r\n \"allOf\": [\r\n {\r\n \"criterionType\": \"DynamicThresholdCriterion\",\r\n \"operator\": \"GreaterThan\",\r\n \"alertSensitivity\": \"High\",\r\n \"failingPeriods\": {\r\n \"numberOfEvaluationPeriods\": 4.0,\r\n \"minFailingPeriodsToAlert\": 4.0\r\n },\r\n \"name\": \"metric1\",\r\n \"metricName\": \"Transactions\",\r\n \"metricNamespace\": \"Microsoft.Storage/storageAccounts\",\r\n \"timeAggregation\": \"Total\",\r\n \"dimensions\": []\r\n }\r\n ]\r\n },\r\n \"actions\": [\r\n {\r\n \"actionGroupId\": \"/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourcegroups/sanjaychresourcegroup/providers/microsoft.insights/actiongroups/scnewactiongroup\"\r\n }\r\n ]\r\n },\r\n \"location\": \"global\"\r\n}", + "RequestHeaders": { + "x-ms-client-request-id": [ + "6707da3b-8af9-49b8-b592-d25d629cf9d3" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.26614.01", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.18362.", + "Microsoft.Azure.Management.Monitor.MonitorManagementClient/0.22.0.0" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Content-Length": [ + "1282" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Tue, 16 Jul 2019 20:28:24 GMT" + ], + "Pragma": [ + "no-cache" + ], + "Server": [ + "Microsoft-IIS/10.0" + ], + "x-ms-request-id": [ + "37e7d6f4-b6b4-4489-a112-aa670b8bf7c2" + ], + "X-AspNet-Version": [ + "4.0.30319" + ], + "X-Powered-By": [ + "ASP.NET" + ], + "x-ms-ratelimit-remaining-subscription-writes": [ + "1199" + ], + "x-ms-correlation-request-id": [ + "37e7d6f4-b6b4-4489-a112-aa670b8bf7c2" + ], + "x-ms-routing-request-id": [ + "UKSOUTH2:20190716T202824Z:37e7d6f4-b6b4-4489-a112-aa670b8bf7c2" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Content-Length": [ + "1779" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "{\r\n \"location\": \"global\",\r\n \"type\": \"Microsoft.Insights/metricAlerts\",\r\n \"name\": \"DynamicMetricAlertSDKTestRule1\",\r\n \"id\": \"/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourceGroups/SanjaychResourceGroup/providers/Microsoft.Insights/metricAlerts/DynamicMetricAlertSDKTestRule1\",\r\n \"properties\": {\r\n \"description\": \" This is for Dynamic Metric Alert SDK Scenario Test\",\r\n \"severity\": 3,\r\n \"enabled\": true,\r\n \"scopes\": [\r\n \"/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourceGroups/SanjaychResourceGroup/providers/Microsoft.Storage/storageAccounts/metricalertsdktestacc\"\r\n ],\r\n \"evaluationFrequency\": \"PT15M\",\r\n \"windowSize\": \"PT15M\",\r\n \"templateType\": 13,\r\n \"templateSpecificParameters\": {\r\n \"direction\": \"Up\",\r\n \"sensitivity\": \"High\"\r\n },\r\n \"criteria\": {\r\n \"allOf\": [\r\n {\r\n \"alertSensitivity\": \"High\",\r\n \"failingPeriods\": {\r\n \"numberOfEvaluationPeriods\": 4,\r\n \"minFailingPeriodsToAlert\": 4\r\n },\r\n \"name\": \"metric1\",\r\n \"metricNamespace\": \"Microsoft.Storage/storageAccounts\",\r\n \"metricName\": \"Transactions\",\r\n \"dimensions\": [],\r\n \"operator\": \"GreaterThan\",\r\n \"timeAggregation\": \"Total\",\r\n \"criterionType\": \"DynamicThresholdCriterion\"\r\n }\r\n ],\r\n \"odata.type\": \"Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria\"\r\n },\r\n \"targetResourceType\": \"microsoft.storage/storageaccounts\",\r\n \"targetResourceRegion\": \"southcentralus\",\r\n \"actions\": [\r\n {\r\n \"actionGroupId\": \"/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourcegroups/sanjaychresourcegroup/providers/microsoft.insights/actiongroups/scnewactiongroup\"\r\n }\r\n ]\r\n }\r\n}", + "StatusCode": 200 + }, + { + "RequestUri": "/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourceGroups/SanjaychResourceGroup/providers/Microsoft.Insights/metricAlerts/DynamicMetricAlertSDKTestRule1?api-version=2018-03-01", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvODA0MzAwMTgtMjRlZS00YjI4LWE3YmQtZmIyM2I1YTIyMWQ2L3Jlc291cmNlR3JvdXBzL1NhbmpheWNoUmVzb3VyY2VHcm91cC9wcm92aWRlcnMvTWljcm9zb2Z0Lkluc2lnaHRzL21ldHJpY0FsZXJ0cy9EeW5hbWljTWV0cmljQWxlcnRTREtUZXN0UnVsZTE/YXBpLXZlcnNpb249MjAxOC0wMy0wMQ==", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "x-ms-client-request-id": [ + "05bfc34c-34d8-4a02-b19a-02d3351321be" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.26614.01", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.18362.", + "Microsoft.Azure.Management.Monitor.MonitorManagementClient/0.22.0.0" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Tue, 16 Jul 2019 20:28:24 GMT" + ], + "Pragma": [ + "no-cache" + ], + "Server": [ + "Microsoft-IIS/10.0" + ], + "x-ms-request-id": [ + "556c1fbb-2080-4f37-8f46-9996dc3270aa" + ], + "X-AspNet-Version": [ + "4.0.30319" + ], + "X-Powered-By": [ + "ASP.NET" + ], + "x-ms-ratelimit-remaining-subscription-reads": [ + "11998" + ], + "x-ms-correlation-request-id": [ + "556c1fbb-2080-4f37-8f46-9996dc3270aa" + ], + "x-ms-routing-request-id": [ + "UKSOUTH2:20190716T202824Z:556c1fbb-2080-4f37-8f46-9996dc3270aa" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Content-Length": [ + "1779" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "{\r\n \"location\": \"global\",\r\n \"type\": \"Microsoft.Insights/metricAlerts\",\r\n \"name\": \"DynamicMetricAlertSDKTestRule1\",\r\n \"id\": \"/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourceGroups/SanjaychResourceGroup/providers/Microsoft.Insights/metricAlerts/DynamicMetricAlertSDKTestRule1\",\r\n \"properties\": {\r\n \"description\": \" This is for Dynamic Metric Alert SDK Scenario Test\",\r\n \"severity\": 3,\r\n \"enabled\": true,\r\n \"scopes\": [\r\n \"/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourceGroups/SanjaychResourceGroup/providers/Microsoft.Storage/storageAccounts/metricalertsdktestacc\"\r\n ],\r\n \"evaluationFrequency\": \"PT15M\",\r\n \"windowSize\": \"PT15M\",\r\n \"templateType\": 13,\r\n \"templateSpecificParameters\": {\r\n \"direction\": \"Up\",\r\n \"sensitivity\": \"High\"\r\n },\r\n \"criteria\": {\r\n \"allOf\": [\r\n {\r\n \"alertSensitivity\": \"High\",\r\n \"failingPeriods\": {\r\n \"numberOfEvaluationPeriods\": 4,\r\n \"minFailingPeriodsToAlert\": 4\r\n },\r\n \"name\": \"metric1\",\r\n \"metricNamespace\": \"Microsoft.Storage/storageAccounts\",\r\n \"metricName\": \"Transactions\",\r\n \"dimensions\": [],\r\n \"operator\": \"GreaterThan\",\r\n \"timeAggregation\": \"Total\",\r\n \"criterionType\": \"DynamicThresholdCriterion\"\r\n }\r\n ],\r\n \"odata.type\": \"Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria\"\r\n },\r\n \"targetResourceType\": \"microsoft.storage/storageaccounts\",\r\n \"targetResourceRegion\": \"southcentralus\",\r\n \"actions\": [\r\n {\r\n \"actionGroupId\": \"/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourcegroups/sanjaychresourcegroup/providers/microsoft.insights/actiongroups/scnewactiongroup\"\r\n }\r\n ]\r\n }\r\n}", + "StatusCode": 200 + }, + { + "RequestUri": "/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourceGroups/SanjaychResourceGroup/providers/Microsoft.Insights/metricAlerts/DynamicMetricAlertSDKTestRule1?api-version=2018-03-01", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvODA0MzAwMTgtMjRlZS00YjI4LWE3YmQtZmIyM2I1YTIyMWQ2L3Jlc291cmNlR3JvdXBzL1NhbmpheWNoUmVzb3VyY2VHcm91cC9wcm92aWRlcnMvTWljcm9zb2Z0Lkluc2lnaHRzL21ldHJpY0FsZXJ0cy9EeW5hbWljTWV0cmljQWxlcnRTREtUZXN0UnVsZTE/YXBpLXZlcnNpb249MjAxOC0wMy0wMQ==", + "RequestMethod": "DELETE", + "RequestBody": "", + "RequestHeaders": { + "x-ms-client-request-id": [ + "346fa1bc-5d99-421d-83a0-ad8cdcb156ef" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.26614.01", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.18362.", + "Microsoft.Azure.Management.Monitor.MonitorManagementClient/0.22.0.0" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Tue, 16 Jul 2019 20:28:28 GMT" + ], + "Pragma": [ + "no-cache" + ], + "Server": [ + "Microsoft-IIS/10.0" + ], + "x-ms-request-id": [ + "1517f52a-b6ca-4839-9bb9-9c43782c8f78" + ], + "X-AspNet-Version": [ + "4.0.30319" + ], + "X-Powered-By": [ + "ASP.NET" + ], + "x-ms-ratelimit-remaining-subscription-deletes": [ + "14999" + ], + "x-ms-correlation-request-id": [ + "1517f52a-b6ca-4839-9bb9-9c43782c8f78" + ], + "x-ms-routing-request-id": [ + "UKSOUTH2:20190716T202828Z:1517f52a-b6ca-4839-9bb9-9c43782c8f78" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Content-Length": [ + "0" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "", + "StatusCode": 200 + } + ], + "Names": {}, + "Variables": { + "SubscriptionId": "80430018-24ee-4b28-a7bd-fb23b5a221d6" + } +} \ No newline at end of file diff --git a/sdk/monitor/Microsoft.Azure.Management.Monitor/tests/SessionRecords/Monitor.Tests.Scenarios.MetricAlertsTests/MultiResResourceGroupLevelDynamicMetricAlertRule.json b/sdk/monitor/Microsoft.Azure.Management.Monitor/tests/SessionRecords/Monitor.Tests.Scenarios.MetricAlertsTests/MultiResResourceGroupLevelDynamicMetricAlertRule.json new file mode 100644 index 0000000000000..141cb97e0ef68 --- /dev/null +++ b/sdk/monitor/Microsoft.Azure.Management.Monitor/tests/SessionRecords/Monitor.Tests.Scenarios.MetricAlertsTests/MultiResResourceGroupLevelDynamicMetricAlertRule.json @@ -0,0 +1,275 @@ +{ + "Entries": [ + { + "RequestUri": "/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourcegroups/SanjaychResourceGroup?api-version=2017-05-10", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvODA0MzAwMTgtMjRlZS00YjI4LWE3YmQtZmIyM2I1YTIyMWQ2L3Jlc291cmNlZ3JvdXBzL1NhbmpheWNoUmVzb3VyY2VHcm91cD9hcGktdmVyc2lvbj0yMDE3LTA1LTEw", + "RequestMethod": "HEAD", + "RequestBody": "", + "RequestHeaders": { + "x-ms-client-request-id": [ + "74450065-f1ed-461e-8cca-635a2de593b8" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.26614.01", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.18362.", + "Microsoft.Azure.Management.ResourceManager.ResourceManagementClient/1.6.0.0" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Tue, 16 Jul 2019 20:28:41 GMT" + ], + "Pragma": [ + "no-cache" + ], + "x-ms-ratelimit-remaining-subscription-reads": [ + "11999" + ], + "x-ms-request-id": [ + "4f1d1ed1-646d-47e1-ae2e-b616392b8574" + ], + "x-ms-correlation-request-id": [ + "4f1d1ed1-646d-47e1-ae2e-b616392b8574" + ], + "x-ms-routing-request-id": [ + "UKSOUTH2:20190716T202841Z:4f1d1ed1-646d-47e1-ae2e-b616392b8574" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Content-Length": [ + "0" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "", + "StatusCode": 204 + }, + { + "RequestUri": "/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourceGroups/SanjaychResourceGroup/providers/Microsoft.Insights/metricAlerts/MultiResRGMDynamicetricAlert?api-version=2018-03-01", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvODA0MzAwMTgtMjRlZS00YjI4LWE3YmQtZmIyM2I1YTIyMWQ2L3Jlc291cmNlR3JvdXBzL1NhbmpheWNoUmVzb3VyY2VHcm91cC9wcm92aWRlcnMvTWljcm9zb2Z0Lkluc2lnaHRzL21ldHJpY0FsZXJ0cy9NdWx0aVJlc1JHTUR5bmFtaWNldHJpY0FsZXJ0P2FwaS12ZXJzaW9uPTIwMTgtMDMtMDE=", + "RequestMethod": "PUT", + "RequestBody": "{\r\n \"properties\": {\r\n \"description\": \" This is for Multi Resource Metric Alert SDK Scenario Test (ResourceGroup Level)\",\r\n \"severity\": 3,\r\n \"enabled\": true,\r\n \"scopes\": [\r\n \"/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourceGroups/SanjaychResourceGroup\",\r\n \"/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourceGroups/RG2\"\r\n ],\r\n \"evaluationFrequency\": \"PT15M\",\r\n \"windowSize\": \"PT15M\",\r\n \"targetResourceType\": \"Microsoft.Compute/virtualMachines\",\r\n \"targetResourceRegion\": \"southcentralus\",\r\n \"criteria\": {\r\n \"odata.type\": \"Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria\",\r\n \"allOf\": [\r\n {\r\n \"criterionType\": \"DynamicThresholdCriterion\",\r\n \"operator\": \"GreaterThan\",\r\n \"alertSensitivity\": \"High\",\r\n \"failingPeriods\": {\r\n \"numberOfEvaluationPeriods\": 4.0,\r\n \"minFailingPeriodsToAlert\": 4.0\r\n },\r\n \"name\": \"metric1\",\r\n \"metricName\": \"Percentage CPU\",\r\n \"metricNamespace\": \"microsoft.compute/virtualmachines\",\r\n \"timeAggregation\": \"Average\",\r\n \"dimensions\": []\r\n }\r\n ]\r\n },\r\n \"actions\": [\r\n {\r\n \"actionGroupId\": \"/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourcegroups/default-activitylogalerts/providers/microsoft.insights/actiongroups/anashah\"\r\n }\r\n ]\r\n },\r\n \"location\": \"global\"\r\n}", + "RequestHeaders": { + "x-ms-client-request-id": [ + "261d473d-67fb-4630-94ea-c15b0e2dfcbd" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.26614.01", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.18362.", + "Microsoft.Azure.Management.Monitor.MonitorManagementClient/0.22.0.0" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Content-Length": [ + "1436" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Tue, 16 Jul 2019 20:28:48 GMT" + ], + "Pragma": [ + "no-cache" + ], + "Server": [ + "Microsoft-IIS/10.0" + ], + "x-ms-request-id": [ + "a5185fe0-0748-4c33-aafe-177d6e6d18b8" + ], + "X-AspNet-Version": [ + "4.0.30319" + ], + "X-Powered-By": [ + "ASP.NET" + ], + "x-ms-ratelimit-remaining-subscription-writes": [ + "1199" + ], + "x-ms-correlation-request-id": [ + "a5185fe0-0748-4c33-aafe-177d6e6d18b8" + ], + "x-ms-routing-request-id": [ + "UKSOUTH2:20190716T202849Z:a5185fe0-0748-4c33-aafe-177d6e6d18b8" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Content-Length": [ + "1818" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "{\r\n \"location\": \"global\",\r\n \"type\": \"Microsoft.Insights/metricAlerts\",\r\n \"name\": \"MultiResRGMDynamicetricAlert\",\r\n \"id\": \"/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourceGroups/SanjaychResourceGroup/providers/Microsoft.Insights/metricAlerts/MultiResRGMDynamicetricAlert\",\r\n \"properties\": {\r\n \"description\": \" This is for Multi Resource Metric Alert SDK Scenario Test (ResourceGroup Level)\",\r\n \"severity\": 3,\r\n \"enabled\": true,\r\n \"scopes\": [\r\n \"/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourceGroups/SanjaychResourceGroup\",\r\n \"/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourceGroups/RG2\"\r\n ],\r\n \"evaluationFrequency\": \"PT15M\",\r\n \"windowSize\": \"PT15M\",\r\n \"templateType\": 13,\r\n \"templateSpecificParameters\": {\r\n \"direction\": \"Up\",\r\n \"sensitivity\": \"High\"\r\n },\r\n \"criteria\": {\r\n \"allOf\": [\r\n {\r\n \"alertSensitivity\": \"High\",\r\n \"failingPeriods\": {\r\n \"numberOfEvaluationPeriods\": 4,\r\n \"minFailingPeriodsToAlert\": 4\r\n },\r\n \"name\": \"metric1\",\r\n \"metricNamespace\": \"microsoft.compute/virtualmachines\",\r\n \"metricName\": \"Percentage CPU\",\r\n \"dimensions\": [],\r\n \"operator\": \"GreaterThan\",\r\n \"timeAggregation\": \"Average\",\r\n \"criterionType\": \"DynamicThresholdCriterion\"\r\n }\r\n ],\r\n \"odata.type\": \"Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria\"\r\n },\r\n \"targetResourceType\": \"Microsoft.Compute/virtualMachines\",\r\n \"targetResourceRegion\": \"southcentralus\",\r\n \"actions\": [\r\n {\r\n \"actionGroupId\": \"/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourcegroups/default-activitylogalerts/providers/microsoft.insights/actiongroups/anashah\"\r\n }\r\n ]\r\n }\r\n}", + "StatusCode": 200 + }, + { + "RequestUri": "/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourceGroups/SanjaychResourceGroup/providers/Microsoft.Insights/metricAlerts/MultiResRGMDynamicetricAlert?api-version=2018-03-01", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvODA0MzAwMTgtMjRlZS00YjI4LWE3YmQtZmIyM2I1YTIyMWQ2L3Jlc291cmNlR3JvdXBzL1NhbmpheWNoUmVzb3VyY2VHcm91cC9wcm92aWRlcnMvTWljcm9zb2Z0Lkluc2lnaHRzL21ldHJpY0FsZXJ0cy9NdWx0aVJlc1JHTUR5bmFtaWNldHJpY0FsZXJ0P2FwaS12ZXJzaW9uPTIwMTgtMDMtMDE=", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "x-ms-client-request-id": [ + "66d73279-c1d4-4994-800f-20ff77d9e5ae" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.26614.01", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.18362.", + "Microsoft.Azure.Management.Monitor.MonitorManagementClient/0.22.0.0" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Tue, 16 Jul 2019 20:28:48 GMT" + ], + "Pragma": [ + "no-cache" + ], + "Server": [ + "Microsoft-IIS/10.0" + ], + "x-ms-request-id": [ + "ad792181-7560-4439-8654-11d27cc08de8" + ], + "X-AspNet-Version": [ + "4.0.30319" + ], + "X-Powered-By": [ + "ASP.NET" + ], + "x-ms-ratelimit-remaining-subscription-reads": [ + "11998" + ], + "x-ms-correlation-request-id": [ + "ad792181-7560-4439-8654-11d27cc08de8" + ], + "x-ms-routing-request-id": [ + "UKSOUTH2:20190716T202849Z:ad792181-7560-4439-8654-11d27cc08de8" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Content-Length": [ + "1818" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "{\r\n \"location\": \"global\",\r\n \"type\": \"Microsoft.Insights/metricAlerts\",\r\n \"name\": \"MultiResRGMDynamicetricAlert\",\r\n \"id\": \"/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourceGroups/SanjaychResourceGroup/providers/Microsoft.Insights/metricAlerts/MultiResRGMDynamicetricAlert\",\r\n \"properties\": {\r\n \"description\": \" This is for Multi Resource Metric Alert SDK Scenario Test (ResourceGroup Level)\",\r\n \"severity\": 3,\r\n \"enabled\": true,\r\n \"scopes\": [\r\n \"/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourceGroups/SanjaychResourceGroup\",\r\n \"/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourceGroups/RG2\"\r\n ],\r\n \"evaluationFrequency\": \"PT15M\",\r\n \"windowSize\": \"PT15M\",\r\n \"templateType\": 13,\r\n \"templateSpecificParameters\": {\r\n \"direction\": \"Up\",\r\n \"sensitivity\": \"High\"\r\n },\r\n \"criteria\": {\r\n \"allOf\": [\r\n {\r\n \"alertSensitivity\": \"High\",\r\n \"failingPeriods\": {\r\n \"numberOfEvaluationPeriods\": 4,\r\n \"minFailingPeriodsToAlert\": 4\r\n },\r\n \"name\": \"metric1\",\r\n \"metricNamespace\": \"microsoft.compute/virtualmachines\",\r\n \"metricName\": \"Percentage CPU\",\r\n \"dimensions\": [],\r\n \"operator\": \"GreaterThan\",\r\n \"timeAggregation\": \"Average\",\r\n \"criterionType\": \"DynamicThresholdCriterion\"\r\n }\r\n ],\r\n \"odata.type\": \"Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria\"\r\n },\r\n \"targetResourceType\": \"Microsoft.Compute/virtualMachines\",\r\n \"targetResourceRegion\": \"southcentralus\",\r\n \"actions\": [\r\n {\r\n \"actionGroupId\": \"/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourcegroups/default-activitylogalerts/providers/microsoft.insights/actiongroups/anashah\"\r\n }\r\n ]\r\n }\r\n}", + "StatusCode": 200 + }, + { + "RequestUri": "/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourceGroups/SanjaychResourceGroup/providers/Microsoft.Insights/metricAlerts/MultiResRGMDynamicetricAlert?api-version=2018-03-01", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvODA0MzAwMTgtMjRlZS00YjI4LWE3YmQtZmIyM2I1YTIyMWQ2L3Jlc291cmNlR3JvdXBzL1NhbmpheWNoUmVzb3VyY2VHcm91cC9wcm92aWRlcnMvTWljcm9zb2Z0Lkluc2lnaHRzL21ldHJpY0FsZXJ0cy9NdWx0aVJlc1JHTUR5bmFtaWNldHJpY0FsZXJ0P2FwaS12ZXJzaW9uPTIwMTgtMDMtMDE=", + "RequestMethod": "DELETE", + "RequestBody": "", + "RequestHeaders": { + "x-ms-client-request-id": [ + "6572bb15-6539-41ad-9918-75ec5776346d" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.26614.01", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.18362.", + "Microsoft.Azure.Management.Monitor.MonitorManagementClient/0.22.0.0" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Tue, 16 Jul 2019 20:28:53 GMT" + ], + "Pragma": [ + "no-cache" + ], + "Server": [ + "Microsoft-IIS/10.0" + ], + "x-ms-request-id": [ + "a0117a10-30c5-4ab2-9f0c-30d220c08ab2" + ], + "X-AspNet-Version": [ + "4.0.30319" + ], + "X-Powered-By": [ + "ASP.NET" + ], + "x-ms-ratelimit-remaining-subscription-deletes": [ + "14999" + ], + "x-ms-correlation-request-id": [ + "a0117a10-30c5-4ab2-9f0c-30d220c08ab2" + ], + "x-ms-routing-request-id": [ + "UKSOUTH2:20190716T202854Z:a0117a10-30c5-4ab2-9f0c-30d220c08ab2" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Content-Length": [ + "0" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "", + "StatusCode": 200 + } + ], + "Names": {}, + "Variables": { + "SubscriptionId": "80430018-24ee-4b28-a7bd-fb23b5a221d6" + } +} \ No newline at end of file diff --git a/sdk/monitor/Microsoft.Azure.Management.Monitor/tests/SessionRecords/Monitor.Tests.Scenarios.MetricAlertsTests/MultiResResourceLevelDynamicMetricAlertRuleFlow.json b/sdk/monitor/Microsoft.Azure.Management.Monitor/tests/SessionRecords/Monitor.Tests.Scenarios.MetricAlertsTests/MultiResResourceLevelDynamicMetricAlertRuleFlow.json new file mode 100644 index 0000000000000..c471c942ab9ec --- /dev/null +++ b/sdk/monitor/Microsoft.Azure.Management.Monitor/tests/SessionRecords/Monitor.Tests.Scenarios.MetricAlertsTests/MultiResResourceLevelDynamicMetricAlertRuleFlow.json @@ -0,0 +1,275 @@ +{ + "Entries": [ + { + "RequestUri": "/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourcegroups/SanjaychResourceGroup?api-version=2017-05-10", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvODA0MzAwMTgtMjRlZS00YjI4LWE3YmQtZmIyM2I1YTIyMWQ2L3Jlc291cmNlZ3JvdXBzL1NhbmpheWNoUmVzb3VyY2VHcm91cD9hcGktdmVyc2lvbj0yMDE3LTA1LTEw", + "RequestMethod": "HEAD", + "RequestBody": "", + "RequestHeaders": { + "x-ms-client-request-id": [ + "6d436823-015e-4359-9cbe-8c35c25af00f" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.26614.01", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.18362.", + "Microsoft.Azure.Management.ResourceManager.ResourceManagementClient/1.6.0.0" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Tue, 16 Jul 2019 20:36:27 GMT" + ], + "Pragma": [ + "no-cache" + ], + "x-ms-ratelimit-remaining-subscription-reads": [ + "11999" + ], + "x-ms-request-id": [ + "e32efd3d-a5fe-4509-85bd-92d1bbbc5a31" + ], + "x-ms-correlation-request-id": [ + "e32efd3d-a5fe-4509-85bd-92d1bbbc5a31" + ], + "x-ms-routing-request-id": [ + "UKSOUTH2:20190716T203627Z:e32efd3d-a5fe-4509-85bd-92d1bbbc5a31" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Content-Length": [ + "0" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "", + "StatusCode": 204 + }, + { + "RequestUri": "/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourceGroups/SanjaychResourceGroup/providers/Microsoft.Insights/metricAlerts/MultiResResourceDynamicMetricAlert?api-version=2018-03-01", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvODA0MzAwMTgtMjRlZS00YjI4LWE3YmQtZmIyM2I1YTIyMWQ2L3Jlc291cmNlR3JvdXBzL1NhbmpheWNoUmVzb3VyY2VHcm91cC9wcm92aWRlcnMvTWljcm9zb2Z0Lkluc2lnaHRzL21ldHJpY0FsZXJ0cy9NdWx0aVJlc1Jlc291cmNlRHluYW1pY01ldHJpY0FsZXJ0P2FwaS12ZXJzaW9uPTIwMTgtMDMtMDE=", + "RequestMethod": "PUT", + "RequestBody": "{\r\n \"properties\": {\r\n \"description\": \" This is for Multi Resource Dynamic Metric Alert SDK Scenario Test\",\r\n \"severity\": 3,\r\n \"enabled\": true,\r\n \"scopes\": [\r\n \"/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourceGroups/SanjaychResourceGroup/providers/Microsoft.Compute/virtualMachines/SCCMDemo2\",\r\n \"/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourceGroups/SanjaychResourceGroup/providers/Microsoft.Compute/virtualMachines/SCCMDemo3\"\r\n ],\r\n \"evaluationFrequency\": \"PT15M\",\r\n \"windowSize\": \"PT15M\",\r\n \"targetResourceType\": \"Microsoft.Compute/virtualMachines\",\r\n \"targetResourceRegion\": \"southcentralus\",\r\n \"criteria\": {\r\n \"odata.type\": \"Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria\",\r\n \"allOf\": [\r\n {\r\n \"criterionType\": \"DynamicThresholdCriterion\",\r\n \"operator\": \"GreaterThan\",\r\n \"alertSensitivity\": \"High\",\r\n \"failingPeriods\": {\r\n \"numberOfEvaluationPeriods\": 4.0,\r\n \"minFailingPeriodsToAlert\": 4.0\r\n },\r\n \"name\": \"metric1\",\r\n \"metricName\": \"Percentage CPU\",\r\n \"metricNamespace\": \"microsoft.compute/virtualmachines\",\r\n \"timeAggregation\": \"Average\",\r\n \"dimensions\": []\r\n }\r\n ]\r\n },\r\n \"actions\": [\r\n {\r\n \"actionGroupId\": \"/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourcegroups/default-activitylogalerts/providers/microsoft.insights/actiongroups/anashah\"\r\n }\r\n ]\r\n },\r\n \"location\": \"global\"\r\n}", + "RequestHeaders": { + "x-ms-client-request-id": [ + "b3d39427-4c12-46ba-97f3-2bd1987fde22" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.26614.01", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.18362.", + "Microsoft.Azure.Management.Monitor.MonitorManagementClient/0.22.0.0" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Content-Length": [ + "1548" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Tue, 16 Jul 2019 20:36:35 GMT" + ], + "Pragma": [ + "no-cache" + ], + "Server": [ + "Microsoft-IIS/10.0" + ], + "x-ms-request-id": [ + "439cd58a-9d2e-40cb-8885-1c4b8ee94a9c" + ], + "X-AspNet-Version": [ + "4.0.30319" + ], + "X-Powered-By": [ + "ASP.NET" + ], + "x-ms-ratelimit-remaining-subscription-writes": [ + "1199" + ], + "x-ms-correlation-request-id": [ + "439cd58a-9d2e-40cb-8885-1c4b8ee94a9c" + ], + "x-ms-routing-request-id": [ + "UKSOUTH2:20190716T203636Z:439cd58a-9d2e-40cb-8885-1c4b8ee94a9c" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Content-Length": [ + "1942" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "{\r\n \"location\": \"global\",\r\n \"type\": \"Microsoft.Insights/metricAlerts\",\r\n \"name\": \"MultiResResourceDynamicMetricAlert\",\r\n \"id\": \"/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourceGroups/SanjaychResourceGroup/providers/Microsoft.Insights/metricAlerts/MultiResResourceDynamicMetricAlert\",\r\n \"properties\": {\r\n \"description\": \" This is for Multi Resource Dynamic Metric Alert SDK Scenario Test\",\r\n \"severity\": 3,\r\n \"enabled\": true,\r\n \"scopes\": [\r\n \"/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourceGroups/SanjaychResourceGroup/providers/Microsoft.Compute/virtualMachines/SCCMDemo2\",\r\n \"/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourceGroups/SanjaychResourceGroup/providers/Microsoft.Compute/virtualMachines/SCCMDemo3\"\r\n ],\r\n \"evaluationFrequency\": \"PT15M\",\r\n \"windowSize\": \"PT15M\",\r\n \"templateType\": 13,\r\n \"templateSpecificParameters\": {\r\n \"direction\": \"Up\",\r\n \"sensitivity\": \"High\"\r\n },\r\n \"criteria\": {\r\n \"allOf\": [\r\n {\r\n \"alertSensitivity\": \"High\",\r\n \"failingPeriods\": {\r\n \"numberOfEvaluationPeriods\": 4,\r\n \"minFailingPeriodsToAlert\": 4\r\n },\r\n \"name\": \"metric1\",\r\n \"metricNamespace\": \"microsoft.compute/virtualmachines\",\r\n \"metricName\": \"Percentage CPU\",\r\n \"dimensions\": [],\r\n \"operator\": \"GreaterThan\",\r\n \"timeAggregation\": \"Average\",\r\n \"criterionType\": \"DynamicThresholdCriterion\"\r\n }\r\n ],\r\n \"odata.type\": \"Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria\"\r\n },\r\n \"targetResourceType\": \"Microsoft.Compute/virtualMachines\",\r\n \"targetResourceRegion\": \"southcentralus\",\r\n \"actions\": [\r\n {\r\n \"actionGroupId\": \"/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourcegroups/default-activitylogalerts/providers/microsoft.insights/actiongroups/anashah\"\r\n }\r\n ]\r\n }\r\n}", + "StatusCode": 200 + }, + { + "RequestUri": "/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourceGroups/SanjaychResourceGroup/providers/Microsoft.Insights/metricAlerts/MultiResResourceDynamicMetricAlert?api-version=2018-03-01", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvODA0MzAwMTgtMjRlZS00YjI4LWE3YmQtZmIyM2I1YTIyMWQ2L3Jlc291cmNlR3JvdXBzL1NhbmpheWNoUmVzb3VyY2VHcm91cC9wcm92aWRlcnMvTWljcm9zb2Z0Lkluc2lnaHRzL21ldHJpY0FsZXJ0cy9NdWx0aVJlc1Jlc291cmNlRHluYW1pY01ldHJpY0FsZXJ0P2FwaS12ZXJzaW9uPTIwMTgtMDMtMDE=", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "x-ms-client-request-id": [ + "3901a19d-6289-4bd7-87e2-bafb9239c52e" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.26614.01", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.18362.", + "Microsoft.Azure.Management.Monitor.MonitorManagementClient/0.22.0.0" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Tue, 16 Jul 2019 20:36:35 GMT" + ], + "Pragma": [ + "no-cache" + ], + "Server": [ + "Microsoft-IIS/10.0" + ], + "x-ms-request-id": [ + "526c017a-a36a-4408-960c-e02b1e08d124" + ], + "X-AspNet-Version": [ + "4.0.30319" + ], + "X-Powered-By": [ + "ASP.NET" + ], + "x-ms-ratelimit-remaining-subscription-reads": [ + "11998" + ], + "x-ms-correlation-request-id": [ + "526c017a-a36a-4408-960c-e02b1e08d124" + ], + "x-ms-routing-request-id": [ + "UKSOUTH2:20190716T203636Z:526c017a-a36a-4408-960c-e02b1e08d124" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Content-Length": [ + "1942" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "{\r\n \"location\": \"global\",\r\n \"type\": \"Microsoft.Insights/metricAlerts\",\r\n \"name\": \"MultiResResourceDynamicMetricAlert\",\r\n \"id\": \"/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourceGroups/SanjaychResourceGroup/providers/Microsoft.Insights/metricAlerts/MultiResResourceDynamicMetricAlert\",\r\n \"properties\": {\r\n \"description\": \" This is for Multi Resource Dynamic Metric Alert SDK Scenario Test\",\r\n \"severity\": 3,\r\n \"enabled\": true,\r\n \"scopes\": [\r\n \"/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourceGroups/SanjaychResourceGroup/providers/Microsoft.Compute/virtualMachines/SCCMDemo2\",\r\n \"/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourceGroups/SanjaychResourceGroup/providers/Microsoft.Compute/virtualMachines/SCCMDemo3\"\r\n ],\r\n \"evaluationFrequency\": \"PT15M\",\r\n \"windowSize\": \"PT15M\",\r\n \"templateType\": 13,\r\n \"templateSpecificParameters\": {\r\n \"direction\": \"Up\",\r\n \"sensitivity\": \"High\"\r\n },\r\n \"criteria\": {\r\n \"allOf\": [\r\n {\r\n \"alertSensitivity\": \"High\",\r\n \"failingPeriods\": {\r\n \"numberOfEvaluationPeriods\": 4,\r\n \"minFailingPeriodsToAlert\": 4\r\n },\r\n \"name\": \"metric1\",\r\n \"metricNamespace\": \"microsoft.compute/virtualmachines\",\r\n \"metricName\": \"Percentage CPU\",\r\n \"dimensions\": [],\r\n \"operator\": \"GreaterThan\",\r\n \"timeAggregation\": \"Average\",\r\n \"criterionType\": \"DynamicThresholdCriterion\"\r\n }\r\n ],\r\n \"odata.type\": \"Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria\"\r\n },\r\n \"targetResourceType\": \"Microsoft.Compute/virtualMachines\",\r\n \"targetResourceRegion\": \"southcentralus\",\r\n \"actions\": [\r\n {\r\n \"actionGroupId\": \"/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourcegroups/default-activitylogalerts/providers/microsoft.insights/actiongroups/anashah\"\r\n }\r\n ]\r\n }\r\n}", + "StatusCode": 200 + }, + { + "RequestUri": "/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourceGroups/SanjaychResourceGroup/providers/Microsoft.Insights/metricAlerts/MultiResResourceDynamicMetricAlert?api-version=2018-03-01", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvODA0MzAwMTgtMjRlZS00YjI4LWE3YmQtZmIyM2I1YTIyMWQ2L3Jlc291cmNlR3JvdXBzL1NhbmpheWNoUmVzb3VyY2VHcm91cC9wcm92aWRlcnMvTWljcm9zb2Z0Lkluc2lnaHRzL21ldHJpY0FsZXJ0cy9NdWx0aVJlc1Jlc291cmNlRHluYW1pY01ldHJpY0FsZXJ0P2FwaS12ZXJzaW9uPTIwMTgtMDMtMDE=", + "RequestMethod": "DELETE", + "RequestBody": "", + "RequestHeaders": { + "x-ms-client-request-id": [ + "625d635b-842a-4979-a0e4-78ce797b33af" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.26614.01", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.18362.", + "Microsoft.Azure.Management.Monitor.MonitorManagementClient/0.22.0.0" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Tue, 16 Jul 2019 20:36:40 GMT" + ], + "Pragma": [ + "no-cache" + ], + "Server": [ + "Microsoft-IIS/10.0" + ], + "x-ms-request-id": [ + "dde34753-5aaa-439c-acd5-fe51e180fd8f" + ], + "X-AspNet-Version": [ + "4.0.30319" + ], + "X-Powered-By": [ + "ASP.NET" + ], + "x-ms-ratelimit-remaining-subscription-deletes": [ + "14999" + ], + "x-ms-correlation-request-id": [ + "dde34753-5aaa-439c-acd5-fe51e180fd8f" + ], + "x-ms-routing-request-id": [ + "UKSOUTH2:20190716T203641Z:dde34753-5aaa-439c-acd5-fe51e180fd8f" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Content-Length": [ + "0" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "", + "StatusCode": 200 + } + ], + "Names": {}, + "Variables": { + "SubscriptionId": "80430018-24ee-4b28-a7bd-fb23b5a221d6" + } +} \ No newline at end of file diff --git a/sdk/monitor/Microsoft.Azure.Management.Monitor/tests/SessionRecords/Monitor.Tests.Scenarios.MetricAlertsTests/MultiResSubscriptionLevelDynamicMetricAlertRule.json b/sdk/monitor/Microsoft.Azure.Management.Monitor/tests/SessionRecords/Monitor.Tests.Scenarios.MetricAlertsTests/MultiResSubscriptionLevelDynamicMetricAlertRule.json new file mode 100644 index 0000000000000..189e97d01d359 --- /dev/null +++ b/sdk/monitor/Microsoft.Azure.Management.Monitor/tests/SessionRecords/Monitor.Tests.Scenarios.MetricAlertsTests/MultiResSubscriptionLevelDynamicMetricAlertRule.json @@ -0,0 +1,275 @@ +{ + "Entries": [ + { + "RequestUri": "/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourcegroups/SanjaychResourceGroup?api-version=2017-05-10", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvODA0MzAwMTgtMjRlZS00YjI4LWE3YmQtZmIyM2I1YTIyMWQ2L3Jlc291cmNlZ3JvdXBzL1NhbmpheWNoUmVzb3VyY2VHcm91cD9hcGktdmVyc2lvbj0yMDE3LTA1LTEw", + "RequestMethod": "HEAD", + "RequestBody": "", + "RequestHeaders": { + "x-ms-client-request-id": [ + "2b2492cb-110b-47da-b8b4-735151910d9e" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.26614.01", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.18362.", + "Microsoft.Azure.Management.ResourceManager.ResourceManagementClient/1.6.0.0" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Tue, 16 Jul 2019 20:36:55 GMT" + ], + "Pragma": [ + "no-cache" + ], + "x-ms-ratelimit-remaining-subscription-reads": [ + "11999" + ], + "x-ms-request-id": [ + "5b885458-7f04-47b9-a8f3-79986a269fd3" + ], + "x-ms-correlation-request-id": [ + "5b885458-7f04-47b9-a8f3-79986a269fd3" + ], + "x-ms-routing-request-id": [ + "UKSOUTH2:20190716T203656Z:5b885458-7f04-47b9-a8f3-79986a269fd3" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Content-Length": [ + "0" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "", + "StatusCode": 204 + }, + { + "RequestUri": "/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourceGroups/SanjaychResourceGroup/providers/Microsoft.Insights/metricAlerts/MultiResSubsDynamicMetricAlert?api-version=2018-03-01", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvODA0MzAwMTgtMjRlZS00YjI4LWE3YmQtZmIyM2I1YTIyMWQ2L3Jlc291cmNlR3JvdXBzL1NhbmpheWNoUmVzb3VyY2VHcm91cC9wcm92aWRlcnMvTWljcm9zb2Z0Lkluc2lnaHRzL21ldHJpY0FsZXJ0cy9NdWx0aVJlc1N1YnNEeW5hbWljTWV0cmljQWxlcnQ/YXBpLXZlcnNpb249MjAxOC0wMy0wMQ==", + "RequestMethod": "PUT", + "RequestBody": "{\r\n \"properties\": {\r\n \"description\": \" This is for Multi Resource Metric Alert SDK Scenario Test (ResourceGroup Level)\",\r\n \"severity\": 3,\r\n \"enabled\": true,\r\n \"scopes\": [\r\n \"/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6\"\r\n ],\r\n \"evaluationFrequency\": \"PT15M\",\r\n \"windowSize\": \"PT15M\",\r\n \"targetResourceType\": \"Microsoft.Compute/virtualMachines\",\r\n \"targetResourceRegion\": \"southcentralus\",\r\n \"criteria\": {\r\n \"odata.type\": \"Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria\",\r\n \"allOf\": [\r\n {\r\n \"criterionType\": \"DynamicThresholdCriterion\",\r\n \"operator\": \"GreaterThan\",\r\n \"alertSensitivity\": \"High\",\r\n \"failingPeriods\": {\r\n \"numberOfEvaluationPeriods\": 4.0,\r\n \"minFailingPeriodsToAlert\": 4.0\r\n },\r\n \"name\": \"metric1\",\r\n \"metricName\": \"Percentage CPU\",\r\n \"metricNamespace\": \"microsoft.compute/virtualmachines\",\r\n \"timeAggregation\": \"Average\",\r\n \"dimensions\": []\r\n }\r\n ]\r\n },\r\n \"actions\": [\r\n {\r\n \"actionGroupId\": \"/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourcegroups/default-activitylogalerts/providers/microsoft.insights/actiongroups/anashah\"\r\n }\r\n ]\r\n },\r\n \"location\": \"global\"\r\n}", + "RequestHeaders": { + "x-ms-client-request-id": [ + "8ec1155a-9796-45a7-bc5d-fbe435099b38" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.26614.01", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.18362.", + "Microsoft.Azure.Management.Monitor.MonitorManagementClient/0.22.0.0" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Content-Length": [ + "1318" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Tue, 16 Jul 2019 20:37:03 GMT" + ], + "Pragma": [ + "no-cache" + ], + "Server": [ + "Microsoft-IIS/10.0" + ], + "x-ms-request-id": [ + "4c64badb-74b2-433a-9cec-92bdcedb01f9" + ], + "X-AspNet-Version": [ + "4.0.30319" + ], + "X-Powered-By": [ + "ASP.NET" + ], + "x-ms-ratelimit-remaining-subscription-writes": [ + "1199" + ], + "x-ms-correlation-request-id": [ + "4c64badb-74b2-433a-9cec-92bdcedb01f9" + ], + "x-ms-routing-request-id": [ + "UKSOUTH2:20190716T203703Z:4c64badb-74b2-433a-9cec-92bdcedb01f9" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Content-Length": [ + "1704" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "{\r\n \"location\": \"global\",\r\n \"type\": \"Microsoft.Insights/metricAlerts\",\r\n \"name\": \"MultiResSubsDynamicMetricAlert\",\r\n \"id\": \"/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourceGroups/SanjaychResourceGroup/providers/Microsoft.Insights/metricAlerts/MultiResSubsDynamicMetricAlert\",\r\n \"properties\": {\r\n \"description\": \" This is for Multi Resource Metric Alert SDK Scenario Test (ResourceGroup Level)\",\r\n \"severity\": 3,\r\n \"enabled\": true,\r\n \"scopes\": [\r\n \"/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6\"\r\n ],\r\n \"evaluationFrequency\": \"PT15M\",\r\n \"windowSize\": \"PT15M\",\r\n \"templateType\": 13,\r\n \"templateSpecificParameters\": {\r\n \"direction\": \"Up\",\r\n \"sensitivity\": \"High\"\r\n },\r\n \"criteria\": {\r\n \"allOf\": [\r\n {\r\n \"alertSensitivity\": \"High\",\r\n \"failingPeriods\": {\r\n \"numberOfEvaluationPeriods\": 4,\r\n \"minFailingPeriodsToAlert\": 4\r\n },\r\n \"name\": \"metric1\",\r\n \"metricNamespace\": \"microsoft.compute/virtualmachines\",\r\n \"metricName\": \"Percentage CPU\",\r\n \"dimensions\": [],\r\n \"operator\": \"GreaterThan\",\r\n \"timeAggregation\": \"Average\",\r\n \"criterionType\": \"DynamicThresholdCriterion\"\r\n }\r\n ],\r\n \"odata.type\": \"Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria\"\r\n },\r\n \"targetResourceType\": \"Microsoft.Compute/virtualMachines\",\r\n \"targetResourceRegion\": \"southcentralus\",\r\n \"actions\": [\r\n {\r\n \"actionGroupId\": \"/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourcegroups/default-activitylogalerts/providers/microsoft.insights/actiongroups/anashah\"\r\n }\r\n ]\r\n }\r\n}", + "StatusCode": 200 + }, + { + "RequestUri": "/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourceGroups/SanjaychResourceGroup/providers/Microsoft.Insights/metricAlerts/MultiResSubsDynamicMetricAlert?api-version=2018-03-01", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvODA0MzAwMTgtMjRlZS00YjI4LWE3YmQtZmIyM2I1YTIyMWQ2L3Jlc291cmNlR3JvdXBzL1NhbmpheWNoUmVzb3VyY2VHcm91cC9wcm92aWRlcnMvTWljcm9zb2Z0Lkluc2lnaHRzL21ldHJpY0FsZXJ0cy9NdWx0aVJlc1N1YnNEeW5hbWljTWV0cmljQWxlcnQ/YXBpLXZlcnNpb249MjAxOC0wMy0wMQ==", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "x-ms-client-request-id": [ + "d34b64cd-fba8-4cde-ac6e-4633a3fbabf6" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.26614.01", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.18362.", + "Microsoft.Azure.Management.Monitor.MonitorManagementClient/0.22.0.0" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Tue, 16 Jul 2019 20:37:04 GMT" + ], + "Pragma": [ + "no-cache" + ], + "Server": [ + "Microsoft-IIS/10.0" + ], + "x-ms-request-id": [ + "fd3cff54-abe0-4e20-8ac1-e78c46c5ca05" + ], + "X-AspNet-Version": [ + "4.0.30319" + ], + "X-Powered-By": [ + "ASP.NET" + ], + "x-ms-ratelimit-remaining-subscription-reads": [ + "11998" + ], + "x-ms-correlation-request-id": [ + "fd3cff54-abe0-4e20-8ac1-e78c46c5ca05" + ], + "x-ms-routing-request-id": [ + "UKSOUTH2:20190716T203704Z:fd3cff54-abe0-4e20-8ac1-e78c46c5ca05" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Content-Length": [ + "1704" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "{\r\n \"location\": \"global\",\r\n \"type\": \"Microsoft.Insights/metricAlerts\",\r\n \"name\": \"MultiResSubsDynamicMetricAlert\",\r\n \"id\": \"/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourceGroups/SanjaychResourceGroup/providers/Microsoft.Insights/metricAlerts/MultiResSubsDynamicMetricAlert\",\r\n \"properties\": {\r\n \"description\": \" This is for Multi Resource Metric Alert SDK Scenario Test (ResourceGroup Level)\",\r\n \"severity\": 3,\r\n \"enabled\": true,\r\n \"scopes\": [\r\n \"/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6\"\r\n ],\r\n \"evaluationFrequency\": \"PT15M\",\r\n \"windowSize\": \"PT15M\",\r\n \"templateType\": 13,\r\n \"templateSpecificParameters\": {\r\n \"direction\": \"Up\",\r\n \"sensitivity\": \"High\"\r\n },\r\n \"criteria\": {\r\n \"allOf\": [\r\n {\r\n \"alertSensitivity\": \"High\",\r\n \"failingPeriods\": {\r\n \"numberOfEvaluationPeriods\": 4,\r\n \"minFailingPeriodsToAlert\": 4\r\n },\r\n \"name\": \"metric1\",\r\n \"metricNamespace\": \"microsoft.compute/virtualmachines\",\r\n \"metricName\": \"Percentage CPU\",\r\n \"dimensions\": [],\r\n \"operator\": \"GreaterThan\",\r\n \"timeAggregation\": \"Average\",\r\n \"criterionType\": \"DynamicThresholdCriterion\"\r\n }\r\n ],\r\n \"odata.type\": \"Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria\"\r\n },\r\n \"targetResourceType\": \"Microsoft.Compute/virtualMachines\",\r\n \"targetResourceRegion\": \"southcentralus\",\r\n \"actions\": [\r\n {\r\n \"actionGroupId\": \"/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourcegroups/default-activitylogalerts/providers/microsoft.insights/actiongroups/anashah\"\r\n }\r\n ]\r\n }\r\n}", + "StatusCode": 200 + }, + { + "RequestUri": "/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourceGroups/SanjaychResourceGroup/providers/Microsoft.Insights/metricAlerts/MultiResSubsDynamicMetricAlert?api-version=2018-03-01", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvODA0MzAwMTgtMjRlZS00YjI4LWE3YmQtZmIyM2I1YTIyMWQ2L3Jlc291cmNlR3JvdXBzL1NhbmpheWNoUmVzb3VyY2VHcm91cC9wcm92aWRlcnMvTWljcm9zb2Z0Lkluc2lnaHRzL21ldHJpY0FsZXJ0cy9NdWx0aVJlc1N1YnNEeW5hbWljTWV0cmljQWxlcnQ/YXBpLXZlcnNpb249MjAxOC0wMy0wMQ==", + "RequestMethod": "DELETE", + "RequestBody": "", + "RequestHeaders": { + "x-ms-client-request-id": [ + "66dfb274-30e5-44c6-b73b-acb5494de442" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.26614.01", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.18362.", + "Microsoft.Azure.Management.Monitor.MonitorManagementClient/0.22.0.0" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Tue, 16 Jul 2019 20:37:09 GMT" + ], + "Pragma": [ + "no-cache" + ], + "Server": [ + "Microsoft-IIS/10.0" + ], + "x-ms-request-id": [ + "33858b5b-1605-4ef4-949d-ef56f89f8b69" + ], + "X-AspNet-Version": [ + "4.0.30319" + ], + "X-Powered-By": [ + "ASP.NET" + ], + "x-ms-ratelimit-remaining-subscription-deletes": [ + "14999" + ], + "x-ms-correlation-request-id": [ + "33858b5b-1605-4ef4-949d-ef56f89f8b69" + ], + "x-ms-routing-request-id": [ + "UKSOUTH2:20190716T203709Z:33858b5b-1605-4ef4-949d-ef56f89f8b69" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Content-Length": [ + "0" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "", + "StatusCode": 200 + } + ], + "Names": {}, + "Variables": { + "SubscriptionId": "80430018-24ee-4b28-a7bd-fb23b5a221d6" + } +} \ No newline at end of file From 20572992afab70826c2759cc4c9cf37ef3eb479a Mon Sep 17 00:00:00 2001 From: Meydan Dayan Date: Wed, 17 Jul 2019 13:08:34 +0300 Subject: [PATCH 2/2] Don't exclude from build and test --- .../tests/Microsoft.Azure.Management.Monitor.Tests.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/monitor/Microsoft.Azure.Management.Monitor/tests/Microsoft.Azure.Management.Monitor.Tests.csproj b/sdk/monitor/Microsoft.Azure.Management.Monitor/tests/Microsoft.Azure.Management.Monitor.Tests.csproj index d57d6da00ed5a..01b8213bed513 100644 --- a/sdk/monitor/Microsoft.Azure.Management.Monitor/tests/Microsoft.Azure.Management.Monitor.Tests.csproj +++ b/sdk/monitor/Microsoft.Azure.Management.Monitor/tests/Microsoft.Azure.Management.Monitor.Tests.csproj @@ -8,8 +8,8 @@ true - true - true + false + false