public async Task UpdateAnomalyAlertConfigurationAsync() { string endpoint = MetricsAdvisorUri; string subscriptionKey = MetricsAdvisorSubscriptionKey; string apiKey = MetricsAdvisorApiKey; var credential = new MetricsAdvisorKeyCredential(subscriptionKey, apiKey); var adminClient = new MetricsAdvisorAdministrationClient(new Uri(endpoint), credential); string alertConfigurationId = AlertConfigurationId; Response <AnomalyAlertConfiguration> response = await adminClient.GetAnomalyAlertConfigurationAsync(alertConfigurationId); AnomalyAlertConfiguration alertConfiguration = response.Value; string originalDescription = alertConfiguration.Description; alertConfiguration.Description = "This description was generated by a sample."; await adminClient.UpdateAnomalyAlertConfigurationAsync(alertConfigurationId, alertConfiguration); // Undo the changes to leave the alert configuration unaltered. Skip this step if you intend to keep // the changes. alertConfiguration.Description = originalDescription; await adminClient.UpdateAnomalyAlertConfigurationAsync(alertConfigurationId, alertConfiguration); }
public async Task GetAnomalyAlertConfigurationAsync() { string endpoint = MetricsAdvisorUri; string subscriptionKey = MetricsAdvisorSubscriptionKey; string apiKey = MetricsAdvisorApiKey; var credential = new MetricsAdvisorKeyCredential(subscriptionKey, apiKey); var adminClient = new MetricsAdvisorAdministrationClient(new Uri(endpoint), credential); string alertConfigurationId = AlertConfigurationId; Response <AnomalyAlertConfiguration> response = await adminClient.GetAnomalyAlertConfigurationAsync(alertConfigurationId); AnomalyAlertConfiguration alertConfiguration = response.Value; Console.WriteLine($"Alert configuration name: {alertConfiguration.Name}"); Console.WriteLine($"Alert configuration description: {alertConfiguration.Description}"); Console.WriteLine(); Console.WriteLine($"IDs of hooks to alert:"); foreach (string hookId in alertConfiguration.IdsOfHooksToAlert) { Console.WriteLine($" - {hookId}"); } Console.WriteLine(); Console.WriteLine("Metric anomaly alert configurations:"); foreach (MetricAnomalyAlertConfiguration metricAlertConfiguration in alertConfiguration.MetricAlertConfigurations) { Console.Write($" Scope type: {metricAlertConfiguration.AlertScope.ScopeType}, "); Console.WriteLine($"Anomaly detection configuration ID: {metricAlertConfiguration.DetectionConfigurationId}"); } }