MetricsAdvisorClient Class
- java.
lang. Object - com.
azure. ai. metricsadvisor. MetricsAdvisorClient
- com.
public final class MetricsAdvisorClient
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 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 com.azure.ai.metricsadvisor.MetricsAdvisorClient#listIncidentsForDetectionConfig(String, OffsetDateTime, OffsetDateTime, ListIncidentsDetectedOptions, Context) method.
- Fetch all the anomalies detected for a particular detection configuration using the 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. 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 MetricsAdvisorClient with DefaultAzureCredential
The following code sample demonstrates the creation of a 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 MetricsAdvisorKeyCredential for client creation.
MetricsAdvisorClient metricsAdvisorClient =
new MetricsAdvisorClientBuilder()
.credential(new MetricsAdvisorKeyCredential("{subscription_key}", "{api_key}"))
.endpoint("{endpoint}")
.buildClient();
Method Summary
Methods inherited from java.lang.Object
Method Details
addFeedback
public MetricFeedback 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);
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());
Parameters:
Returns:
addFeedbackWithResponse
public 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 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());
Parameters:
Returns:
getFeedback
public MetricFeedback getFeedback(String feedbackId)
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());
}
Parameters:
Returns:
getFeedbackWithResponse
public Response
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());
}
Parameters:
Returns:
listAlerts
public PagedIterable
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());
}
Parameters:
Returns:
listAlerts
public PagedIterable
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());
}
});
Parameters:
Returns:
listAnomaliesForAlert
public PagedIterable
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());
}
Parameters:
Returns:
listAnomaliesForAlert
public PagedIterable
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());
}
});
Parameters:
Returns:
listAnomaliesForDetectionConfig
public PagedIterable
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());
}
}
Parameters:
Returns:
listAnomaliesForDetectionConfig
public PagedIterable
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());
}
}
});
Parameters:
Returns:
listAnomalyDimensionValues
public PagedIterable
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);
}
Parameters:
Returns:
listAnomalyDimensionValues
public PagedIterable
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);
}
});
Parameters:
Returns:
listFeedback
public PagedIterable
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());
}
});
Parameters:
Returns:
listFeedback
public PagedIterable
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());
}
});
Parameters:
Returns:
listIncidentRootCauses
public PagedIterable
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());
});
});
Parameters:
Returns:
listIncidentRootCauses
public PagedIterable
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());
});
Parameters:
Returns:
listIncidentRootCauses
public PagedIterable
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());
}
});
Parameters:
Returns:
listIncidentsForAlert
public PagedIterable
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());
}
}
});
Parameters:
Returns:
listIncidentsForAlert
public PagedIterable
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());
}
}
});
Parameters:
Returns:
listIncidentsForDetectionConfig
public PagedIterable
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());
}
Parameters:
Returns:
listIncidentsForDetectionConfig
public PagedIterable
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());
}
});
Parameters:
Returns:
listMetricDimensionValues
public PagedIterable
List dimension values from certain metric.
Code sample
final String metricId = "gh3014a0-41ec-a637-677e77b81455";
metricsAdvisorClient.listMetricDimensionValues(metricId, "category")
.forEach(System.out::println);
Parameters:
Returns:
listMetricDimensionValues
public PagedIterable
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);
Parameters:
Returns:
listMetricEnrichedSeriesData
public PagedIterable
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());
}
Parameters:
seriesKeys
.
Returns:
listMetricEnrichedSeriesData
public PagedIterable
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());
}
});
Parameters:
seriesKeys
.
Returns:
listMetricEnrichmentStatus
public PagedIterable
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());
});
Parameters:
Returns:
listMetricEnrichmentStatus
public PagedIterable
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());
});
Parameters:
Returns:
listMetricSeriesData
public PagedIterable
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());
});
Parameters:
Returns:
listMetricSeriesData
public PagedIterable
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());
});
Parameters:
Returns:
listMetricSeriesDefinitions
public PagedIterable
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());
});
Parameters:
Returns:
listMetricSeriesDefinitions
public PagedIterable
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());
});
Parameters:
Returns:
Applies to
Azure SDK for Java