Compartir a través de


MetricsAdvisorAsyncClient Class

  • java.lang.Object
    • com.azure.ai.metricsadvisor.MetricsAdvisorAsyncClient

public final class MetricsAdvisorAsyncClient

This class provides an asynchronous client to connect to the Metrics Advisor Azure Cognitive Service.

This client provides asynchronous methods to perform:

  1. Analyze root cause into specific dimension using the com.azure.ai.metricsadvisor.MetricsAdvisorAsyncClient#listIncidentRootCauses(String, String) method with your respective data source.
  2. Fetch incidents triggered for a particular detection configuration using the com.azure.ai.metricsadvisor.MetricsAdvisorAsyncClient#listIncidentsForDetectionConfig(String, OffsetDateTime, OffsetDateTime) method.
  3. Fetch all the anomalies detected for a particular detection configuration using the com.azure.ai.metricsadvisor.MetricsAdvisorAsyncClient#listAnomaliesForDetectionConfig(String, OffsetDateTime, OffsetDateTime) method./li>

Service clients are the point of interaction for developers to use Azure Metrics Advisor. MetricsAdvisorClient is the synchronous service client and 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 MetricsAdvisorAsyncClient with DefaultAzureCredential

The following code sample demonstrates the creation of a MetricsAdvisorAsyncClient, using the `DefaultAzureCredentialBuilder` to configure it.

MetricsAdvisorAsyncClient metricsAdvisorAsyncClient =
     new MetricsAdvisorClientBuilder()
         .credential(new DefaultAzureCredentialBuilder().build())
         .endpoint("{endpoint}")
         .buildAsyncClient();

Further, see the code sample below to use MetricsAdvisorKeyCredential for client creation.

MetricsAdvisorAsyncClient metricsAdvisorAsyncClient =
     new MetricsAdvisorClientBuilder()
         .credential(new MetricsAdvisorKeyCredential("{subscription_key}", "{api_key}"))
         .endpoint("{endpoint}")
         .buildAsyncClient();

Method Summary

Modifier and Type Method and Description
Mono<MetricFeedback> addFeedback(String metricId, MetricFeedback metricFeedback)

Create a new metric feedback.

Mono<Response<MetricFeedback>> addFeedbackWithResponse(String metricId, MetricFeedback metricFeedback)

Create a new metric feedback.

Mono<MetricFeedback> getFeedback(String feedbackId)

Get a metric feedback by its id.

Mono<Response<MetricFeedback>> getFeedbackWithResponse(String feedbackId)

Get a metric feedback by its id.

PagedFlux<AnomalyAlert> listAlerts(String alertConfigurationId, OffsetDateTime startTime, OffsetDateTime endTime)

Fetch the alerts triggered by an anomaly alert configuration.

PagedFlux<AnomalyAlert> listAlerts(String alertConfigurationId, OffsetDateTime startTime, OffsetDateTime endTime, ListAlertOptions options)

Fetch the alerts triggered by an anomaly alert configuration.

PagedFlux<DataPointAnomaly> listAnomaliesForAlert(String alertConfigurationId, String alertId)

Fetch the anomalies in an alert.

PagedFlux<DataPointAnomaly> listAnomaliesForAlert(String alertConfigurationId, String alertId, ListAnomaliesAlertedOptions options)

Fetch the anomalies in an alert.

PagedFlux<DataPointAnomaly> listAnomaliesForDetectionConfig(String detectionConfigurationId, OffsetDateTime startTime, OffsetDateTime endTime)

Fetch the anomalies identified by an anomaly detection configuration.

PagedFlux<DataPointAnomaly> listAnomaliesForDetectionConfig(String detectionConfigurationId, OffsetDateTime startTime, OffsetDateTime endTime, ListAnomaliesDetectedOptions options)

Fetch the anomalies identified by an anomaly detection configuration.

PagedFlux<String> listAnomalyDimensionValues(String detectionConfigurationId, String dimensionName, OffsetDateTime startTime, OffsetDateTime endTime)

Fetch dimension values that have anomalies.

PagedFlux<String> listAnomalyDimensionValues(String detectionConfigurationId, String dimensionName, OffsetDateTime startTime, OffsetDateTime endTime, ListAnomalyDimensionValuesOptions options)

Fetch dimension values that have anomalies.

PagedFlux<MetricFeedback> listFeedback(String metricId)

