Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
com.azure.ai.metricsadvisor.MetricsAdvisorClient Maven / Gradle / Ivy
Go to download
This package contains the Microsoft Azure Cognitive Services Metrics Advisor SDK.
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
package com.azure.ai.metricsadvisor;
import com.azure.ai.metricsadvisor.administration.MetricsAdvisorAdministrationClientBuilder;
import com.azure.ai.metricsadvisor.implementation.MetricsAdvisorImpl;
import com.azure.ai.metricsadvisor.implementation.models.AlertingResultQuery;
import com.azure.ai.metricsadvisor.implementation.models.AnomalyDimensionQuery;
import com.azure.ai.metricsadvisor.implementation.models.AnomalyFeedback;
import com.azure.ai.metricsadvisor.implementation.models.AnomalyFeedbackValue;
import com.azure.ai.metricsadvisor.implementation.models.AnomalyResult;
import com.azure.ai.metricsadvisor.implementation.models.ChangePointFeedback;
import com.azure.ai.metricsadvisor.implementation.models.ChangePointFeedbackValue;
import com.azure.ai.metricsadvisor.implementation.models.CommentFeedback;
import com.azure.ai.metricsadvisor.implementation.models.CommentFeedbackValue;
import com.azure.ai.metricsadvisor.implementation.models.CreateMetricFeedbackResponse;
import com.azure.ai.metricsadvisor.implementation.models.DetectionAnomalyResultQuery;
import com.azure.ai.metricsadvisor.implementation.models.DetectionIncidentResultQuery;
import com.azure.ai.metricsadvisor.implementation.models.DetectionSeriesQuery;
import com.azure.ai.metricsadvisor.implementation.models.EnrichmentStatusQueryOption;
import com.azure.ai.metricsadvisor.implementation.models.FeedbackDimensionFilter;
import com.azure.ai.metricsadvisor.implementation.models.IncidentResult;
import com.azure.ai.metricsadvisor.implementation.models.MetricDataList;
import com.azure.ai.metricsadvisor.implementation.models.MetricDataQueryOptions;
import com.azure.ai.metricsadvisor.implementation.models.MetricDimensionQueryOptions;
import com.azure.ai.metricsadvisor.implementation.models.MetricFeedbackFilter;
import com.azure.ai.metricsadvisor.implementation.models.MetricSeriesItem;
import com.azure.ai.metricsadvisor.implementation.models.MetricSeriesQueryOptions;
import com.azure.ai.metricsadvisor.implementation.models.PeriodFeedback;
import com.azure.ai.metricsadvisor.implementation.models.PeriodFeedbackValue;
import com.azure.ai.metricsadvisor.implementation.models.RootCauseList;
import com.azure.ai.metricsadvisor.implementation.models.SeriesIdentity;
import com.azure.ai.metricsadvisor.implementation.models.SeriesResultList;
import com.azure.ai.metricsadvisor.implementation.models.TimeMode;
import com.azure.ai.metricsadvisor.implementation.util.AnomalyTransforms;
import com.azure.ai.metricsadvisor.implementation.util.DetectionConfigurationTransforms;
import com.azure.ai.metricsadvisor.implementation.util.IncidentHelper;
import com.azure.ai.metricsadvisor.implementation.util.IncidentRootCauseTransforms;
import com.azure.ai.metricsadvisor.implementation.util.IncidentTransforms;
import com.azure.ai.metricsadvisor.implementation.util.MetricEnrichedSeriesDataTransformations;
import com.azure.ai.metricsadvisor.implementation.util.MetricFeedbackTransforms;
import com.azure.ai.metricsadvisor.implementation.util.MetricSeriesDataTransforms;
import com.azure.ai.metricsadvisor.implementation.util.MetricSeriesDefinitionTransforms;
import com.azure.ai.metricsadvisor.models.AnomalyAlert;
import com.azure.ai.metricsadvisor.models.AnomalyIncident;
import com.azure.ai.metricsadvisor.models.DataPointAnomaly;
import com.azure.ai.metricsadvisor.models.DimensionKey;
import com.azure.ai.metricsadvisor.models.EnrichmentStatus;
import com.azure.ai.metricsadvisor.models.IncidentRootCause;
import com.azure.ai.metricsadvisor.models.ListAlertOptions;
import com.azure.ai.metricsadvisor.models.ListAnomaliesAlertedOptions;
import com.azure.ai.metricsadvisor.models.ListAnomaliesDetectedOptions;
import com.azure.ai.metricsadvisor.models.ListAnomalyDimensionValuesOptions;
import com.azure.ai.metricsadvisor.models.ListIncidentsAlertedOptions;
import com.azure.ai.metricsadvisor.models.ListIncidentsDetectedOptions;
import com.azure.ai.metricsadvisor.models.ListMetricDimensionValuesOptions;
import com.azure.ai.metricsadvisor.models.ListMetricEnrichmentStatusOptions;
import com.azure.ai.metricsadvisor.models.ListMetricFeedbackOptions;
import com.azure.ai.metricsadvisor.models.ListMetricSeriesDefinitionOptions;
import com.azure.ai.metricsadvisor.models.MetricAnomalyFeedback;
import com.azure.ai.metricsadvisor.models.MetricChangePointFeedback;
import com.azure.ai.metricsadvisor.models.MetricCommentFeedback;
import com.azure.ai.metricsadvisor.models.MetricEnrichedSeriesData;
import com.azure.ai.metricsadvisor.models.MetricFeedback;
import com.azure.ai.metricsadvisor.models.MetricPeriodFeedback;
import com.azure.ai.metricsadvisor.models.MetricSeriesData;
import com.azure.ai.metricsadvisor.models.MetricSeriesDefinition;
import com.azure.ai.metricsadvisor.models.MetricsAdvisorResponseException;
import com.azure.core.annotation.ReturnType;
import com.azure.core.annotation.ServiceClient;
import com.azure.core.annotation.ServiceMethod;
import com.azure.core.http.rest.PagedIterable;
import com.azure.core.http.rest.PagedResponse;
import com.azure.core.http.rest.PagedResponseBase;
import com.azure.core.http.rest.Response;
import com.azure.core.http.rest.SimpleResponse;
import com.azure.core.util.Context;
import com.azure.core.util.CoreUtils;
import com.azure.core.util.logging.ClientLogger;
import java.time.OffsetDateTime;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.UUID;
import java.util.stream.Collectors;
import static com.azure.ai.metricsadvisor.implementation.util.Utility.getEnrichmentStatusQueryOptions;
import static com.azure.ai.metricsadvisor.implementation.util.Utility.getListAnomaliesDetectedOptions;
import static com.azure.ai.metricsadvisor.implementation.util.Utility.getListAnomalyDimensionValuesOptions;
import static com.azure.ai.metricsadvisor.implementation.util.Utility.getListIncidentsDetectedOptions;
import static com.azure.ai.metricsadvisor.implementation.util.Utility.getMetricDataQueryOptions;
import static com.azure.ai.metricsadvisor.implementation.util.Utility.getMetricDimensionQueryOptions;
import static com.azure.ai.metricsadvisor.implementation.util.Utility.getMetricSeriesQueryOptions;
import static com.azure.ai.metricsadvisor.implementation.util.Utility.parseOperationId;
import static com.azure.ai.metricsadvisor.implementation.util.Utility.toStringOrNull;
import static com.azure.ai.metricsadvisor.implementation.util.Utility.validateActiveSinceInput;
import static com.azure.ai.metricsadvisor.implementation.util.Utility.validateAddFeedbackInputs;
import static com.azure.ai.metricsadvisor.implementation.util.Utility.validateAnomalyDimensionValuesInputs;
import static com.azure.ai.metricsadvisor.implementation.util.Utility.validateAnomalyIncidentRootCausesInputs;
import static com.azure.ai.metricsadvisor.implementation.util.Utility.validateIncidentsForDetectionConfigInputs;
import static com.azure.ai.metricsadvisor.implementation.util.Utility.validateListAlertsInputs;
import static com.azure.ai.metricsadvisor.implementation.util.Utility.validateListAnomaliesInputs;
import static com.azure.ai.metricsadvisor.implementation.util.Utility.validateMetricEnrichedSeriesInputs;
import static com.azure.ai.metricsadvisor.implementation.util.Utility.validateMetricEnrichmentStatusInputs;
import static com.azure.ai.metricsadvisor.implementation.util.Utility.validateMetricSeriesInputs;
import static com.azure.ai.metricsadvisor.implementation.util.Utility.validateStartEndTime;
/**
* This class provides a synchronous client to connect to the Metrics Advisor Azure Cognitive Service.
* This client provides synchronous methods to perform:
*
* Analyze root cause into specific dimension using the
* {@link com.azure.ai.metricsadvisor.MetricsAdvisorClient#listIncidentRootCauses(String, String, Context)}
* method with your respective data source.
* Fetch incidents triggered for a particular detection configuration using the
* {@link com.azure.ai.metricsadvisor.MetricsAdvisorClient#listIncidentsForDetectionConfig(String, OffsetDateTime, OffsetDateTime, ListIncidentsDetectedOptions, Context)}
* method.
* Fetch all the anomalies detected for a particular detection configuration using the
* {@link com.azure.ai.metricsadvisor.MetricsAdvisorClient#listAnomaliesForDetectionConfig(String, OffsetDateTime, OffsetDateTime)}
* method./li>
*
*
* Service clients are the point of interaction for developers to use Azure Metrics Advisor.
* {@link com.azure.ai.metricsadvisor.MetricsAdvisorClient} is the synchronous service client and
* {@link com.azure.ai.metricsadvisor.MetricsAdvisorAsyncClient} is the asynchronous service client.
* The examples shown in this document use a credential object named DefaultAzureCredential for authentication, which is
* appropriate for most scenarios, including local development and production environments. Additionally, we
* recommend using
* managed identity
* for authentication in production environments.
* You can find more information on different ways of authenticating and their corresponding credential types in the
* Azure Identity documentation" .
*
*
* Sample: Construct a MetricsAdvisorClient with DefaultAzureCredential
*
* The following code sample demonstrates the creation of a
* {@link com.azure.ai.metricsadvisor.MetricsAdvisorClient}, using the `DefaultAzureCredentialBuilder` to configure it.
*
*
*
* MetricsAdvisorClient metricsAdvisorClient =
* new MetricsAdvisorClientBuilder()
* .credential(new DefaultAzureCredentialBuilder().build())
* .endpoint("{endpoint}")
* .buildClient();
*
*
*
* Further, see the code sample below to use
* {@link com.azure.ai.metricsadvisor.models.MetricsAdvisorKeyCredential MetricsAdvisorKeyCredential} for client creation.
*
*
*
* MetricsAdvisorClient metricsAdvisorClient =
* new MetricsAdvisorClientBuilder()
* .credential(new MetricsAdvisorKeyCredential("{subscription_key}", "{api_key}"))
* .endpoint("{endpoint}")
* .buildClient();
*
*
*
* @see com.azure.ai.metricsadvisor
* @see MetricsAdvisorClientBuilder
* @see MetricsAdvisorAsyncClient
*/
@ServiceClient(builder = MetricsAdvisorClientBuilder.class)
public final class MetricsAdvisorClient {
final ClientLogger logger = new ClientLogger(MetricsAdvisorClient.class);
private final MetricsAdvisorImpl service;
/**
* Create a {@link MetricsAdvisorClient client} that sends requests to the Metrics Advisor service's
* endpoint.
* Each service call goes through the {@link MetricsAdvisorAdministrationClientBuilder#pipeline http pipeline}.
*
* @param service The proxy service used to perform REST calls.
* client routes its request through.
* @param serviceVersion The versions of Azure Metrics Advisor supported by this client library.
*/
MetricsAdvisorClient(MetricsAdvisorImpl service, MetricsAdvisorServiceVersion serviceVersion) {
this.service = service;
}
/**
* List series (dimension combinations) from metric.
*
* Code sample
*
*
* final OffsetDateTime activeSince = OffsetDateTime.parse("2020-07-10T00:00:00Z");
* metricsAdvisorClient.listMetricSeriesDefinitions(
* "metricId",
* activeSince)
* .forEach(metricSeriesDefinition -> {
* System.out.printf("Data Feed Metric id for the retrieved series definition : %s%n",
* metricSeriesDefinition.getMetricId());
* System.out.printf("Data Feed Metric dimension: %s%n", metricSeriesDefinition.getSeriesKey().asMap());
* });
*
*
*
* @param metricId metric unique id.
* @param activeSince the start time for querying series ingested after this time.
* @return A {@link PagedIterable} of the {@link MetricSeriesDefinition metric series definitions}.
* @throws IllegalArgumentException thrown if {@code metricId} fail the UUID format validation.
* @throws MetricsAdvisorResponseException thrown if the request is rejected by server.
* @throws NullPointerException thrown if the {@code metricId} or {@code activeSince}
* is null.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable listMetricSeriesDefinitions(String metricId,
OffsetDateTime activeSince) {
return listMetricSeriesDefinitions(metricId, activeSince, null, Context.NONE);
}
/**
* List series (dimension combinations) from metric.
*
* Code sample
*
*
* String metricId = "b460abfc-7a58-47d7-9d99-21ee21fdfc6e";
* final OffsetDateTime activeSince = OffsetDateTime.parse("2020-07-10T00:00:00Z");
* final ListMetricSeriesDefinitionOptions options
* = new ListMetricSeriesDefinitionOptions()
* .setMaxPageSize(10)
* .setDimensionCombinationToFilter(new HashMap<String, List<String>>() {{
* put("Dim2", Collections.singletonList("Angelfish"));
* }});
*
* metricsAdvisorClient.listMetricSeriesDefinitions(metricId, activeSince, options, Context.NONE)
* .forEach(metricSeriesDefinition -> {
* System.out.printf("Data Feed Metric id for the retrieved series definition : %s%n",
* metricSeriesDefinition.getMetricId());
* System.out.printf("Series Key:");
* System.out.println(metricSeriesDefinition.getSeriesKey().asMap());
* });
*
*
*
* @param metricId metric unique id.
* @param activeSince the start time for querying series ingested after this time.
* @param options the additional filtering attributes that can be provided to query the series.
* @param context Additional context that is passed through the HTTP pipeline during the service call.
*
* @return A {@link PagedIterable} of the {@link MetricSeriesDefinition metric series definitions}.
* @throws IllegalArgumentException thrown if {@code metricId} fail the UUID format validation.
* @throws MetricsAdvisorResponseException thrown if the request is rejected by server.
* @throws NullPointerException thrown if the {@code metricId} or {@code activeSince}
* is null.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable listMetricSeriesDefinitions(String metricId,
OffsetDateTime activeSince, ListMetricSeriesDefinitionOptions options, Context context) {
return listMetricSeriesDefinitionsSync(metricId, activeSince, options, context);
}
private PagedIterable listMetricSeriesDefinitionsSync(String metricId,
OffsetDateTime activeSince, ListMetricSeriesDefinitionOptions options, Context context) {
return new PagedIterable<>(
() -> listMetricSeriesDefinitionSinglePageSync(metricId, activeSince, options, context),
continuationToken -> listMetricSeriesDefinitionNextPageSync(continuationToken, activeSince, options,
context));
}
private PagedResponse listMetricSeriesDefinitionSinglePageSync(String metricId,
OffsetDateTime activeSince, ListMetricSeriesDefinitionOptions options, Context context) {
validateActiveSinceInput(activeSince, logger);
if (options == null) {
options = new ListMetricSeriesDefinitionOptions();
}
final MetricSeriesQueryOptions metricSeriesQueryOptions = getMetricSeriesQueryOptions(activeSince, options);
PagedResponse res = service.getMetricSeriesSinglePage(UUID.fromString(metricId),
metricSeriesQueryOptions, options.getSkip(), options.getMaxPageSize(), context);
return MetricSeriesDefinitionTransforms.fromInnerResponse(res);
}
private PagedResponse listMetricSeriesDefinitionNextPageSync(String nextPageLink,
OffsetDateTime activeSince, ListMetricSeriesDefinitionOptions options, Context context) {
if (CoreUtils.isNullOrEmpty(nextPageLink)) {
return null;
}
validateActiveSinceInput(activeSince, logger);
if (options == null) {
options = new ListMetricSeriesDefinitionOptions();
}
final MetricSeriesQueryOptions metricSeriesQueryOptions = getMetricSeriesQueryOptions(activeSince, options);
PagedResponse res
= service.getMetricSeriesNextSinglePage(nextPageLink, metricSeriesQueryOptions, context);
return MetricSeriesDefinitionTransforms.fromInnerResponse(res);
}
/**
* Get time series data from metric.
*
* Code sample
*
*
* final OffsetDateTime startTime = OffsetDateTime.parse("2020-09-09T00:00:00Z");
* final OffsetDateTime endTime = OffsetDateTime.parse("2020-09-09T12:00:00Z");
*
* metricsAdvisorClient.listMetricSeriesData("metricId",
* Arrays.asList(new DimensionKey(new HashMap<String, String>() {{
* put("Dim1", "value1");
* }})), startTime, endTime)
* .forEach(metricSeriesData -> {
* System.out.println("List of data points for this series:");
* System.out.println(metricSeriesData.getMetricValues());
* System.out.println("Timestamps of the data related to this time series:");
* System.out.println(metricSeriesData.getTimestamps());
* System.out.printf("Series Key:");
* System.out.println(metricSeriesData.getSeriesKey().asMap());
* });
*
*
*
* @param metricId metric unique id.
* @param seriesKeys the series key to filter.
* This enables additional filtering of dimension values being queried.
* For example, let's say we've the dimensions 'category' and 'city',
* so the api can query value of the dimension 'category', with series key as 'city=redmond'.
*
* @param startTime The start time for querying the time series data.
* @param endTime The end time for querying the time series data.
*
* @return A {@link PagedIterable} of the {@link MetricSeriesData metric series data points}.
* @throws IllegalArgumentException thrown if {@code metricId} fail the UUID format validation.
* @throws NullPointerException thrown if the {@code metricId}, {@code startTime} or {@code endTime}
* is null.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable listMetricSeriesData(String metricId, List seriesKeys,
OffsetDateTime startTime, OffsetDateTime endTime) {
return listMetricSeriesData(metricId, seriesKeys, startTime, endTime, Context.NONE);
}
/**
* Get time series data from metric.
*
* Code sample
*
*
* final OffsetDateTime startTime = OffsetDateTime.parse("2020-09-09T00:00:00Z");
* final OffsetDateTime endTime = OffsetDateTime.parse("2020-09-09T12:00:00Z");
* metricsAdvisorClient.listMetricSeriesData("metricId",
* Arrays.asList(new DimensionKey(new HashMap<String, String>() {{
* put("Dim1", "value1");
* }})), startTime, endTime)
* .forEach(metricSeriesData -> {
* System.out.printf("Data feed Id: %s%n", metricSeriesData.getMetricId());
* System.out.printf("Data feed description: %s%n", metricSeriesData.getSeriesKey());
* System.out.printf("Data feed source type: %.2f%n", metricSeriesData.getTimestamps());
* System.out.printf("Data feed creator: %.2f%n", metricSeriesData.getMetricValues());
* });
*
*
*
* @param metricId metric unique id.
* @param seriesKeys the series key to filter.
* This enables additional filtering of dimension values being queried.
* For example, let's say we've the dimensions 'category' and 'city',
* so the api can query value of the dimension 'category', with series key as 'city=redmond'.
*
* @param startTime The start time for querying the time series data.
* @param endTime The end time for querying the time series data.
* @param context Additional context that is passed through the Http pipeline during the service call.
*
* @return A {@link PagedIterable} of the {@link MetricSeriesData metric series data points}.
* @throws IllegalArgumentException thrown if {@code metricId} fail the UUID format validation.
* @throws NullPointerException thrown if the {@code metricId}, {@code startTime} or {@code endTime}
* is null.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable listMetricSeriesData(String metricId, List seriesKeys,
OffsetDateTime startTime, OffsetDateTime endTime, Context context) {
return listMetricSeriesDataSync(metricId, seriesKeys, startTime, endTime, context);
}
private PagedIterable listMetricSeriesDataSync(String metricId, List seriesKeys,
OffsetDateTime startTime, OffsetDateTime endTime, Context context) {
return new PagedIterable<>(
() -> listMetricSeriesDataInternal(metricId, seriesKeys, startTime, endTime, context), null);
}
private PagedResponse listMetricSeriesDataInternal(String metricId, List seriesKeys,
OffsetDateTime startTime, OffsetDateTime endTime, Context context) {
validateMetricSeriesInputs(metricId, seriesKeys, startTime, endTime, logger);
List> dimensionList
= seriesKeys.stream().map(DimensionKey::asMap).collect(Collectors.toList());
final MetricDataQueryOptions metricDataQueryOptions = getMetricDataQueryOptions(startTime, dimensionList);
Response response
= service.getMetricDataWithResponse(UUID.fromString(metricId), metricDataQueryOptions, context);
return MetricSeriesDataTransforms.fromInnerResponse(response);
}
/**
* List the enrichment status for a metric.
*
* Code sample
*
*
* final OffsetDateTime startTime = OffsetDateTime.parse("2020-01-01T00:00:00Z");
* final OffsetDateTime endTime = OffsetDateTime.parse("2020-09-09T00:00:00Z");
* final String metricId = "d3gh4i4-b804-4ab9-a70f-0da0c89cft3l";
*
* metricsAdvisorClient.listMetricEnrichmentStatus(metricId, startTime, endTime)
* .forEach(enrichmentStatus -> {
* System.out.printf("Data Feed Metric enrichment status : %s%n", enrichmentStatus.getStatus());
* System.out.printf("Data Feed Metric enrichment status message: %s%n", enrichmentStatus.getMessage());
* System.out.printf("Data Feed Metric enrichment status data slice timestamp : %s%n",
* enrichmentStatus.getTimestamp());
* });
*
*
*
* @param metricId metric unique id.
* @param startTime The start time for querying the time series data.
* @param endTime The end time for querying the time series data.
* @return the list of enrichment status's for the specified metric.
* @throws IllegalArgumentException thrown if {@code metricId} fail the UUID format validation.
* @throws MetricsAdvisorResponseException thrown if the request is rejected by server.
* @throws NullPointerException thrown if {@code metricId}, {@code startTime} and {@code endTime}
* is null.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable listMetricEnrichmentStatus(String metricId, OffsetDateTime startTime,
OffsetDateTime endTime) {
return listMetricEnrichmentStatus(metricId, startTime, endTime, null, Context.NONE);
}
/**
* List the enrichment status for a metric.
*
* Code sample
*
*
* final OffsetDateTime startTime = OffsetDateTime.parse("2020-01-01T00:00:00Z");
* final OffsetDateTime endTime = OffsetDateTime.parse("2020-09-09T00:00:00Z");
* final String metricId = "d3gh4i4-b804-4ab9-a70f-0da0c89cft3l";
* final ListMetricEnrichmentStatusOptions options = new ListMetricEnrichmentStatusOptions().setMaxPageSize(10);
*
* metricsAdvisorClient.listMetricEnrichmentStatus(metricId, startTime, endTime, options, Context.NONE)
* .forEach(enrichmentStatus -> {
* System.out.printf("Data Feed Metric enrichment status : %s%n", enrichmentStatus.getStatus());
* System.out.printf("Data Feed Metric enrichment status message: %s%n", enrichmentStatus.getMessage());
* System.out.printf("Data Feed Metric enrichment status data slice timestamp : %s%n",
* enrichmentStatus.getTimestamp());
* });
*
*
*
* @param metricId metric unique id.
* @param startTime The start time for querying the time series data.
* @param endTime The end time for querying the time series data.
* @param options the additional configurable options to specify when querying the result.
* @param context Additional context that is passed through the Http pipeline during the service call.
*
* @return the list of enrichment status's for the specified metric.
* @throws IllegalArgumentException thrown if {@code metricId} fail the UUID format validation.
* @throws MetricsAdvisorResponseException thrown if the request is rejected by server.
* @throws NullPointerException thrown if {@code metricId}, {@code startTime} and {@code endTime}
* is null.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable listMetricEnrichmentStatus(String metricId, OffsetDateTime startTime,
OffsetDateTime endTime, ListMetricEnrichmentStatusOptions options, Context context) {
return listMetricEnrichmentStatusSync(metricId, startTime, endTime, options, context);
}
private PagedIterable listMetricEnrichmentStatusSync(String metricId, OffsetDateTime startTime,
OffsetDateTime endTime, ListMetricEnrichmentStatusOptions options, Context context) {
return new PagedIterable<>(
() -> listMetricEnrichmentStatusSinglePageSync(metricId, startTime, endTime, options, context),
continuationToken -> listMetricEnrichmentStatusNextPageSync(continuationToken, startTime, endTime,
context));
}
private PagedResponse listMetricEnrichmentStatusSinglePageSync(String metricId,
OffsetDateTime startTime, OffsetDateTime endTime, ListMetricEnrichmentStatusOptions options, Context context) {
validateMetricEnrichmentStatusInputs(metricId, "'metricId' is required.", startTime, endTime);
if (options == null) {
options = new ListMetricEnrichmentStatusOptions();
}
final EnrichmentStatusQueryOption enrichmentStatusQueryOption
= getEnrichmentStatusQueryOptions(startTime, endTime);
PagedResponse res = service.getEnrichmentStatusByMetricSinglePage(UUID.fromString(metricId),
enrichmentStatusQueryOption, options.getSkip(), options.getMaxPageSize(), context);
return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getValue(),
res.getContinuationToken(), null);
}
private PagedResponse listMetricEnrichmentStatusNextPageSync(String nextPageLink,
OffsetDateTime startTime, OffsetDateTime endTime, Context context) {
if (CoreUtils.isNullOrEmpty(nextPageLink)) {
return null;
}
validateStartEndTime(startTime, endTime);
final EnrichmentStatusQueryOption enrichmentStatusQueryOption
= getEnrichmentStatusQueryOptions(startTime, endTime);
PagedResponse res
= service.getEnrichmentStatusByMetricNextSinglePage(nextPageLink, enrichmentStatusQueryOption, context);
return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getValue(),
res.getContinuationToken(), null);
}
/**
* Given a list of time series keys, retrieve time series version enriched using
* a detection configuration.
*
* Code sample
*
*
* final String detectionConfigurationId = "e87d899d-a5a0-4259-b752-11aea34d5e34";
* final DimensionKey seriesKey = new DimensionKey()
* .put("Dim1", "Common Lime")
* .put("Dim2", "Antelope");
* final OffsetDateTime startTime = OffsetDateTime.parse("2020-08-12T00:00:00Z");
* final OffsetDateTime endTime = OffsetDateTime.parse("2020-09-12T00:00:00Z");
*
* PagedIterable<MetricEnrichedSeriesData> enrichedDataIterable
* = metricsAdvisorClient.listMetricEnrichedSeriesData(detectionConfigurationId,
* Arrays.asList(seriesKey),
* startTime,
* endTime);
*
* for (MetricEnrichedSeriesData enrichedData : enrichedDataIterable) {
* System.out.printf("Series Key %s%n:", enrichedData.getSeriesKey().asMap());
* System.out.println("List of data points for this series");
* System.out.println(enrichedData.getMetricValues());
* System.out.println("Timestamps of the data related to this time series:");
* System.out.println(enrichedData.getTimestamps());
* System.out.println("The expected values of the data points calculated by the smart detector:");
* System.out.println(enrichedData.getExpectedMetricValues());
* System.out.println("The lower boundary values of the data points calculated by smart detector:");
* System.out.println(enrichedData.getLowerBoundaryValues());
* System.out.println("the periods calculated for the data points in the time series:");
* System.out.println(enrichedData.getPeriods());
* }
*
*
*
* @param detectionConfigurationId The id of the configuration used to enrich the time series
* identified by the keys in {@code seriesKeys}.
* @param seriesKeys The time series key list, each key identifies a specific time series.
* @param startTime The start time.
* @param endTime The end time.
* @return The enriched time series.
* @throws IllegalArgumentException thrown if {@code detectionConfigurationId} fail the UUID format validation
* or if {@code seriesKeys} is empty.
* @throws NullPointerException thrown if the {@code detectionConfigurationId}
* or {@code startTime} or {@code endTime} is null.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable listMetricEnrichedSeriesData(String detectionConfigurationId,
List seriesKeys, OffsetDateTime startTime, OffsetDateTime endTime) {
return listMetricEnrichedSeriesDataSync(detectionConfigurationId, seriesKeys, startTime, endTime, Context.NONE);
}
private PagedIterable listMetricEnrichedSeriesDataSync(String detectionConfigurationId,
List seriesKeys, OffsetDateTime startTime, OffsetDateTime endTime, Context context) {
return new PagedIterable<>(() -> listMetricEnrichedSeriesDataInternal(detectionConfigurationId, seriesKeys,
startTime, endTime, context), null);
}
private PagedResponse listMetricEnrichedSeriesDataInternal(
String detectionConfigurationId, List seriesKeys, OffsetDateTime startTime,
OffsetDateTime endTime, Context context) {
validateMetricEnrichedSeriesInputs(detectionConfigurationId, seriesKeys, startTime, endTime, logger);
final List innerSeriesKeys = seriesKeys.stream()
.map(seriesId -> new SeriesIdentity().setDimension(seriesId.asMap()))
.collect(Collectors.toList());
DetectionSeriesQuery query
= new DetectionSeriesQuery().setSeries(innerSeriesKeys).setStartTime(startTime).setEndTime(endTime);
Response res = service.getSeriesByAnomalyDetectionConfigurationWithResponse(
UUID.fromString(detectionConfigurationId), query, context);
return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(),
MetricEnrichedSeriesDataTransformations.fromInnerList(res.getValue()), null, null);
}
/**
* Given a list of time series keys, retrieve time series version enriched using
* a detection configuration.
*
* Code sample
*
*
* final String detectionConfigurationId = "e87d899d-a5a0-4259-b752-11aea34d5e34";
* final DimensionKey seriesKey = new DimensionKey()
* .put("Dim1", "Common Lime")
* .put("Dim2", "Antelope");
* final OffsetDateTime startTime = OffsetDateTime.parse("2020-08-12T00:00:00Z");
* final OffsetDateTime endTime = OffsetDateTime.parse("2020-09-12T00:00:00Z");
*
* PagedIterable<MetricEnrichedSeriesData> enrichedDataIterable
* = metricsAdvisorClient.listMetricEnrichedSeriesData(detectionConfigurationId,
* Arrays.asList(seriesKey),
* startTime,
* endTime);
*
* Stream<PagedResponse<MetricEnrichedSeriesData>> enrichedDataPageStream
* = enrichedDataIterable.streamByPage();
* int[] pageCount = new int[1];
* enrichedDataPageStream.forEach(enrichedDataPage -> {
* System.out.printf("Page: %d%n", pageCount[0]++);
* IterableStream<MetricEnrichedSeriesData> pageElements = enrichedDataPage.getElements();
* for (MetricEnrichedSeriesData enrichedData : pageElements) {
* System.out.printf("Series Key %s%n:", enrichedData.getSeriesKey().asMap());
* System.out.println("List of data points for this series");
* System.out.println(enrichedData.getMetricValues());
* System.out.println("Timestamps of the data related to this time series:");
* System.out.println(enrichedData.getTimestamps());
* System.out.println("The expected values of the data points calculated by the smart detector:");
* System.out.println(enrichedData.getExpectedMetricValues());
* System.out.println("The lower boundary values of the data points calculated by smart detector:");
* System.out.println(enrichedData.getLowerBoundaryValues());
* System.out.println("the periods calculated for the data points in the time series:");
* System.out.println(enrichedData.getPeriods());
* }
* });
*
*
*
* @param detectionConfigurationId The id of the configuration used to enrich the time series
* identified by the keys in {@code seriesKeys}.
* @param seriesKeys The time series key list, each key identifies a specific time series.
* @param startTime The start time of the time range within which the enriched data is returned.
* @param endTime The end time of the time range within which the enriched data is returned.
* @param context Additional context that is passed through the Http pipeline during the service call.
* @return The enriched time series.
* @throws IllegalArgumentException thrown if {@code detectionConfigurationId} fail the UUID format validation
* or if {@code seriesKeys} is empty.
* @throws NullPointerException thrown if the {@code detectionConfigurationId}
* or {@code startTime} or {@code endTime} is null.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable listMetricEnrichedSeriesData(String detectionConfigurationId,
List seriesKeys, OffsetDateTime startTime, OffsetDateTime endTime, Context context) {
return listMetricEnrichedSeriesDataSync(detectionConfigurationId, seriesKeys, startTime, endTime, context);
}
/**
* Fetch the anomalies identified by an anomaly detection configuration.
*
* Code sample
*
*
* final String detectionConfigurationId = "c0f2539f-b804-4ab9-a70f-0da0c89c76d8";
* final OffsetDateTime startTime = OffsetDateTime.parse("2020-09-09T00:00:00Z");
* final OffsetDateTime endTime = OffsetDateTime.parse("2020-09-09T12:00:00Z");
* final ListAnomaliesDetectedFilter filter = new ListAnomaliesDetectedFilter()
* .setSeverityRange(AnomalySeverity.LOW, AnomalySeverity.MEDIUM);
* final ListAnomaliesDetectedOptions options = new ListAnomaliesDetectedOptions()
* .setMaxPageSize(10)
* .setFilter(filter);
* PagedIterable<DataPointAnomaly> anomaliesIterable
* = metricsAdvisorClient.listAnomaliesForDetectionConfig(detectionConfigurationId, startTime, endTime,
* options, Context.NONE);
*
* for (DataPointAnomaly dataPointAnomaly : anomaliesIterable) {
* System.out.printf("DataPointAnomaly AnomalySeverity: %s%n", dataPointAnomaly.getSeverity());
* System.out.printf("Series Key:");
* DimensionKey seriesKey = dataPointAnomaly.getSeriesKey();
* for (Map.Entry<String, String> dimension : seriesKey.asMap().entrySet()) {
* System.out.printf("DimensionName: %s DimensionValue:%s%n",
* dimension.getKey(), dimension.getValue());
* }
* }
*
*
*
* @param detectionConfigurationId The anomaly detection configuration id.
* @param startTime The start time of the time range within which the anomalies were detected.
* @param endTime The end time of the time range within which the anomalies were detected.
* @return The anomalies.
* @throws IllegalArgumentException thrown if {@code detectionConfigurationId} does not conform
* to the UUID format specification
* or {@code options.filter} is used to set severity but either min or max severity is missing.
* @throws NullPointerException thrown if the {@code detectionConfigurationId} or
* {@code startTime} or {@code endTime} is null.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable listAnomaliesForDetectionConfig(String detectionConfigurationId,
OffsetDateTime startTime, OffsetDateTime endTime) {
return listAnomaliesForDetectionConfig(detectionConfigurationId, startTime, endTime, null, Context.NONE);
}
/**
* Fetch the anomalies identified by an anomaly detection configuration.
*
* Code sample
*
*
* final String detectionConfigurationId = "c0f2539f-b804-4ab9-a70f-0da0c89c76d8";
* final OffsetDateTime startTime = OffsetDateTime.parse("2020-09-09T00:00:00Z");
* final OffsetDateTime endTime = OffsetDateTime.parse("2020-09-09T12:00:00Z");
* final ListAnomaliesDetectedFilter filter = new ListAnomaliesDetectedFilter()
* .setSeverityRange(AnomalySeverity.LOW, AnomalySeverity.MEDIUM);
* final ListAnomaliesDetectedOptions options = new ListAnomaliesDetectedOptions()
* .setMaxPageSize(10)
* .setFilter(filter);
* PagedIterable<DataPointAnomaly> anomaliesIterable
* = metricsAdvisorClient.listAnomaliesForDetectionConfig(detectionConfigurationId,
* startTime, endTime, options,
* Context.NONE);
*
* Stream<PagedResponse<DataPointAnomaly>> anomaliesPageStream = anomaliesIterable.streamByPage();
* int[] pageCount = new int[1];
* anomaliesPageStream.forEach(anomaliesPage -> {
* System.out.printf("Page: %d%n", pageCount[0]++);
* IterableStream<DataPointAnomaly> anomaliesPageItems = anomaliesPage.getElements();
* for (DataPointAnomaly dataPointAnomaly : anomaliesPageItems) {
* System.out.printf("DataPoint Anomaly AnomalySeverity: %s%n", dataPointAnomaly.getSeverity());
* System.out.printf("Series Key:");
* DimensionKey seriesKey = dataPointAnomaly.getSeriesKey();
* for (Map.Entry<String, String> dimension : seriesKey.asMap().entrySet()) {
* System.out.printf("DimensionName: %s DimensionValue:%s%n",
* dimension.getKey(), dimension.getValue());
* }
* }
* });
*
*
*
* @param detectionConfigurationId The anomaly detection configuration id.
* @param startTime The start time of the time range within which the anomalies were detected.
* @param endTime The end time of the time range within which the anomalies were detected.
* @param options The additional parameters.
* @param context Additional context that is passed through the Http pipeline during the service call.
* @return The anomalies.
* @throws IllegalArgumentException thrown if {@code detectionConfigurationId} does not conform
* to the UUID format specification
* or {@code options.filter} is used to set severity but either min or max severity is missing.
* @throws NullPointerException thrown if the {@code detectionConfigurationId} or {@code startTime} or
* {@code endTime} is null.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable listAnomaliesForDetectionConfig(String detectionConfigurationId,
OffsetDateTime startTime, OffsetDateTime endTime, ListAnomaliesDetectedOptions options, Context context) {
return listAnomaliesForDetectionConfigSync(detectionConfigurationId, startTime, endTime, options, context);
}
private PagedIterable listAnomaliesForDetectionConfigSync(String detectionConfigurationId,
OffsetDateTime startTime, OffsetDateTime endTime, ListAnomaliesDetectedOptions options, Context context) {
return new PagedIterable<>(
() -> listAnomaliesForDetectionConfigSinglePageSync(detectionConfigurationId, startTime, endTime, options,
context),
continuationToken -> listAnomaliesForDetectionConfigNextPageSync(continuationToken, startTime, endTime,
options, context));
}
private PagedResponse listAnomaliesForDetectionConfigSinglePageSync(
String detectionConfigurationId, OffsetDateTime startTime, OffsetDateTime endTime,
ListAnomaliesDetectedOptions options, Context context) {
validateMetricEnrichmentStatusInputs(detectionConfigurationId, "'detectionConfigurationId' is required.",
startTime, endTime);
DetectionAnomalyResultQuery query
= new DetectionAnomalyResultQuery().setStartTime(startTime).setEndTime(endTime);
options = getListAnomaliesDetectedOptions(options, query, logger);
PagedResponse response = service.getAnomaliesByAnomalyDetectionConfigurationSinglePage(
UUID.fromString(detectionConfigurationId), query, options.getSkip(), options.getMaxPageSize(), context);
return AnomalyTransforms.fromInnerPagedResponse(response);
}
private PagedResponse listAnomaliesForDetectionConfigNextPageSync(String nextPageLink,
OffsetDateTime startTime, OffsetDateTime endTime, ListAnomaliesDetectedOptions options, Context context) {
if (CoreUtils.isNullOrEmpty(nextPageLink)) {
return null;
}
DetectionAnomalyResultQuery query
= new DetectionAnomalyResultQuery().setStartTime(startTime).setEndTime(endTime);
getListAnomaliesDetectedOptions(options, query, logger);
PagedResponse response
= service.getAnomaliesByAnomalyDetectionConfigurationNextSinglePage(nextPageLink, query, context);
return AnomalyTransforms.fromInnerPagedResponse(response);
}
/**
* Fetch the incidents identified by an anomaly detection configuration.
*
* Code sample
*
*
* final String detectionConfigurationId = "c0f2539f-b804-4ab9-a70f-0da0c89c76d8";
* final OffsetDateTime startTime = OffsetDateTime.parse("2020-09-09T00:00:00Z");
* final OffsetDateTime endTime = OffsetDateTime.parse("2020-09-09T12:00:00Z");
*
* PagedIterable<AnomalyIncident> incidentsIterable
* = metricsAdvisorClient.listIncidentsForDetectionConfig(detectionConfigurationId, startTime, endTime);
*
* for (AnomalyIncident anomalyIncident : incidentsIterable) {
* System.out.printf("Data Feed Metric Id: %s%n", anomalyIncident.getMetricId());
* System.out.printf("Detection Configuration Id: %s%n", anomalyIncident.getDetectionConfigurationId());
* System.out.printf("Anomaly Incident Id: %s%n", anomalyIncident.getId());
* System.out.printf("Anomaly Incident Start Time: %s%n", anomalyIncident.getStartTime());
* System.out.printf("Anomaly Incident AnomalySeverity: %s%n", anomalyIncident.getSeverity());
* System.out.printf("Anomaly Incident Status: %s%n", anomalyIncident.getStatus());
* System.out.printf("Root DataFeedDimension Key: %s%n", anomalyIncident.getRootDimensionKey().asMap());
* }
*
*
*
* @param detectionConfigurationId The anomaly detection configuration id.
* @param startTime The start time of the time range within which the incidents were detected.
* @param endTime The end time of the time range within which the incidents were detected.
* @return The incidents.
* @throws IllegalArgumentException thrown if {@code detectionConfigurationId} does not conform
* to the UUID format specification.
* @throws NullPointerException thrown if the {@code detectionConfigurationId} or {@code options}
* or {@code startTime} or {@code endTime} is null.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable listIncidentsForDetectionConfig(String detectionConfigurationId,
OffsetDateTime startTime, OffsetDateTime endTime) {
return listIncidentsForDetectionConfig(detectionConfigurationId, startTime, endTime, null, Context.NONE);
}
/**
* Fetch the incidents identified by an anomaly detection configuration.
*
* Code sample
*
*
* final String detectionConfigurationId = "c0f2539f-b804-4ab9-a70f-0da0c89c76d8";
* final OffsetDateTime startTime = OffsetDateTime.parse("2020-09-09T00:00:00Z");
* final OffsetDateTime endTime = OffsetDateTime.parse("2020-09-09T12:00:00Z");
* final ListIncidentsDetectedOptions options = new ListIncidentsDetectedOptions()
* .setMaxPageSize(1000);
*
* PagedIterable<AnomalyIncident> incidentsIterable
* = metricsAdvisorClient.listIncidentsForDetectionConfig(detectionConfigurationId,
* startTime, endTime, options,
* Context.NONE);
*
* Stream<PagedResponse<AnomalyIncident>> incidentsPageStream = incidentsIterable.streamByPage();
*
* int[] pageCount = new int[1];
* incidentsPageStream.forEach(incidentsPage -> {
* System.out.printf("Page: %d%n", pageCount[0]++);
* IterableStream<AnomalyIncident> pageElements = incidentsPage.getElements();
* for (AnomalyIncident anomalyIncident : pageElements) {
* System.out.printf("Data Feed Metric Id: %s%n", anomalyIncident.getMetricId());
* System.out.printf("Detection Configuration Id: %s%n", anomalyIncident.getDetectionConfigurationId());
* System.out.printf("Anomaly Incident Id: %s%n", anomalyIncident.getId());
* System.out.printf("Anomaly Incident Start Time: %s%n", anomalyIncident.getStartTime());
* System.out.printf("Anomaly Incident AnomalySeverity: %s%n", anomalyIncident.getSeverity());
* System.out.printf("Anomaly Incident Status: %s%n", anomalyIncident.getStatus());
* System.out.printf("Root DataFeedDimension Key:");
* System.out.printf("Root DataFeedDimension Key: %s%n", anomalyIncident.getRootDimensionKey().asMap());
* }
* });
*
*
*
* @param detectionConfigurationId The anomaly detection configuration id.
* @param startTime The start time of the time range within which the incidents were detected.
* @param endTime The end time of the time range within which the incidents were detected.
* @param options The additional parameters.
* @param context Additional context that is passed through the Http pipeline during the service call.
* @return The incidents.
* @throws IllegalArgumentException thrown if {@code detectionConfigurationId} does not conform
* to the UUID format specification.
* @throws NullPointerException thrown if the {@code detectionConfigurationId} or {@code startTime} or
* {@code endTime} is null.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable listIncidentsForDetectionConfig(String detectionConfigurationId,
OffsetDateTime startTime, OffsetDateTime endTime, ListIncidentsDetectedOptions options, Context context) {
return listIncidentsForDetectionConfigSync(detectionConfigurationId, startTime, endTime, options, context);
}
private PagedIterable listIncidentsForDetectionConfigSync(String detectionConfigurationId,
OffsetDateTime startTime, OffsetDateTime endTime, ListIncidentsDetectedOptions options, Context context) {
return new PagedIterable<>(() -> listIncidentsForDetectionConfigSinglePageSync(detectionConfigurationId,
startTime, endTime, options, context),
continuationToken -> listIncidentsForDetectionConfigNextPageSync(continuationToken, context));
}
private PagedResponse listIncidentsForDetectionConfigSinglePageSync(
String detectionConfigurationId, OffsetDateTime startTime, OffsetDateTime endTime,
ListIncidentsDetectedOptions options, Context context) {
validateIncidentsForDetectionConfigInputs(detectionConfigurationId, startTime, endTime);
DetectionIncidentResultQuery query
= new DetectionIncidentResultQuery().setStartTime(startTime).setEndTime(endTime);
options = getListIncidentsDetectedOptions(options, query);
PagedResponse response = service.getIncidentsByAnomalyDetectionConfigurationSinglePage(
UUID.fromString(detectionConfigurationId), query, options.getMaxPageSize(), context);
return IncidentTransforms.fromInnerPagedResponse(response);
}
private PagedResponse listIncidentsForDetectionConfigNextPageSync(String nextPageLink,
Context context) {
if (CoreUtils.isNullOrEmpty(nextPageLink)) {
return null;
}
PagedResponse response
= service.getIncidentsByAnomalyDetectionConfigurationNextSinglePage(nextPageLink, context);
return IncidentTransforms.fromInnerPagedResponse(response);
}
/**
* List the root causes for an incident.
*
* Code sample
*
*
* final String detectionConfigurationId = "c0dddf2539f-b804-4ab9-a70f-0da0c89c76d8";
* final String incidentId = "c5thh0f2539f-b804-4ab9-a70f-0da0c89c456d";
*
* metricsAdvisorClient.listIncidentRootCauses(detectionConfigurationId, incidentId)
* .forEach(incidentRootCause -> {
* System.out.printf("Description: %s%n", incidentRootCause.getDescription());
* System.out.printf("Series Key:");
* System.out.println(incidentRootCause.getSeriesKey().asMap());
* System.out.printf("Confidence for the detected incident root cause %.2f%n",
* incidentRootCause.getContributionScore());
* });
*
*
*
*
* @param detectionConfigurationId anomaly detection configuration unique id.
* @param incidentId the incident for which you want to query root causes for.
*
* @return the list of root causes for that incident.
* @throws IllegalArgumentException thrown if {@code detectionConfigurationId} fail the UUID format validation.
* @throws MetricsAdvisorResponseException thrown if the request is rejected by server.
* @throws NullPointerException thrown if the {@code detectionConfigurationId} or {@code incidentId} is null.
**/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable listIncidentRootCauses(String detectionConfigurationId, String incidentId) {
return listIncidentRootCauses(detectionConfigurationId, incidentId, Context.NONE);
}
/**
* List the root causes for an incident.
*
* Code sample
*
*
* final String detectionConfigurationId = "c0dddf2539f-b804-4ab9-a70f-0da0c89c76d8";
* final String incidentId = "c5thh0f2539f-b804-4ab9-a70f-0da0c89c456d";
*
* PagedIterable<IncidentRootCause> rootCauseIterable
* = metricsAdvisorClient.listIncidentRootCauses(detectionConfigurationId, incidentId, Context.NONE);
* Stream<PagedResponse<IncidentRootCause>> rootCausePageIterable = rootCauseIterable.streamByPage();
* rootCausePageIterable.forEach(response -> {
* System.out.printf("Response StatusCode: %s%n", response.getStatusCode());
* IterableStream<IncidentRootCause> pageElements = response.getElements();
* for (IncidentRootCause incidentRootCause : pageElements) {
* System.out.printf("Description: %s%n", incidentRootCause.getDescription());
* System.out.printf("Series Key:");
* System.out.println(incidentRootCause.getSeriesKey().asMap());
* System.out.printf("Confidence for the detected incident root cause %.2f%n",
* incidentRootCause.getContributionScore());
* }
* });
*
*
*
*
* @param detectionConfigurationId anomaly detection configuration unique id.
* @param incidentId the incident for which you want to query root causes for.
* @param context Additional context that is passed through the Http pipeline during the service call.
*
* @return the list of root causes for that incident.
* @throws IllegalArgumentException thrown if {@code detectionConfigurationId} fail the UUID format validation.
* @throws MetricsAdvisorResponseException thrown if the request is rejected by server.
* @throws NullPointerException thrown if the {@code detectionConfigurationId} or {@code incidentId} is null.
**/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable listIncidentRootCauses(String detectionConfigurationId, String incidentId,
Context context) {
return listIncidentRootCausesSync(detectionConfigurationId, incidentId, context);
}
private PagedIterable listIncidentRootCausesSync(String detectionConfigurationId,
String incidentId, Context context) {
Objects.requireNonNull(detectionConfigurationId, "'detectionConfigurationId' is required.");
Objects.requireNonNull(incidentId, "'incidentId' is required.");
AnomalyIncident anomalyIncident = new AnomalyIncident();
IncidentHelper.setId(anomalyIncident, incidentId);
IncidentHelper.setDetectionConfigurationId(anomalyIncident, detectionConfigurationId);
return new PagedIterable<>(() -> listIncidentRootCausesInternal(anomalyIncident, context), null);
}
/**
* List the root causes for an anomalyIncident.
*
* Code sample
*
*
* final String detectionConfigurationId = "c0f2539f-b804-4ab9-a70f-0da0c89c76d8";
* final OffsetDateTime startTime = OffsetDateTime.parse("2020-01-01T00:00:00Z");
* final OffsetDateTime endTime = OffsetDateTime.parse("2020-09-09T00:00:00Z");
*
* metricsAdvisorClient.listIncidentsForDetectionConfig(detectionConfigurationId, startTime, endTime)
* .forEach(incident -> {
* metricsAdvisorClient.listIncidentRootCauses(incident)
* .forEach(incidentRootCause -> {
* System.out.printf("Description: %s%n", incidentRootCause.getDescription());
* System.out.printf("Series Key:");
* System.out.println(incidentRootCause.getSeriesKey().asMap());
* System.out.printf("Confidence for the detected incident root cause %.2f%n",
* incidentRootCause.getContributionScore());
* });
* });
*
*
*
* @param anomalyIncident the anomalyIncident for which you want to query root causes for.
*
* @return the list of root causes for that anomalyIncident.
* @throws IllegalArgumentException thrown if {@code detectionConfigurationId} fail the UUID format validation.
* @throws MetricsAdvisorResponseException thrown if the request is rejected by server.
* @throws NullPointerException thrown if the {@code detectionConfigurationId} or {@code incidentId} is null.
**/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable listIncidentRootCauses(AnomalyIncident anomalyIncident) {
return listIncidentRootCausesSync(anomalyIncident, Context.NONE);
}
private PagedIterable listIncidentRootCausesSync(AnomalyIncident anomalyIncident,
Context context) {
return new PagedIterable<>(() -> listIncidentRootCausesInternal(anomalyIncident, context), null);
}
private PagedResponse listIncidentRootCausesInternal(AnomalyIncident anomalyIncident,
Context context) {
validateAnomalyIncidentRootCausesInputs(anomalyIncident, logger);
Response res = service.getRootCauseOfIncidentByAnomalyDetectionConfigurationWithResponse(
UUID.fromString(anomalyIncident.getDetectionConfigurationId()), anomalyIncident.getId(), context);
return IncidentRootCauseTransforms.fromInnerResponse(res);
}
/**
* Fetch dimension values that have anomalies.
*
* Code sample
*
*
* final String detectionConfigurationId = "c0f2539f-b804-4ab9-a70f-0da0c89c76d8";
* final String dimensionName = "Dim1";
* final OffsetDateTime startTime = OffsetDateTime.parse("2020-01-01T00:00:00Z");
* final OffsetDateTime endTime = OffsetDateTime.parse("2020-09-09T00:00:00Z");
*
* PagedIterable<String> dimensionValueIterable
* = metricsAdvisorClient.listAnomalyDimensionValues(detectionConfigurationId,
* dimensionName,
* startTime, endTime);
*
* for (String dimensionValue : dimensionValueIterable) {
* System.out.printf("DataFeedDimension Value: %s%n", dimensionValue);
* }
*
*
*
* @param detectionConfigurationId Identifies the configuration used to detect the anomalies.
* @param dimensionName The dimension name to retrieve the values for.
* @param startTime The start time of the time range within which the anomalies were identified.
* @param endTime The end time of the time range within which the anomalies were identified.
* @return The dimension values with anomalies.
* @throws IllegalArgumentException thrown if {@code detectionConfigurationId} does not conform
* to the UUID format specification.
* @throws NullPointerException thrown if the {@code detectionConfigurationId} or {@code dimensionName}
* or {@code startTime} or {@code endTime} is null.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable listAnomalyDimensionValues(String detectionConfigurationId, String dimensionName,
OffsetDateTime startTime, OffsetDateTime endTime) {
return listAnomalyDimensionValues(detectionConfigurationId, dimensionName, startTime, endTime, null,
Context.NONE);
}
/**
* Fetch dimension values that have anomalies.
*
* Code sample
*
*
* final String detectionConfigurationId = "c0f2539f-b804-4ab9-a70f-0da0c89c76d8";
* final String dimensionName = "Dim1";
* final OffsetDateTime startTime = OffsetDateTime.parse("2020-01-01T00:00:00Z");
* final OffsetDateTime endTime = OffsetDateTime.parse("2020-09-09T00:00:00Z");
* final ListAnomalyDimensionValuesOptions options
* = new ListAnomalyDimensionValuesOptions()
* .setMaxPageSize(10);
*
* PagedIterable<String> dimensionValueIterable
* = metricsAdvisorClient.listAnomalyDimensionValues(detectionConfigurationId,
* dimensionName,
* startTime, endTime, options,
* Context.NONE);
*
* Stream<PagedResponse<String>> dimensionValuePageStream = dimensionValueIterable.streamByPage();
* int[] pageCount = new int[1];
* dimensionValuePageStream.forEach(dimensionValuePage -> {
* System.out.printf("Page: %d%n", pageCount[0]++);
* IterableStream<String> dimensionValuePageItems = dimensionValuePage.getElements();
* for (String dimensionValue : dimensionValuePageItems) {
* System.out.printf("DataFeedDimension Value: %s%n", dimensionValue);
* }
* });
*
*
*
* @param detectionConfigurationId Identifies the configuration used to detect the anomalies.
* @param dimensionName The dimension name to retrieve the values for.
* @param startTime The start time of the time range within which the anomalies were identified.
* @param endTime The end time of the time range within which the anomalies were identified.
* @param options The additional parameters.
* @param context Additional context that is passed through the Http pipeline during the service call.
*
* @return The dimension values with anomalies.
* @throws IllegalArgumentException thrown if {@code detectionConfigurationId} does not conform
* to the UUID format specification.
* @throws NullPointerException thrown if the {@code detectionConfigurationId} or {@code dimensionName}
* or {@code startTime} or {@code endTime} is null.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable listAnomalyDimensionValues(String detectionConfigurationId, String dimensionName,
OffsetDateTime startTime, OffsetDateTime endTime, ListAnomalyDimensionValuesOptions options, Context context) {
return listAnomalyDimensionValuesSync(detectionConfigurationId, dimensionName, startTime, endTime, options,
context);
}
private PagedIterable listAnomalyDimensionValuesSync(String detectionConfigurationId, String dimensionName,
OffsetDateTime startTime, OffsetDateTime endTime, ListAnomalyDimensionValuesOptions options, Context context) {
return new PagedIterable<>(
() -> listAnomalyDimensionValuesSinglePageSync(detectionConfigurationId, dimensionName, startTime, endTime,
options, context),
continuationToken -> listAnomalyDimensionValuesNextPageSync(continuationToken, dimensionName, startTime,
endTime, options, context));
}
private PagedResponse listAnomalyDimensionValuesSinglePageSync(String detectionConfigurationId,
String dimensionName, OffsetDateTime startTime, OffsetDateTime endTime,
ListAnomalyDimensionValuesOptions options, Context context) {
validateAnomalyDimensionValuesInputs(detectionConfigurationId, dimensionName, startTime, endTime);
AnomalyDimensionQuery query = new AnomalyDimensionQuery();
query.setDimensionName(dimensionName);
query.setStartTime(startTime);
query.setEndTime(endTime);
options = getListAnomalyDimensionValuesOptions(options, query);
return service.getDimensionOfAnomaliesByAnomalyDetectionConfigurationSinglePage(
UUID.fromString(detectionConfigurationId), query, options.getSkip(), options.getMaxPageSize(), context);
}
private PagedResponse listAnomalyDimensionValuesNextPageSync(String nextPageLink, String dimensionName,
OffsetDateTime startTime, OffsetDateTime endTime, ListAnomalyDimensionValuesOptions options, Context context) {
if (CoreUtils.isNullOrEmpty(nextPageLink)) {
return null;
}
AnomalyDimensionQuery query = new AnomalyDimensionQuery();
query.setDimensionName(dimensionName);
query.setStartTime(startTime);
query.setEndTime(endTime);
getListAnomalyDimensionValuesOptions(options, query);
return service.getDimensionOfAnomaliesByAnomalyDetectionConfigurationNextSinglePage(nextPageLink, query,
context);
}
/**
* Fetch the alerts triggered by an anomaly alert configuration.
*
* Code sample
*
*
* final String alertConfigurationId = "ff3014a0-bbbb-41ec-a637-677e77b81299";
* final OffsetDateTime startTime = OffsetDateTime.parse("2020-01-01T00:00:00Z");
* final OffsetDateTime endTime = OffsetDateTime.parse("2020-09-09T00:00:00Z");
*
* PagedIterable<AnomalyAlert> alertsIterable
* = metricsAdvisorClient.listAlerts(alertConfigurationId, startTime, endTime);
*
* for (AnomalyAlert anomalyAlert : alertsIterable) {
* System.out.printf("Anomaly Alert Id: %s%n", anomalyAlert.getId());
* System.out.printf("Created Time: %s%n", anomalyAlert.getCreatedTime());
* System.out.printf("Modified Time: %s%n", anomalyAlert.getModifiedTime());
* }
*
*
*
* @param alertConfigurationId The anomaly alert configuration id.
* @param startTime The start time of the time range within which the alerts were triggered.
* @param endTime The end time of the time range within which the alerts were triggered.
* @return The alerts.
* @throws IllegalArgumentException thrown if {@code alertConfigurationId} does not conform
* to the UUID format specification.
* @throws NullPointerException thrown if the {@code alertConfigurationId}
* or {@code startTime} or {@code endTime} is null.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable listAlerts(String alertConfigurationId, OffsetDateTime startTime,
OffsetDateTime endTime) {
return listAlerts(alertConfigurationId, startTime, endTime, null, Context.NONE);
}
/**
* Fetch the alerts triggered by an anomaly alert configuration.
*
* Code sample
*
*
* final String alertConfigurationId = "ff3014a0-bbbb-41ec-a637-677e77b81299";
* final OffsetDateTime startTime = OffsetDateTime.parse("2020-01-01T00:00:00Z");
* final OffsetDateTime endTime = OffsetDateTime.parse("2020-09-09T00:00:00Z");
* final AlertQueryTimeMode timeMode = AlertQueryTimeMode.ANOMALY_TIME;
* final ListAlertOptions options = new ListAlertOptions()
* .setAlertQueryTimeMode(timeMode)
* .setMaxPageSize(10);
*
* PagedIterable<AnomalyAlert> alertsIterable
* = metricsAdvisorClient.listAlerts(alertConfigurationId, startTime, endTime, options, Context.NONE);
*
* Stream<PagedResponse<AnomalyAlert>> alertsPageStream = alertsIterable.streamByPage();
* int[] pageCount = new int[1];
* alertsPageStream.forEach(alertsPage -> {
* System.out.printf("Page: %d%n", pageCount[0]++);
* IterableStream<AnomalyAlert> alertsPageItems = alertsPage.getElements();
* for (AnomalyAlert anomalyAlert : alertsPageItems) {
* System.out.printf("AnomalyAlert Id: %s%n", anomalyAlert.getId());
* System.out.printf("Created Time: %s%n", anomalyAlert.getCreatedTime());
* System.out.printf("Modified Time: %s%n", anomalyAlert.getModifiedTime());
* }
* });
*
*
*
* @param alertConfigurationId The anomaly alert configuration id.
* @param startTime The start time of the time range within which the alerts were triggered.
* @param endTime The end time of the time range within which the alerts were triggered.
* @param options The additional parameters.
* @param context Additional context that is passed through the Http pipeline during the service call.
*
* @return The alerts.
* @throws IllegalArgumentException thrown if {@code alertConfigurationId} does not conform
* to the UUID format specification.
* @throws NullPointerException thrown if the {@code alertConfigurationId}
* or {@code startTime} or {@code endTime} is null.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable listAlerts(String alertConfigurationId, OffsetDateTime startTime,
OffsetDateTime endTime, ListAlertOptions options, Context context) {
return listAlertsSync(alertConfigurationId, startTime, endTime, options, context);
}
private PagedIterable listAlertsSync(String alertConfigurationId, OffsetDateTime startTime,
OffsetDateTime endTime, ListAlertOptions options, Context context) {
return new PagedIterable<>(
() -> listAlertsSinglePageSync(alertConfigurationId, startTime, endTime, options, context),
continuationToken -> listAlertsNextPageSync(continuationToken, startTime, endTime, options, context));
}
private PagedResponse listAlertsSinglePageSync(String alertConfigurationId, OffsetDateTime startTime,
OffsetDateTime endTime, ListAlertOptions options, Context context) {
validateListAlertsInputs(alertConfigurationId, startTime, endTime);
if (options == null) {
options = new ListAlertOptions();
}
AlertingResultQuery query = new AlertingResultQuery();
query.setStartTime(startTime);
query.setEndTime(endTime);
query.setTimeMode(TimeMode.fromString(toStringOrNull(options.getTimeMode())));
return service.getAlertsByAnomalyAlertingConfigurationSinglePage(UUID.fromString(alertConfigurationId), query,
options.getSkip(), options.getMaxPageSize(), context);
}
private PagedResponse listAlertsNextPageSync(String nextPageLink, OffsetDateTime startTime,
OffsetDateTime endTime, ListAlertOptions options, Context context) {
if (CoreUtils.isNullOrEmpty(nextPageLink)) {
return null;
}
AlertingResultQuery query = new AlertingResultQuery();
query.setStartTime(startTime);
query.setEndTime(endTime);
query.setTimeMode(TimeMode.fromString(toStringOrNull(options.getTimeMode())));
return service.getAlertsByAnomalyAlertingConfigurationNextSinglePage(nextPageLink, query, context);
}
/**
* Fetch the anomalies in an alert.
*
* Code sample
*
*
* final String alertConfigurationId = "ff3014a0-bbbb-41ec-a637-677e77b81299";
* final String alertId = "1746b031c00";
* PagedIterable<DataPointAnomaly> anomaliesIterable = metricsAdvisorClient.listAnomaliesForAlert(
* alertConfigurationId,
* alertId
* );
*
* for (DataPointAnomaly dataPointAnomaly : anomaliesIterable) {
* System.out.printf("Data Feed Metric Id: %s%n", dataPointAnomaly.getMetricId());
* System.out.printf("Detection Configuration Id: %s%n", dataPointAnomaly.getDetectionConfigurationId());
* System.out.printf("DataPoint Anomaly Created Time: %s%n", dataPointAnomaly.getCreatedTime());
* System.out.printf("DataPoint Anomaly Modified Time: %s%n", dataPointAnomaly.getModifiedTime());
* System.out.printf("DataPoint Anomaly AnomalySeverity: %s%n", dataPointAnomaly.getSeverity());
* System.out.printf("DataPoint Anomaly Status: %s%n", dataPointAnomaly.getStatus());
* System.out.printf("Series Key:");
* System.out.println(dataPointAnomaly.getSeriesKey().asMap());
* }
*
*
*
* @param alertConfigurationId The anomaly alert configuration id.
* @param alertId The alert id.
* @return The anomalies.
* @throws IllegalArgumentException thrown if {@code alertConfigurationId} or {@code alertId} does not
* conform to the UUID format specification.
* @throws NullPointerException thrown if the {@code alertConfigurationId} or {@code alertId} is null.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable listAnomaliesForAlert(String alertConfigurationId, String alertId) {
return listAnomaliesForAlert(alertConfigurationId, alertId, null, Context.NONE);
}
/**
* Fetch the anomalies in an alert.
*
* Code sample
*
*
* final String alertConfigurationId = "ff3014a0-bbbb-41ec-a637-677e77b81299";
* final String alertId = "1746b031c00";
* final ListAnomaliesAlertedOptions options = new ListAnomaliesAlertedOptions()
* .setMaxPageSize(10);
* PagedIterable<DataPointAnomaly> anomaliesIterable = metricsAdvisorClient.listAnomaliesForAlert(
* alertConfigurationId,
* alertId,
* options,
* Context.NONE);
*
* Stream<PagedResponse<DataPointAnomaly>> anomaliesPageStream = anomaliesIterable.streamByPage();
* int[] pageCount = new int[1];
* anomaliesPageStream.forEach(anomaliesPage -> {
* System.out.printf("Page: %d%n", pageCount[0]++);
* IterableStream<DataPointAnomaly> anomaliesPageItems = anomaliesPage.getElements();
* for (DataPointAnomaly dataPointAnomaly : anomaliesPageItems) {
* System.out.printf("Data Feed Metric Id: %s%n", dataPointAnomaly.getMetricId());
* System.out.printf("Detection Configuration Id: %s%n", dataPointAnomaly.getDetectionConfigurationId());
* System.out.printf("DataPoint Anomaly Created Time: %s%n", dataPointAnomaly.getCreatedTime());
* System.out.printf("DataPoint Anomaly Modified Time: %s%n", dataPointAnomaly.getModifiedTime());
* System.out.printf("DataPoint Anomaly AnomalySeverity: %s%n", dataPointAnomaly.getSeverity());
* System.out.printf("DataPoint Anomaly Status: %s%n", dataPointAnomaly.getStatus());
* System.out.printf("Series Key:");
* System.out.println(dataPointAnomaly.getSeriesKey().asMap());
* }
* });
*
*
*
* @param alertConfigurationId The anomaly alert configuration id.
* @param alertId The alert id.
* @param options The additional parameters.
* @param context Additional context that is passed through the Http pipeline during the service call.
*
* @return The anomalies.
* @throws IllegalArgumentException thrown if {@code alertConfigurationId} or {@code alertId} does not
* conform to the UUID format specification.
* @throws NullPointerException thrown if the {@code alertConfigurationId} or {@code alertId} is null.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable listAnomaliesForAlert(String alertConfigurationId, String alertId,
ListAnomaliesAlertedOptions options, Context context) {
return listAnomaliesForAlertSync(alertConfigurationId, alertId, options, context);
}
private PagedIterable listAnomaliesForAlertSync(String alertConfigurationId, String alertId,
ListAnomaliesAlertedOptions options, Context context) {
return new PagedIterable<>(
() -> listAnomaliesForAlertSinglePageSync(alertConfigurationId, alertId, options, context),
continuationToken -> listAnomaliesForAlertNextPageSync(continuationToken, context));
}
private PagedResponse listAnomaliesForAlertSinglePageSync(String alertConfigurationId,
String alertId, ListAnomaliesAlertedOptions options, Context context) {
validateListAnomaliesInputs(alertConfigurationId, alertId);
PagedResponse response = service.getAnomaliesFromAlertByAnomalyAlertingConfigurationSinglePage(
UUID.fromString(alertConfigurationId), alertId, options == null ? null : options.getSkip(),
options == null ? null : options.getMaxPageSize(), context);
return AnomalyTransforms.fromInnerPagedResponse(response);
}
private PagedResponse listAnomaliesForAlertNextPageSync(String nextPageLink, Context context) {
if (CoreUtils.isNullOrEmpty(nextPageLink)) {
return null;
}
PagedResponse response
= service.getAnomaliesFromAlertByAnomalyAlertingConfigurationNextSinglePage(nextPageLink, context);
return AnomalyTransforms.fromInnerPagedResponse(response);
}
/**
* Fetch the incidents in an alert.
*
* Code sample
*
*
* final String alertConfigurationId = "ff3014a0-bbbb-41ec-a637-677e77b81299";
* final String alertId = "1746b031c00";
*
* PagedIterable<AnomalyIncident> incidentsIterable = metricsAdvisorClient.listIncidentsForAlert(
* alertConfigurationId,
* alertId);
*
* Stream<PagedResponse<AnomalyIncident>> incidentsPageStream = incidentsIterable.streamByPage();
* int[] pageCount = new int[1];
* incidentsPageStream.forEach(incidentsPage -> {
* System.out.printf("Page: %d%n", pageCount[0]++);
* IterableStream<AnomalyIncident> incidentsPageItems = incidentsPage.getElements();
* for (AnomalyIncident anomalyIncident : incidentsPageItems) {
* System.out.printf("Data Feed Metric Id: %s%n", anomalyIncident.getMetricId());
* System.out.printf("Detection Configuration Id: %s%n", anomalyIncident.getDetectionConfigurationId());
* System.out.printf("Anomaly Incident Id: %s%n", anomalyIncident.getId());
* System.out.printf("Anomaly Incident Start Time: %s%n", anomalyIncident.getStartTime());
* System.out.printf("Anomaly Incident AnomalySeverity: %s%n", anomalyIncident.getSeverity());
* System.out.printf("Anomaly Incident Status: %s%n", anomalyIncident.getStatus());
* System.out.printf("Root DataFeedDimension Key:");
* DimensionKey rootDimension = anomalyIncident.getRootDimensionKey();
* for (Map.Entry<String, String> dimension : rootDimension.asMap().entrySet()) {
* System.out.printf("DimensionKey: %s DimensionValue:%s%n",
* dimension.getKey(), dimension.getValue());
* }
* }
* });
*
*
*
* @param alertConfigurationId The anomaly alert configuration id.
* @param alertId The alert id.
*
* @return The incidents.
* @throws IllegalArgumentException thrown if {@code alertConfigurationId} or {@code alertId} does not
* conform to the UUID format specification.
* @throws NullPointerException thrown if the {@code alertConfigurationId} or {@code alertId} is null.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable listIncidentsForAlert(String alertConfigurationId, String alertId) {
return this.listIncidentsForAlert(alertConfigurationId, alertId, null, Context.NONE);
}
/**
* Fetch the incidents in an alert.
*
* Code sample
*
*
* final String alertConfigurationId = "ff3014a0-bbbb-41ec-a637-677e77b81299";
* final String alertId = "1746b031c00";
* final ListIncidentsAlertedOptions options = new ListIncidentsAlertedOptions()
* .setMaxPageSize(10);
*
* PagedIterable<AnomalyIncident> incidentsIterable = metricsAdvisorClient.listIncidentsForAlert(
* alertConfigurationId,
* alertId,
* options,
* Context.NONE);
*
* Stream<PagedResponse<AnomalyIncident>> incidentsPageStream = incidentsIterable.streamByPage();
* int[] pageCount = new int[1];
* incidentsPageStream.forEach(incidentsPage -> {
* System.out.printf("Page: %d%n", pageCount[0]++);
* IterableStream<AnomalyIncident> incidentsPageItems = incidentsPage.getElements();
* for (AnomalyIncident anomalyIncident : incidentsPageItems) {
* System.out.printf("Data Feed Metric Id: %s%n", anomalyIncident.getMetricId());
* System.out.printf("Detection Configuration Id: %s%n", anomalyIncident.getDetectionConfigurationId());
* System.out.printf("Anomaly Incident Id: %s%n", anomalyIncident.getId());
* System.out.printf("Anomaly Incident Start Time: %s%n", anomalyIncident.getStartTime());
* System.out.printf("Anomaly Incident AnomalySeverity: %s%n", anomalyIncident.getSeverity());
* System.out.printf("Anomaly Incident Status: %s%n", anomalyIncident.getStatus());
* System.out.printf("Root DataFeedDimension Key:");
* DimensionKey rootDimension = anomalyIncident.getRootDimensionKey();
* for (Map.Entry<String, String> dimension : rootDimension.asMap().entrySet()) {
* System.out.printf("DimensionKey: %s DimensionValue:%s%n",
* dimension.getKey(), dimension.getValue());
* }
* }
* });
*
*
*
* @param alertConfigurationId The anomaly alert configuration id.
* @param alertId The alert id.
* @param options The additional parameters.
* @param context Additional context that is passed through the Http pipeline during the service call.
*
* @return The incidents.
* @throws IllegalArgumentException thrown if {@code alertConfigurationId} or {@code alertId} does not
* conform to the UUID format specification.
* @throws NullPointerException thrown if the {@code alertConfigurationId} or {@code alertId} is null.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable listIncidentsForAlert(String alertConfigurationId, String alertId,
ListIncidentsAlertedOptions options, Context context) {
return listIncidentsForAlertSync(alertConfigurationId, alertId, options, context);
}
private PagedIterable listIncidentsForAlertSync(String alertConfigurationId, String alertId,
ListIncidentsAlertedOptions options, Context context) {
return new PagedIterable<>(
() -> listIncidentsForAlertSinglePageSync(alertConfigurationId, alertId, options, context),
continuationToken -> listIncidentsForAlertNextPageSync(continuationToken, context));
}
private PagedResponse listIncidentsForAlertSinglePageSync(String alertConfigurationId,
String alertId, ListIncidentsAlertedOptions options, Context context) {
validateListAnomaliesInputs(alertConfigurationId, alertId);
PagedResponse response = service.getIncidentsFromAlertByAnomalyAlertingConfigurationSinglePage(
UUID.fromString(alertConfigurationId), alertId, options == null ? null : options.getSkip(),
options == null ? null : options.getMaxPageSize(), context);
return IncidentTransforms.fromInnerPagedResponse(response);
}
private PagedResponse listIncidentsForAlertNextPageSync(String nextPageLink, Context context) {
if (CoreUtils.isNullOrEmpty(nextPageLink)) {
return null;
}
PagedResponse response
= service.getIncidentsFromAlertByAnomalyAlertingConfigurationNextSinglePage(nextPageLink, context);
return IncidentTransforms.fromInnerPagedResponse(response);
}
/**
* Create a new metric feedback.
*
* Code sample
*
*
* final String metricId = "d3gh4i4-b804-4ab9-a70f-0da0c89cft3l";
* final OffsetDateTime startTime = OffsetDateTime.parse("2020-01-01T00:00:00Z");
* final OffsetDateTime endTime = OffsetDateTime.parse("2020-09-09T00:00:00Z");
* final MetricChangePointFeedback metricChangePointFeedback
* = new MetricChangePointFeedback(startTime, endTime, ChangePointValue.AUTO_DETECT);
*
* final MetricFeedback metricFeedback
* = metricsAdvisorClient.addFeedback(metricId, metricChangePointFeedback);
*
* MetricChangePointFeedback createdMetricChangePointFeedback = (MetricChangePointFeedback) metricFeedback;
* System.out.printf("Data Feed Metric feedback Id: %s%n", createdMetricChangePointFeedback.getId());
* System.out.printf("Data Feed Metric feedback change point value: %s%n",
* createdMetricChangePointFeedback.getChangePointValue().toString());
* System.out.printf("Data Feed Metric feedback start time: %s%n",
* createdMetricChangePointFeedback.getStartTime());
* System.out.printf("Data Feed Metric feedback end time: %s%n",
* createdMetricChangePointFeedback.getEndTime());
*
*
*
* @param metricId the unique id for which the feedback needs to be submitted.
* @param metricFeedback the actual metric feedback.
*
* @return the created {@link MetricFeedback metric feedback}.
* @throws NullPointerException If {@code metricId}, {@code metricFeedback.dimensionFilter} is null.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public MetricFeedback addFeedback(String metricId, MetricFeedback metricFeedback) {
return addFeedbackWithResponse(metricId, metricFeedback, Context.NONE).getValue();
}
/**
* Create a new metric feedback.
*
* Code sample
*
*
* final String metricId = "d3gh4i4-b804-4ab9-a70f-0da0c89cft3l";
* final OffsetDateTime startTime = OffsetDateTime.parse("2020-01-01T00:00:00Z");
* final OffsetDateTime endTime = OffsetDateTime.parse("2020-09-09T00:00:00Z");
* final MetricChangePointFeedback metricChangePointFeedback
* = new MetricChangePointFeedback(startTime, endTime, ChangePointValue.AUTO_DETECT);
*
* final Response<MetricFeedback> metricFeedbackResponse
* = metricsAdvisorClient.addFeedbackWithResponse(metricId, metricChangePointFeedback, Context.NONE);
*
* System.out.printf("Data Feed Metric feedback creation operation status %s%n",
* metricFeedbackResponse.getStatusCode());
* MetricChangePointFeedback createdMetricChangePointFeedback
* = (MetricChangePointFeedback) metricFeedbackResponse.getValue();
* System.out.printf("Data Feed Metric feedback Id: %s%n", createdMetricChangePointFeedback.getId());
* System.out.printf("Data Feed Metric feedback change point value: %s%n",
* createdMetricChangePointFeedback.getChangePointValue().toString());
* System.out.printf("Data Feed Metric feedback start time: %s%n",
* createdMetricChangePointFeedback.getStartTime());
* System.out.printf("Data Feed Metric feedback end time: %s%n",
* createdMetricChangePointFeedback.getEndTime());
* System.out.printf("Data Feed Metric feedback associated dimension filter: %s%n",
* createdMetricChangePointFeedback.getDimensionFilter().asMap());
*
*
*
* @param metricId the unique id for which the feedback needs to be submitted.
* @param metricFeedback the actual metric feedback.
* @param context Additional context that is passed through the HTTP pipeline during the service call.
*
* @return A {@link Response} containing the created {@link MetricFeedback metric feedback}.
* @throws NullPointerException If {@code metricId}, {@code metricFeedback.dimensionFilter} is null.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response addFeedbackWithResponse(String metricId, MetricFeedback metricFeedback,
Context context) {
return addFeedbackWithResponseSync(metricId, metricFeedback, context);
}
private Response addFeedbackWithResponseSync(String metricId, MetricFeedback metricFeedback,
Context context) {
validateAddFeedbackInputs(metricId, metricFeedback);
com.azure.ai.metricsadvisor.implementation.models.MetricFeedback innerMetricFeedback;
if (metricFeedback instanceof MetricAnomalyFeedback) {
MetricAnomalyFeedback metricAnomalyFeedback = (MetricAnomalyFeedback) metricFeedback;
Objects.requireNonNull(metricAnomalyFeedback.getStartTime(), "'metricFeedback.startTime' is required.");
Objects.requireNonNull(metricAnomalyFeedback.getEndTime(), "'metricFeedback.endTime' is required.");
Objects.requireNonNull(metricAnomalyFeedback.getAnomalyValue(),
"'metricFeedback.anomalyValue' is required.");
AnomalyFeedback innerAnomalyFeedback
= new AnomalyFeedback().setStartTime(metricAnomalyFeedback.getStartTime())
.setEndTime(metricAnomalyFeedback.getEndTime())
.setValue(new AnomalyFeedbackValue().setAnomalyValue(metricAnomalyFeedback.getAnomalyValue()));
if (metricAnomalyFeedback.getDetectionConfiguration() != null) {
innerAnomalyFeedback
.setAnomalyDetectionConfigurationId(
UUID.fromString(metricAnomalyFeedback.getDetectionConfiguration().getId()))
.setAnomalyDetectionConfigurationSnapshot(DetectionConfigurationTransforms.toInnerForCreate(logger,
metricId, metricAnomalyFeedback.getDetectionConfiguration()));
}
innerMetricFeedback = innerAnomalyFeedback.setMetricId(UUID.fromString(metricId))
.setDimensionFilter(
new FeedbackDimensionFilter().setDimension(metricAnomalyFeedback.getDimensionFilter().asMap()));
} else if (metricFeedback instanceof MetricChangePointFeedback) {
MetricChangePointFeedback metricChangePointFeedback = (MetricChangePointFeedback) metricFeedback;
Objects.requireNonNull(metricChangePointFeedback.getStartTime(), "'metricFeedback.startTime' is required.");
Objects.requireNonNull(metricChangePointFeedback.getEndTime(), "'metricFeedback.endTime' is required.");
Objects.requireNonNull(metricChangePointFeedback.getChangePointValue(),
"'metricFeedback.changePointValue' is required.");
innerMetricFeedback = new ChangePointFeedback().setStartTime(metricChangePointFeedback.getStartTime())
.setEndTime(metricChangePointFeedback.getEndTime())
.setValue(
new ChangePointFeedbackValue().setChangePointValue(metricChangePointFeedback.getChangePointValue()))
.setMetricId(UUID.fromString(metricId))
.setDimensionFilter(
new FeedbackDimensionFilter().setDimension(metricChangePointFeedback.getDimensionFilter().asMap()));
} else if (metricFeedback instanceof MetricPeriodFeedback) {
MetricPeriodFeedback metricPeriodFeedback = (MetricPeriodFeedback) metricFeedback;
Objects.requireNonNull(metricPeriodFeedback.getPeriodType(), "'metricFeedback.periodType' is required.");
Objects.requireNonNull(metricPeriodFeedback.getPeriodValue(), "'metricFeedback.periodValue' is required.");
innerMetricFeedback = new PeriodFeedback()
.setValue(new PeriodFeedbackValue().setPeriodValue(metricPeriodFeedback.getPeriodValue())
.setPeriodType(metricPeriodFeedback.getPeriodType()))
.setMetricId(UUID.fromString(metricId))
.setDimensionFilter(
new FeedbackDimensionFilter().setDimension(metricPeriodFeedback.getDimensionFilter().asMap()));
} else if (metricFeedback instanceof MetricCommentFeedback) {
MetricCommentFeedback metricCommentFeedback = (MetricCommentFeedback) metricFeedback;
Objects.requireNonNull(metricCommentFeedback.getComment(), "'metricFeedback.comment' is required.");
innerMetricFeedback = new CommentFeedback().setStartTime(metricCommentFeedback.getStartTime())
.setEndTime(metricCommentFeedback.getEndTime())
.setValue(new CommentFeedbackValue().setCommentValue(metricCommentFeedback.getComment()))
.setMetricId(UUID.fromString(metricId))
.setDimensionFilter(
new FeedbackDimensionFilter().setDimension(metricCommentFeedback.getDimensionFilter().asMap()));
} else {
throw logger.logExceptionAsError(new IllegalArgumentException("Unknown feedback type."));
}
CreateMetricFeedbackResponse createdMetricFeedbackResponse
= service.createMetricFeedbackWithResponse(innerMetricFeedback, context);
return getFeedbackWithResponse(
parseOperationId(createdMetricFeedbackResponse.getDeserializedHeaders().getLocation()), context);
}
/**
* Get a metric feedback by its id.
*
* Code sample
*
*
*
* final String feedbackId = "8i3h4i4-b804-4ab9-a70f-0da0c89cft3l";
* final MetricFeedback metricFeedback = metricsAdvisorClient.getFeedback(feedbackId);
* System.out.printf("Data Feed Metric feedback Id: %s%n", metricFeedback.getId());
* System.out.printf("Data Feed Metric feedback associated dimension filter: %s%n",
* metricFeedback.getDimensionFilter().asMap());
*
* if (PERIOD.equals(metricFeedback.getFeedbackType())) {
* MetricPeriodFeedback createMetricPeriodFeedback
* = (MetricPeriodFeedback) metricFeedback;
* System.out.printf("Data Feed Metric feedback type: %s%n",
* createMetricPeriodFeedback.getPeriodType().toString());
* System.out.printf("Data Feed Metric feedback period value: %d%n",
* createMetricPeriodFeedback.getPeriodValue());
* }
*
*
*
* @param feedbackId The metric feedback unique id.
*
* @return The metric feedback for the provided id.
* @throws IllegalArgumentException If {@code feedbackId} does not conform to the UUID format specification.
* @throws NullPointerException thrown if the {@code feedbackId} is null.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public MetricFeedback getFeedback(String feedbackId) {
return getFeedbackWithResponse(feedbackId, Context.NONE).getValue();
}
/**
* Get a metric feedback by its id.
*
* Code sample
*
*
*
* final String feedbackId = "8i3h4i4-b804-4ab9-a70f-0da0c89cft3l";
* final Response<MetricFeedback> metricFeedbackResponse
* = metricsAdvisorClient.getFeedbackWithResponse(feedbackId, Context.NONE);
* final MetricFeedback metricFeedback = metricFeedbackResponse.getValue();
* System.out.printf("Data Feed Metric feedback Id: %s%n", metricFeedback.getId());
* System.out.printf("Data Feed Metric feedback associated dimension filter: %s%n",
* metricFeedback.getDimensionFilter().asMap());
*
* if (PERIOD.equals(metricFeedback.getFeedbackType())) {
* MetricPeriodFeedback createMetricPeriodFeedback
* = (MetricPeriodFeedback) metricFeedback;
* System.out.printf("Data Feed Metric feedback type: %s%n",
* createMetricPeriodFeedback.getPeriodType().toString());
* System.out.printf("Data Feed Metric feedback period value: %d%n",
* createMetricPeriodFeedback.getPeriodValue());
* }
*
*
*
* @param feedbackId The metric feedback unique id.
* @param context Additional context that is passed through the HTTP pipeline during the service call.
*
* @return The metric feedback for the provided id.
* @throws IllegalArgumentException If {@code feedbackId} does not conform to the UUID format specification.
* @throws NullPointerException thrown if the {@code feedbackId} is null.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response getFeedbackWithResponse(String feedbackId, Context context) {
return getFeedbackWithResponseSync(feedbackId, context);
}
private Response getFeedbackWithResponseSync(String feedbackId, Context context) {
Objects.requireNonNull(feedbackId, "'feedbackId' is required.");
Response metricFeedbackResponse
= service.getMetricFeedbackWithResponse(UUID.fromString(feedbackId), context);
return new SimpleResponse<>(metricFeedbackResponse,
MetricFeedbackTransforms.fromInner(metricFeedbackResponse.getValue()));
}
/**
* List information of all metric feedbacks on the metrics advisor account.
*
* Code sample
*
*
* final String metricId = "d3gh4i4-b804-4ab9-a70f-0da0c89cft3l";
* metricsAdvisorClient.listFeedback(metricId)
* .forEach(metricFeedback -> {
* System.out.printf("Data Feed Metric feedback Id: %s%n", metricFeedback.getId());
* System.out.printf("Data Feed Metric feedback associated dimension filter: %s%n",
* metricFeedback.getDimensionFilter().asMap());
*
* if (PERIOD.equals(metricFeedback.getFeedbackType())) {
* MetricPeriodFeedback periodFeedback
* = (MetricPeriodFeedback) metricFeedback;
* System.out.printf("Data Feed Metric feedback type: %s%n",
* periodFeedback.getPeriodType().toString());
* System.out.printf("Data Feed Metric feedback period value: %d%n",
* periodFeedback.getPeriodValue());
* } else if (ANOMALY.equals(metricFeedback.getFeedbackType())) {
* MetricAnomalyFeedback metricAnomalyFeedback
* = (MetricAnomalyFeedback) metricFeedback;
* System.out.printf("Data Feed Metric feedback anomaly value: %s%n",
* metricAnomalyFeedback.getAnomalyValue().toString());
* System.out.printf("Data Feed Metric feedback associated detection configuration: %s%n",
* metricAnomalyFeedback.getDetectionConfigurationId());
* } else if (COMMENT.equals(metricFeedback.getFeedbackType())) {
* MetricCommentFeedback metricCommentFeedback
* = (MetricCommentFeedback) metricFeedback;
* System.out.printf("Data Feed Metric feedback comment value: %s%n",
* metricCommentFeedback.getComment());
* }
* });
*
*
*
* @param metricId the unique metric Id.
*
* @return A {@link PagedIterable} containing information of all the {@link MetricFeedback metric feedbacks}
* in the account.
* @throws IllegalArgumentException thrown if {@code metricId} fail the UUID format validation.
* @throws MetricsAdvisorResponseException thrown if the request is rejected by server.
* @throws NullPointerException thrown if the {@code metricId} is null.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable listFeedback(String metricId) {
return listFeedback(metricId, null, Context.NONE);
}
/**
* List information of all metric feedbacks on the metrics advisor account.
*
* Code sample
*
*
* final String metricId = "d3gh4i4-b804-4ab9-a70f-0da0c89cft3l";
* final OffsetDateTime startTime = OffsetDateTime.parse("2020-01-01T00:00:00Z");
* final OffsetDateTime endTime = OffsetDateTime.parse("2020-09-09T00:00:00Z");
*
* metricsAdvisorClient.listFeedback(metricId,
* new ListMetricFeedbackOptions()
* .setFilter(new ListMetricFeedbackFilter()
* .setStartTime(startTime)
* .setTimeMode(FeedbackQueryTimeMode.FEEDBACK_CREATED_TIME)
* .setEndTime(endTime)), Context.NONE)
* .forEach(metricFeedback -> {
* System.out.printf("Data Feed Metric feedback Id: %s%n", metricFeedback.getId());
* System.out.printf("Data Feed Metric feedback associated dimension filter: %s%n",
* metricFeedback.getDimensionFilter().asMap());
* System.out.printf("Data Feed Metric feedback created time %s%n", metricFeedback.getCreatedTime());
*
* if (PERIOD.equals(metricFeedback.getFeedbackType())) {
* MetricPeriodFeedback periodFeedback
* = (MetricPeriodFeedback) metricFeedback;
* System.out.printf("Data Feed Metric feedback type: %s%n",
* periodFeedback.getPeriodType().toString());
* System.out.printf("Data Feed Metric feedback period value: %d%n",
* periodFeedback.getPeriodValue());
* } else if (ANOMALY.equals(metricFeedback.getFeedbackType())) {
* MetricAnomalyFeedback metricAnomalyFeedback
* = (MetricAnomalyFeedback) metricFeedback;
* System.out.printf("Data Feed Metric feedback anomaly value: %s%n",
* metricAnomalyFeedback.getAnomalyValue().toString());
* System.out.printf("Data Feed Metric feedback associated detection configuration: %s%n",
* metricAnomalyFeedback.getDetectionConfigurationId());
* } else if (COMMENT.equals(metricFeedback.getFeedbackType())) {
* MetricCommentFeedback metricCommentFeedback
* = (MetricCommentFeedback) metricFeedback;
* System.out.printf("Data Feed Metric feedback comment value: %s%n",
* metricCommentFeedback.getComment());
* }
* });
*
*
*
* @param metricId the unique metric Id.
* @param options The configurable {@link ListMetricFeedbackOptions options} to pass for filtering the output
* result.
* @param context Additional context that is passed through the HTTP pipeline during the service call.
*
* @return A {@link PagedIterable} containing information of all the {@link MetricFeedback metric feedbacks}
* in the account.
* @throws IllegalArgumentException thrown if {@code metricId} fail the UUID format validation.
* @throws MetricsAdvisorResponseException thrown if the request is rejected by server.
* @throws NullPointerException thrown if the {@code metricId} is null.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable listFeedback(String metricId, ListMetricFeedbackOptions options,
Context context) {
return listFeedbackSync(metricId, options, context);
}
private PagedIterable listFeedbackSync(String metricId, ListMetricFeedbackOptions options,
Context context) {
if (options == null) {
options = new ListMetricFeedbackOptions();
}
final MetricFeedbackFilter metricFeedbackFilter = MetricFeedbackTransforms.toInnerFilter(metricId, options);
ListMetricFeedbackOptions finalOptions = options;
return new PagedIterable<>(
() -> listMetricFeedbacksSinglePageSync(metricFeedbackFilter, finalOptions.getMaxPageSize(),
finalOptions.getSkip(), context),
continuationToken -> listMetricFeedbacksNextPageSync(continuationToken, metricFeedbackFilter, context));
}
private PagedResponse listMetricFeedbacksSinglePageSync(MetricFeedbackFilter metricFeedbackFilter,
Integer maxPageSize, Integer skip, Context context) {
PagedResponse res
= service.listMetricFeedbacksSinglePage(metricFeedbackFilter, skip, maxPageSize, context);
return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(),
res.getValue().stream().map(MetricFeedbackTransforms::fromInner).collect(Collectors.toList()),
res.getContinuationToken(), null);
}
private PagedResponse listMetricFeedbacksNextPageSync(String nextPageLink,
MetricFeedbackFilter metricFeedbackFilter, Context context) {
if (CoreUtils.isNullOrEmpty(nextPageLink)) {
return null;
}
PagedResponse res
= service.listMetricFeedbacksNextSinglePage(nextPageLink, metricFeedbackFilter, context);
return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(),
res.getValue().stream().map(MetricFeedbackTransforms::fromInner).collect(Collectors.toList()),
res.getContinuationToken(), null);
}
/**
* List dimension values from certain metric.
*
* Code sample
*
*
* final String metricId = "gh3014a0-41ec-a637-677e77b81455";
* metricsAdvisorClient.listMetricDimensionValues(metricId, "category")
* .forEach(System.out::println);
*
*
*
* @param metricId metric unique id.
* @param dimensionName the query dimension name.
*
* @return the {@link PagedIterable} of the dimension values for that metric.
* @throws IllegalArgumentException thrown if {@code metricId} fail the UUID format validation.
* @throws MetricsAdvisorResponseException thrown if the request is rejected by server.
* @throws NullPointerException thrown if the {@code metricId} or {@code dimensionName} is null.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable listMetricDimensionValues(String metricId, String dimensionName) {
return listMetricDimensionValues(metricId, dimensionName, null, Context.NONE);
}
/**
* List dimension values from certain metric.
*
* Code sample
*
*
* final String metricId = "gh3014a0-41ec-a637-677e77b81455";
* metricsAdvisorClient.listMetricDimensionValues(metricId, "category",
* new ListMetricDimensionValuesOptions().setDimensionValueToFilter("Electronics")
* .setMaxPageSize(3), Context.NONE)
* .forEach(System.out::println);
*
*
*
* @param metricId metric unique id.
* @param dimensionName the query dimension name.
* @param options the additional parameters to specify while querying.
* @param context Additional context that is passed through the HTTP pipeline during the service call.
*
* @return the {@link PagedIterable} of the dimension values for that metric.
* @throws IllegalArgumentException thrown if {@code metricId} fail the UUID format validation.
* @throws MetricsAdvisorResponseException thrown if the request is rejected by server.
* @throws NullPointerException thrown if the {@code metricId} or {@code dimensionName} is null.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable listMetricDimensionValues(String metricId, String dimensionName,
ListMetricDimensionValuesOptions options, Context context) {
return listMetricDimensionValuesSync(metricId, dimensionName, options, context);
}
private PagedIterable listMetricDimensionValuesSync(final String metricId, final String dimensionName,
final ListMetricDimensionValuesOptions options, final Context context) {
return new PagedIterable<>(
() -> listMetricDimensionValuesSinglePageAsync(metricId, dimensionName, options, context),
continuationToken -> listMetricDimensionValuesNextPageAsync(continuationToken, dimensionName, options,
context));
}
private PagedResponse listMetricDimensionValuesSinglePageAsync(String metricId, String dimensionName,
ListMetricDimensionValuesOptions options, Context context) {
Objects.requireNonNull(metricId, "'metricId' cannot be null.");
Objects.requireNonNull(dimensionName, "'dimensionName' cannot be null.");
if (options == null) {
options = new ListMetricDimensionValuesOptions();
}
final MetricDimensionQueryOptions metricDimensionQueryOptions
= getMetricDimensionQueryOptions(dimensionName, options);
PagedResponse res = service.getMetricDimensionSinglePage(UUID.fromString(metricId),
metricDimensionQueryOptions, options.getSkip(), options.getMaxPageSize(), context);
return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getValue(),
res.getContinuationToken(), null);
}
private PagedResponse listMetricDimensionValuesNextPageAsync(String nextPageLink, String dimensionName,
ListMetricDimensionValuesOptions options, Context context) {
if (CoreUtils.isNullOrEmpty(nextPageLink)) {
return null;
}
final MetricDimensionQueryOptions metricDimensionQueryOptions
= getMetricDimensionQueryOptions(dimensionName, options);
PagedResponse res
= service.getMetricDimensionNextSinglePage(nextPageLink, metricDimensionQueryOptions, context);
return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getValue(),
res.getContinuationToken(), null);
}
}