Exemple #1
0
        internal async Task <MetricAnomalyDetectionConfiguration> CreateMetricAnomalyDetectionConfiguration(MetricsAdvisorAdministrationClient adminClient)
        {
            DataFeed feed = await GetFirstDataFeed(adminClient).ConfigureAwait(false);

            var config = new MetricAnomalyDetectionConfiguration(
                feed.MetricIds.First(),
                Recording.GenerateAlphaNumericId("Name"),
                new MetricAnomalyDetectionConditions(
                    DetectionConditionsOperator.And,
                    new SmartDetectionCondition(42, AnomalyDetectorDirection.Both, new SuppressCondition(1, 67)),
                    new HardThresholdCondition(23, 45, AnomalyDetectorDirection.Both, new SuppressCondition(1, 50)),
                    new ChangeThresholdCondition(12, 5, true, AnomalyDetectorDirection.Both, new SuppressCondition(1, 1))));

            return(await adminClient.CreateMetricAnomalyDetectionConfigurationAsync(config).ConfigureAwait(false));
        }
        public async Task CreateMetricAnomalyDetectionConfiguration()
        {
            var adminClient = GetMetricsAdvisorAdministrationClient();

            var config = await CreateMetricAnomalyDetectionConfiguration(adminClient);

            MetricAnomalyDetectionConfiguration createdConfiguration = await adminClient.CreateMetricAnomalyDetectionConfigurationAsync(config).ConfigureAwait(false);

            Assert.That(createdConfiguration.Id, Is.Not.Null);
            Assert.That(createdConfiguration.Name, Is.EqualTo(config.Name));

            MetricAnomalyDetectionConfiguration getConfig = await adminClient.GetMetricAnomalyDetectionConfigurationAsync(createdConfiguration.Id).ConfigureAwait(false);

            Assert.That(getConfig.Id, Is.EqualTo(createdConfiguration.Id));

            await adminClient.DeleteMetricAnomalyDetectionConfigurationAsync(createdConfiguration.Id);
        }
        public async Task AnomalyAlertConfigurationOperations()
        {
            var adminClient = GetMetricsAdvisorAdministrationClient();

            // Create a Detection Configuration
            DataFeed feed = await GetFirstDataFeed(adminClient);

            MetricAnomalyDetectionConfiguration detectionConfig = await CreateMetricAnomalyDetectionConfiguration(adminClient).ConfigureAwait(false);

            MetricAnomalyDetectionConfiguration createdAnomalyDetectionConfiguration = await adminClient.CreateMetricAnomalyDetectionConfigurationAsync(detectionConfig).ConfigureAwait(false);

            AnomalyAlertConfiguration createdAlertConfig = await adminClient.CreateAnomalyAlertConfigurationAsync(
                new AnomalyAlertConfiguration(
                    Recording.GenerateAlphaNumericId("test"),
                    new List <string>(),
                    new List <MetricAnomalyAlertConfiguration>
            {
                new MetricAnomalyAlertConfiguration(
                    createdAnomalyDetectionConfiguration.Id,
                    new MetricAnomalyAlertScope(
                        MetricAnomalyAlertScopeType.TopN,
                        new DimensionKey(new List <KeyValuePair <string, string> >
                {
                    new KeyValuePair <string, string>("test", "test2")
                }),
                        new TopNGroupScope(8, 4, 2)))
            })
                ).ConfigureAwait(false);

            Assert.That(createdAlertConfig.Id, Is.Not.Null);

            // Validate that we can Get the newly created config
            AnomalyAlertConfiguration getAlertConfig = await adminClient.GetAnomalyAlertConfigurationAsync(createdAlertConfig.Id).ConfigureAwait(false);

            Response <IReadOnlyList <AnomalyAlertConfiguration> > getAlertConfigs = await adminClient.GetAnomalyAlertConfigurationsAsync(createdAnomalyDetectionConfiguration.Id).ConfigureAwait(false);

            Assert.That(getAlertConfig.Id, Is.EqualTo(createdAlertConfig.Id));
            Assert.That(getAlertConfigs.Value.Any(c => c.Id == createdAlertConfig.Id));

            // Cleanup
            await adminClient.DeleteAnomalyAlertConfigurationAsync(createdAlertConfig.Id).ConfigureAwait(false);
        }