List information of metrics feedback on the account for a metric Id.

PagedFlux<MetricFeedback> listFeedback(String metricId, ListMetricFeedbackOptions options)

List information of all metric feedbacks on the metrics advisor account for a metric Id.

PagedFlux<IncidentRootCause> listIncidentRootCauses(AnomalyIncident anomalyIncident)

List the root causes for an anomalyIncident.

PagedFlux<IncidentRootCause> listIncidentRootCauses(String detectionConfigurationId, String incidentId)

List the root causes for an incident.

PagedFlux<AnomalyIncident> listIncidentsForAlert(String alertConfigurationId, String alertId)

Fetch the incidents in an alert.

PagedFlux<AnomalyIncident> listIncidentsForAlert(String alertConfigurationId, String alertId, ListIncidentsAlertedOptions options)

Fetch the incidents in an alert.

PagedFlux<AnomalyIncident> listIncidentsForDetectionConfig(String detectionConfigurationId, OffsetDateTime startTime, OffsetDateTime endTime)

Fetch the incidents identified by an anomaly detection configuration.

PagedFlux<AnomalyIncident> listIncidentsForDetectionConfig(String detectionConfigurationId, OffsetDateTime startTime, OffsetDateTime endTime, ListIncidentsDetectedOptions options)

Fetch the incidents identified by an anomaly detection configuration.

PagedFlux<String> listMetricDimensionValues(String metricId, String dimensionName)

List dimension values from certain metric.

PagedFlux<String> listMetricDimensionValues(String metricId, String dimensionName, ListMetricDimensionValuesOptions options)

List dimension values from certain metric.

PagedFlux<MetricEnrichedSeriesData> listMetricEnrichedSeriesData(String detectionConfigurationId, List<DimensionKey> seriesKeys, OffsetDateTime startTime, OffsetDateTime endTime)

Given a list of time series keys, retrieve time series version enriched using a detection configuration.

PagedFlux<EnrichmentStatus> listMetricEnrichmentStatus(String metricId, OffsetDateTime startTime, OffsetDateTime endTime)

List the enrichment status for a metric.

PagedFlux<EnrichmentStatus> listMetricEnrichmentStatus(String metricId, OffsetDateTime startTime, OffsetDateTime endTime, ListMetricEnrichmentStatusOptions options)

List the enrichment status for a metric.

PagedFlux<MetricSeriesData> listMetricSeriesData(String metricId, List<DimensionKey> seriesKeys, OffsetDateTime startTime, OffsetDateTime endTime)

Get time series data from metric.

PagedFlux<MetricSeriesDefinition> listMetricSeriesDefinitions(String metricId, OffsetDateTime activeSince)

List series definition for a metric.

PagedFlux<MetricSeriesDefinition> listMetricSeriesDefinitions(String metricId, OffsetDateTime activeSince, ListMetricSeriesDefinitionOptions options)

List series definition for a metric.

Methods inherited from java.lang.Object

Method Details

addFeedback

public Mono addFeedback(String metricId, MetricFeedback metricFeedback)

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);

 metricsAdvisorAsyncClient.addFeedback(metricId, metricChangePointFeedback)
     .subscribe(metricFeedback -> {
         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());
     });

Parameters:

metricId - the unique id for which the feedback needs to be submitted.
metricFeedback - the actual metric feedback.

Returns:

A Mono containing the created MetricFeedback.

addFeedbackWithResponse

public Mono> addFeedbackWithResponse(String metricId, MetricFeedback metricFeedback)

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);

 metricsAdvisorAsyncClient.addFeedbackWithResponse(metricId, metricChangePointFeedback)
     .subscribe(metricFeedbackResponse -> {
         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());
     });

Parameters:

metricId - the unique id for which the feedback needs to be submitted.
metricFeedback - the actual metric feedback.

Returns:

A Response<T> of a Mono containing the created MetricFeedback.

getFeedback

public Mono getFeedback(String feedbackId)

Get a metric feedback by its id.

Code sample

final String feedbackId = "8i3h4i4-b804-4ab9-a70f-0da0c89cft3l";
 metricsAdvisorAsyncClient.getFeedback(feedbackId)
     .subscribe(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 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());
         }
     });

Parameters:

feedbackId - The metric feedback unique id.

Returns:

The metric feedback for the provided id.

getFeedbackWithResponse

