コード例 #1
0
 internal MetricAnomalyDetectionConditions(DetectionConditionsOperator?crossConditionsOperator, SmartDetectionCondition smartDetectionCondition, HardThresholdCondition hardThresholdCondition, ChangeThresholdCondition changeThresholdCondition)
 {
     CrossConditionsOperator  = crossConditionsOperator;
     SmartDetectionCondition  = smartDetectionCondition;
     HardThresholdCondition   = hardThresholdCondition;
     ChangeThresholdCondition = changeThresholdCondition;
 }
コード例 #2
0
 internal MetricWholeSeriesDetectionCondition(DetectionConditionOperator?conditionOperator, SmartDetectionCondition smartDetectionCondition, HardThresholdCondition hardThresholdCondition, ChangeThresholdCondition changeThresholdCondition)
 {
     ConditionOperator        = conditionOperator;
     SmartDetectionCondition  = smartDetectionCondition;
     HardThresholdCondition   = hardThresholdCondition;
     ChangeThresholdCondition = changeThresholdCondition;
 }
        public async Task CreateAndDeleteAnomalyDetectionConfigurationAsync()
        {
            string endpoint        = MetricsAdvisorUri;
            string subscriptionKey = MetricsAdvisorSubscriptionKey;
            string apiKey          = MetricsAdvisorApiKey;
            var    credential      = new MetricsAdvisorKeyCredential(subscriptionKey, apiKey);

            var adminClient = new MetricsAdvisorAdministrationClient(new Uri(endpoint), credential);

            string metricId = MetricId;

            #region Snippet:CreateAnomalyDetectionConfigurationAsync
            //@@ string metricId = "<metricId>";
            string configurationName = "Sample anomaly detection configuration";

            var hardThresholdSuppressCondition = new SuppressCondition(1, 100);
            var hardThresholdCondition         = new HardThresholdCondition(AnomalyDetectorDirection.Down, hardThresholdSuppressCondition)
            {
                LowerBound = 5.0
            };

            var smartDetectionSuppressCondition = new SuppressCondition(4, 50);
            var smartDetectionCondition         = new SmartDetectionCondition(10.0, AnomalyDetectorDirection.Up, smartDetectionSuppressCondition);

            var detectionCondition = new MetricWholeSeriesDetectionCondition()
            {
                HardThresholdCondition  = hardThresholdCondition,
                SmartDetectionCondition = smartDetectionCondition,
                CrossConditionsOperator = DetectionConditionsOperator.Or
            };

            var detectionConfiguration = new AnomalyDetectionConfiguration(metricId, configurationName, detectionCondition);

            Response <AnomalyDetectionConfiguration> response = await adminClient.CreateMetricAnomalyDetectionConfigurationAsync(detectionConfiguration);

            detectionConfiguration = response.Value;

            Console.WriteLine($"Anomaly detection configuration ID: {detectionConfiguration.Id}");
            #endregion

            // Delete the created anomaly detection configuration to clean up the Metrics Advisor resource.
            // Do not perform this step if you intend to keep using the configuration.

            await adminClient.DeleteMetricAnomalyDetectionConfigurationAsync(detectionConfiguration.Id);
        }