Beispiel #1
0
        public async Task GetAnomalyDimensionValuesWithOptionalDimensionFilter()
        {
            const string dimensionName = "city";

            MetricsAdvisorClient client = GetMetricsAdvisorClient();

            var dimensions = new Dictionary <string, string>()
            {
                { "category", "Handmade" }
            };
            var options = new GetAnomalyDimensionValuesOptions(SamplingStartTime, SamplingEndTime)
            {
                SeriesGroupKey = new DimensionKey(dimensions)
            };

            var valueCount = 0;

            await foreach (string value in client.GetAnomalyDimensionValuesAsync(DetectionConfigurationId, dimensionName, options))
            {
                Assert.That(value, Is.Not.Null.And.Not.Empty);

                if (++valueCount >= MaximumSamplesCount)
                {
                    break;
                }
            }

            Assert.That(valueCount, Is.GreaterThan(0));
        }
        public async Task GetAnomalyDimensionValuesAsync()
        {
            string endpoint        = MetricsAdvisorUri;
            string subscriptionKey = MetricsAdvisorSubscriptionKey;
            string apiKey          = MetricsAdvisorApiKey;
            var    credential      = new MetricsAdvisorKeyCredential(subscriptionKey, apiKey);

            var client = new MetricsAdvisorClient(new Uri(endpoint), credential);

            string detectionConfigurationId = DetectionConfigurationId;

            string dimensionName = "city";

            var startTime = DateTimeOffset.Parse("2020-01-01T00:00:00Z");
            var endTime   = DateTimeOffset.UtcNow;
            var options   = new GetAnomalyDimensionValuesOptions(startTime, endTime)
            {
                MaxPageSize = 10
            };

            Console.WriteLine($"The dimension '{dimensionName}' assumed the following values on anomalous data points (limited to 10):");

            int dimensionValueCount = 0;

            await foreach (string dimensionValue in client.GetAnomalyDimensionValuesAsync(detectionConfigurationId, dimensionName, options))
            {
                Console.WriteLine($"  {dimensionValue}");

                // Print at most 10 values.
                if (++dimensionValueCount >= 10)
                {
                    break;
                }
            }
        }
Beispiel #3
0
        public async Task GetAnomalyDimensionValuesWithMinimumSetup(bool useTokenCredential)
        {
            const string dimensionName = "city";

            MetricsAdvisorClient client = GetMetricsAdvisorClient(useTokenCredential);

            var options = new GetAnomalyDimensionValuesOptions(SamplingStartTime, SamplingEndTime);

            var valueCount = 0;

            await foreach (string value in client.GetAnomalyDimensionValuesAsync(DetectionConfigurationId, dimensionName, options))
            {
                Assert.That(value, Is.Not.Null.And.Not.Empty);

                if (++valueCount >= MaximumSamplesCount)
                {
                    break;
                }
            }

            Assert.That(valueCount, Is.GreaterThan(0));
        }