public Mono> getFeedbackWithResponse(String feedbackId)

Get a metric feedback by its id.

Code sample

final String feedbackId = "8i3h4i4-b804-4ab9-a70f-0da0c89cft3l";
 metricsAdvisorAsyncClient.getFeedbackWithResponse(feedbackId)
     .subscribe(metricFeedbackResponse -> {
         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());
         }
     });

Parameters:

feedbackId - The metric feedback unique id.

Returns:

The metric feedback for the provided id.

listAlerts

public PagedFlux listAlerts(String alertConfigurationId, OffsetDateTime startTime, OffsetDateTime endTime)

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;

 metricsAdvisorAsyncClient.listAlerts(alertConfigurationId, startTime, endTime)
     .subscribe(alert -> {
         System.out.printf("Anomaly Alert Id: %s%n", alert.getId());
         System.out.printf("Created Time: %s%n", alert.getCreatedTime());
         System.out.printf("Modified Time: %s%n", alert.getModifiedTime());
     });

Parameters:

alertConfigurationId - The anomaly alert configuration id.
startTime - The start time of the time range within which the alerts were triggered.
endTime - The end time of the time range within which the alerts were triggered.

Returns:

The alerts.

listAlerts

public PagedFlux listAlerts(String alertConfigurationId, OffsetDateTime startTime, OffsetDateTime endTime, ListAlertOptions options)

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);

 metricsAdvisorAsyncClient.listAlerts(alertConfigurationId, startTime, endTime, options)
     .subscribe(alert -> {
         System.out.printf("Anomaly Alert Id: %s%n", alert.getId());
         System.out.printf("Created Time: %s%n", alert.getCreatedTime());
         System.out.printf("Modified Time: %s%n", alert.getModifiedTime());
     });

Parameters:

alertConfigurationId - The anomaly alert configuration id.
startTime - The start time of the time range within which the alerts were triggered.
endTime - The end time of the time range within which the alerts were triggered.
options - The additional parameters.

Returns:

The alerts.

listAnomaliesForAlert

public PagedFlux listAnomaliesForAlert(String alertConfigurationId, String alertId)

Fetch the anomalies in an alert.

Code sample

final String alertConfigurationId = "ff3014a0-bbbb-41ec-a637-677e77b81299";
 final String alertId = "1746b031c00";

 metricsAdvisorAsyncClient.listAnomaliesForAlert(
     alertConfigurationId,
     alertId)
     .subscribe(anomaly -> {
         System.out.printf("Data Feed Metric Id: %s%n", anomaly.getMetricId());
         System.out.printf("Detection Configuration Id: %s%n", anomaly.getDetectionConfigurationId());
         System.out.printf("DataPoint Anomaly Created Time: %s%n", anomaly.getCreatedTime());
         System.out.printf("DataPoint Anomaly Modified Time: %s%n", anomaly.getModifiedTime());
         System.out.printf("DataPoint Anomaly AnomalySeverity: %s%n", anomaly.getSeverity());
         System.out.printf("DataPoint Anomaly Status: %s%n", anomaly.getStatus());
         System.out.printf("Series Key:");
         DimensionKey seriesKey = anomaly.getSeriesKey();
         for (Map.Entry<String, String> dimension : seriesKey.asMap().entrySet()) {
             System.out.printf("DimensionName: %s DimensionValue:%s%n",
                 dimension.getKey(), dimension.getValue());
         }
     });

Parameters:

alertConfigurationId - The anomaly alert configuration id.
alertId - The alert id.

Returns:

The anomalies.

listAnomaliesForAlert

public PagedFlux listAnomaliesForAlert(String alertConfigurationId, String alertId, ListAnomaliesAlertedOptions options)

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);
 metricsAdvisorAsyncClient.listAnomaliesForAlert(
     alertConfigurationId,
     alertId,
     options)
     .subscribe(anomaly -> {
         System.out.printf("Data Feed Metric Id: %s%n", anomaly.getMetricId());
         System.out.printf("Detection Configuration Id: %s%n", anomaly.getDetectionConfigurationId());
         System.out.printf("DataPoint Anomaly Created Time: %s%n", anomaly.getCreatedTime());
         System.out.printf("DataPoint Anomaly Modified Time: %s%n", anomaly.getModifiedTime());
         System.out.printf("DataPoint Anomaly AnomalySeverity: %s%n", anomaly.getSeverity());
         System.out.printf("DataPoint Anomaly Status: %s%n", anomaly.getStatus());
         System.out.printf("Series Key:");
         System.out.println(anomaly.getSeriesKey().asMap());
     });

Parameters:

alertConfigurationId - The anomaly alert configuration id.
alertId - The alert id.
options - The additional parameters.

Returns:

The anomalies.

listAnomaliesForDetectionConfig

public PagedFlux listAnomaliesForDetectionConfig(String detectionConfigurationId, OffsetDateTime startTime, OffsetDateTime endTime)

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");

 metricsAdvisorAsyncClient.listAnomaliesForDetectionConfig(detectionConfigurationId,
     startTime, endTime)
     .subscribe(anomaly -> {
         System.out.printf("DataPoint Anomaly AnomalySeverity: %s%n", anomaly.getSeverity());
         System.out.printf("Series Key:");
         DimensionKey seriesKey = anomaly.getSeriesKey();
         for (Map.Entry<String, String> dimension : seriesKey.asMap().entrySet()) {
             System.out.printf("DimensionName: %s DimensionValue:%s%n",
                 dimension.getKey(), dimension.getValue());
         }
     });

Parameters:

detectionConfigurationId - The anomaly detection configuration id.
startTime - The start time of the time range within which the anomalies were detected.
endTime - The end time of the time range within which the anomalies were detected.

Returns:

The anomalies.

listAnomaliesForDetectionConfig

public PagedFlux listAnomaliesForDetectionConfig(String detectionConfigurationId, OffsetDateTime startTime, OffsetDateTime endTime, ListAnomaliesDetectedOptions options)

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);
 metricsAdvisorAsyncClient.listAnomaliesForDetectionConfig(detectionConfigurationId,
         startTime, endTime, options)
     .subscribe(anomaly -> {
         System.out.printf("DataPoint Anomaly AnomalySeverity: %s%n", anomaly.getSeverity());
         System.out.printf("Series Key:");
         DimensionKey seriesKey = anomaly.getSeriesKey();
         for (Map.Entry<String, String> dimension : seriesKey.asMap().entrySet()) {
             System.out.printf("DimensionName: %s DimensionValue:%s%n",
                 dimension.getKey(), dimension.getValue());
         }
     });

Parameters:

detectionConfigurationId - The anomaly detection configuration id.
startTime - The start time of the time range within which the anomalies were detected.
endTime - The end time of the time range within which the anomalies were detected.
options - The additional parameters.

Returns:

The anomalies.

listAnomalyDimensionValues

public PagedFlux listAnomalyDimensionValues(String detectionConfigurationId, String dimensionName, OffsetDateTime startTime, OffsetDateTime endTime)

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");

 metricsAdvisorAsyncClient.listAnomalyDimensionValues(detectionConfigurationId,
     dimensionName,
     startTime, endTime)
     .subscribe(dimensionValue -> {
         System.out.printf("DataFeedDimension Value: %s%n", dimensionValue);
     });

Parameters:

detectionConfigurationId - Identifies the configuration used to detect the anomalies.
dimensionName - The dimension name to retrieve the values for.
startTime - The start time of the time range within which the anomalies were identified.
endTime - The end time of the time range within which the anomalies were identified.

Returns:

The dimension values with anomalies.

listAnomalyDimensionValues

public PagedFlux listAnomalyDimensionValues(String detectionConfigurationId, String dimensionName, OffsetDateTime startTime, OffsetDateTime endTime, ListAnomalyDimensionValuesOptions options)

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);

 metricsAdvisorAsyncClient.listAnomalyDimensionValues(detectionConfigurationId,
     dimensionName,
     startTime, endTime, options)
     .subscribe(dimensionValue -> {
         System.out.printf("DataFeedDimension Value: %s%n", dimensionValue);
     });

Parameters:

detectionConfigurationId - Identifies the configuration used to detect the anomalies.
dimensionName - The dimension name to retrieve the values for.
startTime - The start time of the time range within which the anomalies were identified.
endTime - The end time of the time range within which the anomalies were identified.
options - The additional parameters.

Returns:

The dimension values with anomalies.

listFeedback

public PagedFlux listFeedback(String metricId)

List information of metrics feedback on the account for a metric Id.

Code sample

final String metricId = "d3gh4i4-b804-4ab9-a70f-0da0c89cft3l";
 metricsAdvisorAsyncClient.listFeedback(metricId)
     .subscribe(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());
         }
     });

Parameters:

metricId - the unique metric Id.

Returns:

A PagedFlux<T> containing information of all the MetricFeedback in the account.

listFeedback

public PagedFlux listFeedback(String metricId, ListMetricFeedbackOptions options)

List information of all metric feedbacks on the metrics advisor account for a metric Id.

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");

 metricsAdvisorAsyncClient.listFeedback(metricId,
     new ListMetricFeedbackOptions()
         .setFilter(new ListMetricFeedbackFilter()
             .setStartTime(startTime)
             .setTimeMode(FeedbackQueryTimeMode.FEEDBACK_CREATED_TIME)
             .setEndTime(endTime)))
     .subscribe(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());
         }
     });

Parameters:

metricId - the unique metric Id.
options - The configurable ListMetricFeedbackOptions to pass for filtering the output result.

Returns:

A PagedFlux<T> containing information of all the MetricFeedback in the account.

listIncidentRootCauses

public PagedFlux listIncidentRootCauses(AnomalyIncident anomalyIncident)

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");
 final ListIncidentsDetectedOptions options
     = new ListIncidentsDetectedOptions()
     .setMaxPageSize(10);

 metricsAdvisorAsyncClient.listIncidentsForDetectionConfig(detectionConfigurationId, startTime, endTime,
     options)
     .flatMap(incident -> {
         return metricsAdvisorAsyncClient.listIncidentRootCauses(incident);
     })
     .subscribe(incidentRootCause -> {
         System.out.printf("Description: %s%n", incidentRootCause.getDescription());
         System.out.printf("Series Key:");
         System.out.println(incidentRootCause.getSeriesKey().asMap());
     });

Parameters:

anomalyIncident - the anomalyIncident for which you want to query root causes for.

Returns:

the list of root causes for that anomalyIncident.

listIncidentRootCauses

public PagedFlux listIncidentRootCauses(String detectionConfigurationId, String incidentId)

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";

 metricsAdvisorAsyncClient.listIncidentRootCauses(detectionConfigurationId, incidentId)
     .subscribe(incidentRootCause -> {
         System.out.printf("Description: %s%n", incidentRootCause.getDescription());
         System.out.println("Series Key:");
         System.out.println(incidentRootCause.getSeriesKey().asMap());
         System.out.printf("Confidence for the detected incident root cause: %.2f%n",
             incidentRootCause.getContributionScore());
     });

Parameters:

detectionConfigurationId - anomaly detection configuration unique id.
incidentId - the incident for which you want to query root causes for.

Returns:

the list of root causes for that incident.

listIncidentsForAlert

public PagedFlux listIncidentsForAlert(String alertConfigurationId, String alertId)

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);

 metricsAdvisorAsyncClient.listIncidentsForAlert(
     alertConfigurationId,
     alertId,
     options)
     .subscribe(incident -> {
         System.out.printf("Data Feed Metric Id: %s%n", incident.getMetricId());
         System.out.printf("Detection Configuration Id: %s%n", incident.getDetectionConfigurationId());
         System.out.printf("Anomaly Incident Id: %s%n", incident.getId());
         System.out.printf("Anomaly Incident Start Time: %s%n", incident.getStartTime());
         System.out.printf("Anomaly Incident AnomalySeverity: %s%n", incident.getSeverity());
         System.out.printf("Anomaly Incident Status: %s%n", incident.getStatus());
         System.out.printf("Root DataFeedDimension Key:");
         DimensionKey rootDimension = incident.getRootDimensionKey();
         for (Map.Entry<String, String> dimension : rootDimension.asMap().entrySet()) {
             System.out.printf("DimensionName: %s DimensionValue:%s%n",
                 dimension.getKey(), dimension.getValue());
         }
     });

Parameters:

alertConfigurationId - The anomaly alert configuration id.
alertId - The alert id.

Returns:

The incidents.

listIncidentsForAlert

public PagedFlux listIncidentsForAlert(String alertConfigurationId, String alertId, ListIncidentsAlertedOptions options)

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);

 metricsAdvisorAsyncClient.listIncidentsForAlert(
     alertConfigurationId,
     alertId,
     options)
     .subscribe(incident -> {
         System.out.printf("Data Feed Metric Id: %s%n", incident.getMetricId());
         System.out.printf("Detection Configuration Id: %s%n", incident.getDetectionConfigurationId());
         System.out.printf("Anomaly Incident Id: %s%n", incident.getId());
         System.out.printf("Anomaly Incident Start Time: %s%n", incident.getStartTime());
         System.out.printf("Anomaly Incident AnomalySeverity: %s%n", incident.getSeverity());
         System.out.printf("Anomaly Incident Status: %s%n", incident.getStatus());
         System.out.printf("Root DataFeedDimension Key:");
         DimensionKey rootDimension = incident.getRootDimensionKey();
         for (Map.Entry<String, String> dimension : rootDimension.asMap().entrySet()) {
             System.out.printf("DimensionName: %s DimensionValue:%s%n",
                 dimension.getKey(), dimension.getValue());
         }
     });

Parameters:

alertConfigurationId - The anomaly alert configuration id.
alertId - The alert id.
options - The additional parameters.

Returns:

The incidents.

listIncidentsForDetectionConfig

public PagedFlux listIncidentsForDetectionConfig(String detectionConfigurationId, OffsetDateTime startTime, OffsetDateTime endTime)

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");

 PagedFlux<AnomalyIncident> incidentsFlux
     = metricsAdvisorAsyncClient.listIncidentsForDetectionConfig(detectionConfigurationId, startTime,
     endTime);

 incidentsFlux.subscribe(incident -> {
     System.out.printf("Data Feed Metric Id: %s%n", incident.getMetricId());
     System.out.printf("Detection Configuration Id: %s%n", incident.getDetectionConfigurationId());
     System.out.printf("Anomaly Incident Id: %s%n", incident.getId());
     System.out.printf("Anomaly Incident Start Time: %s%n", incident.getStartTime());
     System.out.printf("Anomaly Incident AnomalySeverity: %s%n", incident.getSeverity());
     System.out.printf("Anomaly Incident Status: %s%n", incident.getStatus());
     System.out.printf("Root DataFeedDimension Key: %s%n", incident.getRootDimensionKey().asMap());
 });

Parameters:

detectionConfigurationId - The anomaly detection configuration id.
startTime - The start time of the time range within which the incidents were detected.
endTime - The end time of the time range within which the incidents were detected.

Returns:

The incidents.

listIncidentsForDetectionConfig

public PagedFlux listIncidentsForDetectionConfig(String detectionConfigurationId, OffsetDateTime startTime, OffsetDateTime endTime, ListIncidentsDetectedOptions options)

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);

 PagedFlux<AnomalyIncident> incidentsFlux
     = metricsAdvisorAsyncClient.listIncidentsForDetectionConfig(detectionConfigurationId, startTime,
     endTime, options);

 incidentsFlux.subscribe(incident -> {
     System.out.printf("Data Feed Metric Id: %s%n", incident.getMetricId());
     System.out.printf("Detection Configuration Id: %s%n", incident.getDetectionConfigurationId());
     System.out.printf("Anomaly Incident Id: %s%n", incident.getId());
     System.out.printf("Anomaly Incident Start Time: %s%n", incident.getStartTime());
     System.out.printf("Anomaly Incident AnomalySeverity: %s%n", incident.getSeverity());
     System.out.printf("Anomaly Incident Status: %s%n", incident.getStatus());
     System.out.printf("Root DataFeedDimension Key: %s%n", incident.getRootDimensionKey().asMap());
 });

Parameters:

detectionConfigurationId - The anomaly detection configuration id.
startTime - The start time of the time range within which the incidents were detected.
endTime - The end time of the time range within which the incidents were detected.
options - The additional parameters.

Returns:

The incidents.

listMetricDimensionValues

public PagedFlux listMetricDimensionValues(String metricId, String dimensionName)

List dimension values from certain metric.

Code sample

metricsAdvisorAsyncClient.listMetricDimensionValues("metricId", "dimension1")
     .subscribe(System.out::println);

Parameters:

metricId - metric unique id.
dimensionName - the query dimension name.

Returns:

the PagedFlux<T> of the dimension values for that metric.

listMetricDimensionValues

public PagedFlux listMetricDimensionValues(String metricId, String dimensionName, ListMetricDimensionValuesOptions options)

List dimension values from certain metric.

Code sample

metricsAdvisorAsyncClient.listMetricDimensionValues("metricId", "dimension1",
     new ListMetricDimensionValuesOptions().setDimensionValueToFilter("value1").setMaxPageSize(3))
     .subscribe(System.out::println);

Parameters:

metricId - metric unique id.
dimensionName - the query dimension name.
options - the additional filtering parameters to specify while querying.

Returns:

the PagedFlux<T> of the dimension values for that metric.

listMetricEnrichedSeriesData

public PagedFlux listMetricEnrichedSeriesData(String detectionConfigurationId, List seriesKeys, OffsetDateTime startTime, OffsetDateTime endTime)

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");

 PagedFlux<MetricEnrichedSeriesData> enrichedDataFlux
     = metricsAdvisorAsyncClient.listMetricEnrichedSeriesData(detectionConfigurationId,
     Arrays.asList(seriesKey),
     startTime,
     endTime);

 enrichedDataFlux.subscribe(enrichedData -> {
     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());
 });

Parameters:

detectionConfigurationId - The id of the configuration used to enrich the time series identified by the keys in seriesKeys.
seriesKeys - The time series key list, each key identifies a specific time series.
startTime - The start time of the time range within which the enriched data is returned.
endTime - The end time of the time range within which the enriched data is returned.

Returns:

The enriched time series.

listMetricEnrichmentStatus

public PagedFlux listMetricEnrichmentStatus(String metricId, OffsetDateTime startTime, OffsetDateTime endTime)

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";

 metricsAdvisorAsyncClient.listMetricEnrichmentStatus(metricId, startTime, endTime)
     .subscribe(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());
     });

Parameters:

metricId - metric unique id.
startTime - The start time for querying the time series data.
endTime - The end time for querying the time series data.

Returns:

the list of enrichment status's for the specified metric.

listMetricEnrichmentStatus

public PagedFlux listMetricEnrichmentStatus(String metricId, OffsetDateTime startTime, OffsetDateTime endTime, ListMetricEnrichmentStatusOptions options)

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);

 metricsAdvisorAsyncClient.listMetricEnrichmentStatus(metricId, startTime, endTime, options)
     .subscribe(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());
     });

Parameters:

metricId - metric unique id.
startTime - The start time for querying the time series data.
endTime - The end time for querying the time series data.
options - th e additional configurable options to specify when querying the result..

Returns:

the list of enrichment status's for the specified metric.

listMetricSeriesData

public PagedFlux listMetricSeriesData(String metricId, List seriesKeys, OffsetDateTime startTime, OffsetDateTime endTime)

Get time series data from metric.

Code sample

final String metricId = "2dgfbbbb-41ec-a637-677e77b81455";
 final OffsetDateTime startTime = OffsetDateTime.parse("2020-09-09T00:00:00Z");
 final OffsetDateTime endTime = OffsetDateTime.parse("2020-09-09T12:00:00Z");

 final List<DimensionKey> seriesKeyFilter
     = Arrays.asList(new DimensionKey().put("cost", "redmond"));

 metricsAdvisorAsyncClient.listMetricSeriesData(metricId, seriesKeyFilter, startTime, endTime)
     .subscribe(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());
     });

Parameters:

metricId - metric unique id.
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'.
startTime - The start time for querying the time series data.
endTime - The end time for querying the time series data.

Returns:

listMetricSeriesDefinitions

public PagedFlux listMetricSeriesDefinitions(String metricId, OffsetDateTime activeSince)

List series definition for a metric.

Code sample

String metricId = "b460abfc-7a58-47d7-9d99-21ee21fdfc6e";
 final OffsetDateTime activeSince = OffsetDateTime.parse("2020-07-10T00:00:00Z");

 metricsAdvisorAsyncClient.listMetricSeriesDefinitions(metricId, activeSince)
     .subscribe(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());
     });

Parameters:

metricId - metric unique id.
activeSince - the start time for querying series ingested after this time.

Returns:

listMetricSeriesDefinitions

public PagedFlux listMetricSeriesDefinitions(String metricId, OffsetDateTime activeSince, ListMetricSeriesDefinitionOptions options)

List series definition for a 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"));
         }});

 metricsAdvisorAsyncClient.listMetricSeriesDefinitions(metricId, activeSince, options)
     .subscribe(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());
     });

Parameters:

metricId - metric unique id.
activeSince - the start time for querying series ingested after this time.
options - the additional filtering attributes that can be provided to query the series.

Returns:

Applies to