diff --git a/sdk/metricsadvisor/azure-ai-metricsadvisor/CHANGELOG.md b/sdk/metricsadvisor/azure-ai-metricsadvisor/CHANGELOG.md
index 9448a68274e5..4d1c57aadabe 100644
--- a/sdk/metricsadvisor/azure-ai-metricsadvisor/CHANGELOG.md
+++ b/sdk/metricsadvisor/azure-ai-metricsadvisor/CHANGELOG.md
@@ -2,6 +2,18 @@
## 1.0.0-beta.2 (Unreleased)
+### Breaking changes
+- Updated `createdDataFeed` method to take one `DataFeed` object.
+- Renamed `listValuesOfDimensionWithAnomalies` method to `listDimensionValuesWithAnomalies`.
+- Renamed model `ListValuesOfDimensionWithAnomaliesOptions` method to `ListDimensionValuesWithAnomaliesOptions`.
+- Renamed properties `viewers` , `admins` and their accessors to `viewerEmails` and `adminEmails` respectively on
+`DataFeedOptions` model.
+- Renamed model `DataSourceMissingDataPointFillType` to `DataFeedMissingDataPointFillType`.
+- Renamed properties on `MetricEnrichedSeriesData` and `MetricSeriesData` model.
+- Renamed method `setSeverity` to `setSeverityRangeCondition` on `MetricAnomalyAlertConditions` model.
+- Renamed property `confidenceScore` to `contributionScore` and its accessors on `IncidentRootCause` model.
+- Removed model `ListMetricSeriesData` as top and skip parameters are not valid for this API.
+- Moved `startTime` and `endTime` to positional arguments on several methods as they are required.
## 1.0.0-beta.1 (2020-10-07)
Version 1.0.0-beta.1 is a preview of our efforts in creating a Azure Metrics Advisor client library that is developer-friendly
diff --git a/sdk/metricsadvisor/azure-ai-metricsadvisor/README.md b/sdk/metricsadvisor/azure-ai-metricsadvisor/README.md
index 70bfec8d0c20..07410cf507ef 100644
--- a/sdk/metricsadvisor/azure-ai-metricsadvisor/README.md
+++ b/sdk/metricsadvisor/azure-ai-metricsadvisor/README.md
@@ -1,9 +1,9 @@
# Azure Metrics Advisor client library for Java
Azure Metrics Advisor is a new Cognitive Service that uses time series based decision AI to identify and assist
trouble shooting the incidents of online services, and monitor the business health by automating the slice and dice
-of business metrics.
+of business dataFeedMetrics.
-[Source code][source_code] | [Package (Maven)] | [API reference documentation][api_reference_doc] | [Product Documentation][product_documentation] | [Samples][samples]
+[Source code][source_code] | [Package (Maven)][mvn_package] | [API reference documentation][api_reference_doc] | [Product Documentation][product_documentation] | [Samples][samples]
## Getting started
@@ -44,7 +44,7 @@ az cognitiveservices account show --name "resource-name" --resource-group "resou
```
#### Create a Metrics Advisor client using MetricsAdvisorKeyCredential
-
+
```java
MetricsAdvisorKeyCredential credential = new MetricsAdvisorKeyCredential("subscription_key", "api_key");
MetricsAdvisorClient metricsAdvisorClient = new MetricsAdvisorClientBuilder()
@@ -54,10 +54,10 @@ MetricsAdvisorClient metricsAdvisorClient = new MetricsAdvisorClientBuilder()
```
#### Create a Metrics Administration client using MetricsAdvisorKeyCredential
-
+
```java
MetricsAdvisorKeyCredential credential = new MetricsAdvisorKeyCredential("subscription_key", "api_key");
-MetricsAdvisorAdministrationClient metricsAdvisorAdministrationClient =
+MetricsAdvisorAdministrationClient metricsAdvisorAdminClient =
new MetricsAdvisorAdministrationClientBuilder()
.endpoint("{endpoint}")
.credential(credential)
@@ -68,44 +68,47 @@ MetricsAdvisorAdministrationClient metricsAdvisorAdministrationClient =
### MetricsAdvisorClient
`MetricsAdvisorClient` helps with:
-- listing incidents
-- listing root causes of incidents
-- retrieving original time series data and time series data enriched by the service.
-- listing alerts
-- adding feedback to tune your model
+- Diagnose anomalies and incidents and help with root cause analysis of incidents.
+- Retrieve original time series data and time series data enriched by the service.
+- Send real time alerts through multiple notification hooks.
+- Adjust anomaly/incident detection using feedback to tune your model.
### MetricsAdvisorAdministrationClient
`MetricsAdvisorAdministrationClient` allows you to
-- manage data feeds
-- configure anomaly detection configurations
-- configure anomaly alerting configurations
-- manage hooks
+- Manage data feeds
+- List available metrics and their detection configurations
+- Fine tune anomaly detection configurations
+- Configure anomaly alerting configurations
+- Manage notification hooks
### Data feed
-A `data feed` is what Metrics Advisor ingests from the user-specified data source such as Cosmos structure stream, SQL query result, and so on.
-A data feed contains rows of timestamps, zero or more dimensions, one or more metrics. Therefore, multiple metrics could share the same data source and even the same data feed.
+A data feed is what Metrics Advisor ingests from the user-specified data source such as Cosmos structure stream, SQL query result, and so on.
+It contains rows of timestamps, zero or more dimensions, one or more Metrics. Therefore, multiple metrics could share the same data source and even the same data feed.
-### Metric
-A `metric` is a quantifiable measure that is used to track and assess the status of a specific business process. It can be a combination of multiple time series values divided by dimensions, for example user count for a web vertical and en-us market.
+### Data Feed Metric
+A metric is a quantifiable measure that is used to track and assess the status of a specific business process. It can be a combination of multiple time series values divided by dimensions, for example user count for a web vertical and en-us market.
-### Dimension
-A `dimension` is one or more categorical values. The combination of those values identifies a particular univariate time series, for example: country, language, tenant, and so on.
+### Data Feed Dimension
+A dimension is one or more categorical values of the provided data feed. The combination of those values identifies a particular univariate time series, for example: country, language, tenant, and so on.
-### Time series
-A time series is a series of data points indexed (or listed or graphed) in time order. Most commonly, a time series is a sequence taken at successive equally spaced points in time. Therefore, it is a sequence of discrete-time data.
+### Metric series
+Metric series is a series of data points indexed (or listed or graphed) in time order. Most commonly, a time series is a sequence taken at successive equally spaced points in time. Therefore, it is a sequence of discrete-time data.
-### AnomalyDetectionConfiguration
-An `anomaly detection configuration` is a configuration supplied for a time series to identify if the data point is detected as an Anomaly.
+### Anomaly Detection Configuration
+An anomaly detection configuration is a configuration supplied for a time series to identify if the data point is detected as an Anomaly.
+A metric can apply one or more detecting configurations. While a default detection configuration is automatically applied to each metric (named "Default"),
+we can tune the detection modes used on our data by creating a customized anomaly detection configuration.
-### Incident
-`Incidents` are generated for series when it has an Anomaly depending on the applied Anomaly detection configurations.
+### Anomaly Incident
+Incidents are generated for series when it has an anomaly depending on the applied Anomaly detection configurations.
+Metrics Advisor service groups series of anomalies within a metric into an incident.
-### Alert
-`Alerts` can be configured to be triggered when certain anomalies are met. You can set multiple alerts with different settings. For example, you could create an alert for anomalies with lower business impact, and another for more important alerts.
+### Anomaly Alert
+Anomaly Alerts can be configured to be triggered when certain anomalies are met. You can set multiple alerts with different settings. For example, you could create an anomalyAlert for anomalies with lower business impact, and another for more important alerts.
-### Hook
-`Hook` is the entry point that allows the users to subscribe to real-time alerts. These alerts are sent over the internet, using a Hook.
+### Notification Hook
+A notification hook is the entry point that allows the users to subscribe to real-time alerts. These alerts are sent over the internet, using a Hook.
## Examples
@@ -113,33 +116,33 @@ An `anomaly detection configuration` is a configuration supplied for a time seri
* [Check ingestion status](#check-ingestion-status "Check ingestion status")
* [Configure anomaly detection configuration](#configure-anomaly-detection-configuration "Configure anomaly detection configuration")
* [Add hooks for receiving anomaly alerts](#add-hooks-for-receiving-anomaly-alerts "Add hooks for receiving anomaly alerts")
-* [Configure alert configuration](#configure-alert-configuration "Configure alert configuration")
+* [Configure an anomaly alert configuration](#configure-anomaly-alert-configuration "Configure anomalyAlert configuration")
* [Query anomaly detection results](#query-anomaly-detection-results "Query anomaly detection results")
#### Add a data feed from a sample or data source
This example ingests the user specified `SQLServerDataFeedSource` data feed source data to the service.
-
+
```java
-final DataFeed createdSqlDataFeed = metricsAdvisorAdministrationClient.createDataFeed(
- "My data feed name",
- new SQLServerDataFeedSource("sql_server_connection_string", "query"),
- new DataFeedGranularity().setGranularityType(DataFeedGranularityType.DAILY),
- new DataFeedSchema(Arrays.asList(
- new Metric().setName("cost"),
- new Metric().setName("revenue")))
- .setDimensions(Arrays.asList(
- new Dimension().setName("category"),
- new Dimension().setName("city"))),
- new DataFeedIngestionSettings(OffsetDateTime.parse("2020-01-01T00:00:00Z")),
- new DataFeedOptions()
- .setDescription("My data feed description")
- .setRollupSettings(
- new DataFeedRollupSettings()
- .setAutoRollup(DataFeedAutoRollUpMethod.SUM, Arrays.asList("cost"), "__CUSTOM_SUM__"))
- .setMissingDataPointFillSettings(
- new DataFeedMissingDataPointFillSettings()
- .setFillType(DataSourceMissingDataPointFillType.SMART_FILLING))
- .setAccessMode(DataFeedAccessMode.PUBLIC));
+DataFeed dataFeed = new DataFeed()
+ .setName("dataFeedName")
+ .setSource(new MySqlDataFeedSource("conn-string", "query"))
+ .setGranularity(new DataFeedGranularity().setGranularityType(DataFeedGranularityType.DAILY))
+ .setSchema(new DataFeedSchema(
+ Arrays.asList(
+ new DataFeedMetric().setName("cost"),
+ new DataFeedMetric().setName("revenue")
+ )).setDimensions(
+ Arrays.asList(
+ new DataFeedDimension().setName("city"),
+ new DataFeedDimension().setName("category")
+ ))
+ )
+ .setIngestionSettings(new DataFeedIngestionSettings(OffsetDateTime.parse("2020-01-01T00:00:00Z")))
+ .setOptions(new DataFeedOptions()
+ .setDescription("data feed description")
+ .setRollupSettings(new DataFeedRollupSettings()
+ .setRollupType(DataFeedRollupType.AUTO_ROLLUP)));
+final DataFeed createdSqlDataFeed = metricsAdvisorAdminClient.createDataFeed(dataFeed);
System.out.printf("Data feed Id : %s%n", createdSqlDataFeed.getId());
System.out.printf("Data feed name : %s%n", createdSqlDataFeed.getName());
@@ -150,10 +153,10 @@ System.out.printf("Data feed granularity type : %s%n",
System.out.printf("Data feed granularity value : %d%n",
createdSqlDataFeed.getGranularity().getCustomGranularityValue());
System.out.println("Data feed related metric Ids:");
-createdSqlDataFeed.getMetricIds().forEach(metricId -> System.out.println(metricId));
+createdSqlDataFeed.getMetricIds().forEach(System.out::println);
System.out.printf("Data feed source type: %s%n", createdSqlDataFeed.getSourceType());
-if (SQL_SERVER_DB.equals(createdSqlDataFeed.getSourceType())) {
+if (SQL_SERVER_DB == createdSqlDataFeed.getSourceType()) {
System.out.printf("Data feed sql server query: %s%n",
((SQLServerDataFeedSource) createdSqlDataFeed.getSource()).getQuery());
}
@@ -161,11 +164,11 @@ if (SQL_SERVER_DB.equals(createdSqlDataFeed.getSourceType())) {
#### Check ingestion status
This example checks the ingestion status of a previously provided data feed source.
-
+
```java
String dataFeedId = "3d48er30-6e6e-4391-b78f-b00dfee1e6f5";
-metricsAdvisorAdministrationClient.listDataFeedIngestionStatus(
+metricsAdvisorAdminClient.listDataFeedIngestionStatus(
dataFeedId,
new ListDataFeedIngestionOptions(
OffsetDateTime.parse("2020-01-01T00:00:00Z"),
@@ -176,10 +179,11 @@ metricsAdvisorAdministrationClient.listDataFeedIngestionStatus(
System.out.printf("Status : %s%n", dataFeedIngestionStatus.getStatus());
});
```
+
#### Configure anomaly detection configuration
This example demonstrates how a user can configure an anomaly detection configuration for their data.
-
+
```java
String metricId = "3d48er30-6e6e-4391-b78f-b00dfee1e6f5";
@@ -201,9 +205,9 @@ SmartDetectionCondition smartDetectionCondition = new SmartDetectionCondition()
.setSuppressCondition(new SuppressCondition().setMinNumber(1).setMinRatio(2));
final AnomalyDetectionConfiguration anomalyDetectionConfiguration =
- metricsAdvisorAdministrationClient.createMetricAnomalyDetectionConfiguration(
+ metricsAdvisorAdminClient.createMetricAnomalyDetectionConfig(
metricId,
- new AnomalyDetectionConfiguration("My Anomaly detection configuration")
+ new AnomalyDetectionConfiguration("My dataPoint anomaly detection configuration")
.setDescription("anomaly detection config description")
.setWholeSeriesDetectionCondition(
new MetricWholeSeriesDetectionCondition()
@@ -216,26 +220,27 @@ final AnomalyDetectionConfiguration anomalyDetectionConfiguration =
### Add hooks for receiving anomaly alerts
This example creates an email hook that receives anomaly incident alerts.
-
+
```java
-Hook emailHook = new EmailHook("email hook")
- .setDescription("my email hook")
+NotificationHook emailNotificationHook = new EmailNotificationHook("email Hook")
+ .setDescription("my email Hook")
.addEmailToAlert("alertme@alertme.com")
.setExternalLink("https://adwiki.azurewebsites.net/articles/howto/alerts/create-hooks.html");
-final Hook hook = metricsAdvisorAdministrationClient.createHook(emailHook);
-EmailHook createdEmailHook = (EmailHook) hook;
-System.out.printf("Hook Id: %s%n", createdEmailHook.getId());
-System.out.printf("Hook Name: %s%n", createdEmailHook.getName());
-System.out.printf("Hook Description: %s%n", createdEmailHook.getDescription());
-System.out.printf("Hook External Link: %s%n", createdEmailHook.getExternalLink());
-System.out.printf("Hook Emails: %s%n", String.join(",", createdEmailHook.getEmailsToAlert()));
+final NotificationHook notificationHook = metricsAdvisorAdminClient.createHook(emailNotificationHook);
+EmailNotificationHook createdEmailHook = (EmailNotificationHook) notificationHook;
+System.out.printf("Email Hook Id: %s%n", createdEmailHook.getId());
+System.out.printf("Email Hook name: %s%n", createdEmailHook.getName());
+System.out.printf("Email Hook description: %s%n", createdEmailHook.getDescription());
+System.out.printf("Email Hook external Link: %s%n", createdEmailHook.getExternalLink());
+System.out.printf("Email Hook emails to alert: %s%n",
+ String.join(",", createdEmailHook.getEmailsToAlert()));
```
-#### Configure alert configuration
+#### Configure an anomaly alert configuration
This example demonstrates how a user can configure an alerting configuration for detected anomalies in their data.
-
+
```java
String detectionConfigurationId1 = "9ol48er30-6e6e-4391-b78f-b00dfee1e6f5";
String detectionConfigurationId2 = "3e58er30-6e6e-4391-b78f-b00dfee1e6f5";
@@ -243,8 +248,8 @@ String hookId1 = "5f48er30-6e6e-4391-b78f-b00dfee1e6f5";
String hookId2 = "8i48er30-6e6e-4391-b78f-b00dfee1e6f5";
final AnomalyAlertConfiguration anomalyAlertConfiguration
- = metricsAdvisorAdministrationClient.createAnomalyAlertConfiguration(
- new AnomalyAlertConfiguration("My Alert config name")
+ = metricsAdvisorAdminClient.createAnomalyAlertConfig(
+ new AnomalyAlertConfiguration("My anomaly alert config name")
.setDescription("alert config description")
.setMetricAlertConfigurations(
Arrays.asList(
@@ -253,36 +258,36 @@ final AnomalyAlertConfiguration anomalyAlertConfiguration
new MetricAnomalyAlertConfiguration(detectionConfigurationId2,
MetricAnomalyAlertScope.forWholeSeries())
.setAlertConditions(new MetricAnomalyAlertConditions()
- .setSeverityCondition(new SeverityCondition()
- .setMaxAlertSeverity(Severity.HIGH)))
+ .setSeverityRangeCondition(new SeverityCondition()
+ .setMaxAlertSeverity(AnomalySeverity.HIGH)))
))
.setCrossMetricsOperator(MetricAnomalyAlertConfigurationsOperator.AND)
.setIdOfHooksToAlert(Arrays.asList(hookId1, hookId2)));
```
#### Query anomaly detection results
-This example demonstrates how a user can query alerts triggered for an anomaly detection configuration and get anomalies for that alert.
+This example demonstrates how a user can query alerts triggered for an anomaly detection configuration and get anomalies for that anomalyAlert.
```java
String alertConfigurationId = "9ol48er30-6e6e-4391-b78f-b00dfee1e6f5";
+final OffsetDateTime startTime = OffsetDateTime.parse("2020-01-01T00:00:00Z");
+final OffsetDateTime endTime = OffsetDateTime.parse("2020-09-09T00:00:00Z");
metricsAdvisorClient.listAlerts(
alertConfigurationId,
- new ListAlertOptions(OffsetDateTime.parse("2020-01-01T00:00:00Z"),
- OffsetDateTime.now(),
- TimeMode.ANOMALY_TIME))
+ startTime, endTime)
.forEach(alert -> {
- System.out.printf("Alert Id: %s%n", alert.getId());
- System.out.printf("Alert created on: %s%n", alert.getCreatedTime());
+ System.out.printf("AnomalyAlert Id: %s%n", alert.getId());
+ System.out.printf("AnomalyAlert created on: %s%n", alert.getCreatedTime());
// List anomalies for returned alerts
metricsAdvisorClient.listAnomaliesForAlert(
alertConfigurationId,
alert.getId())
.forEach(anomaly -> {
- System.out.printf("Anomaly was created on: %s%n", anomaly.getCreatedTime());
- System.out.printf("Anomaly severity: %s%n", anomaly.getSeverity().toString());
- System.out.printf("Anomaly status: %s%n", anomaly.getStatus());
- System.out.printf("Anomaly related series key: %s%n", anomaly.getSeriesKey().asMap());
+ System.out.printf("DataPoint Anomaly was created on: %s%n", anomaly.getCreatedTime());
+ System.out.printf("DataPoint Anomaly severity: %s%n", anomaly.getSeverity().toString());
+ System.out.printf("DataPoint Anomaly status: %s%n", anomaly.getStatus());
+ System.out.printf("DataPoint Anomaly related series key: %s%n", anomaly.getSeriesKey().asMap());
});
});
```
@@ -293,7 +298,7 @@ Metrics Advisor clients raises `HttpResponseException` [exceptions][http_respons
to provide a non existing feedback Id an `HttpResponseException` would be raised with an error indicating the failure cause.
In the following code snippet, the error is handled
gracefully by catching the exception and display the additional information about the error.
-
+
```java
try {
metricsAdvisorClient.getMetricFeedback("non_existing_feedback_id");
@@ -302,7 +307,6 @@ try {
}
```
-
### Enable client logging
Azure SDKs for Java offer a consistent logging story to help aid in troubleshooting application errors and expedite
their resolution. The logs produced will capture the flow of an application before reaching the terminal state to help
@@ -319,7 +323,7 @@ For more details see the [samples README][samples_readme].
#### Async APIs
All the examples shown so far have been using synchronous APIs, but we provide full support for async APIs as well.
You'll need to use `MetricsAdvisorAsyncClient`
-
+
```java
MetricsAdvisorKeyCredential credential = new MetricsAdvisorKeyCredential("subscription_key", "api_key");
MetricsAdvisorAsyncClient metricsAdvisorAsyncClient = new MetricsAdvisorClientBuilder()
@@ -355,9 +359,11 @@ This project has adopted the [Microsoft Open Source Code of Conduct][coc]. For m
[coc_faq]: https://opensource.microsoft.com/codeofconduct/faq/
[coc_contact]: mailto:opencode@microsoft.com
[create_new_resource]: https://docs.microsoft.com/azure/cognitive-services/cognitive-services-apis-create-account?tabs=multiservice%2Cwindows#create-a-new-azure-cognitive-services-resource
+[http_clients_wiki]: https://github.com/Azure/azure-sdk-for-java/wiki/HTTP-clients
[jdk_link]: https://docs.microsoft.com/java/azure/jdk/?view=azure-java-stable
[metrics_advisor_account]: https://ms.portal.azure.com/#create/Microsoft.CognitiveServicesMetricsAdvisor
-[metrics_advisor_doc]: https://docs.microsoft.com/en-gb/azure/cognitive-services/metrics-advisor/glossary
+[metrics_advisor_doc]: https://docs.microsoft.com/azure/cognitive-services/Metrics-advisor/glossary
+[mvn_package]: https://search.maven.org/artifact/com.azure/azure-ai-metricsadvisor/1.0.0-beta.1/jar
[product_documentation]: https://docs.microsoft.com/azure/cognitive-services/metrics-advisor/overview
[source_code]: https://github.com/Azure/azure-sdk-for-java/tree/master/sdk/metricsadvisor/azure-ai-metricsadvisor/src
[samples]: https://github.com/Azure/azure-sdk-for-java/tree/master/sdk/metricsadvisor/azure-ai-metricsadvisor/src/samples
diff --git a/sdk/metricsadvisor/azure-ai-metricsadvisor/pom.xml b/sdk/metricsadvisor/azure-ai-metricsadvisor/pom.xml
index f514db2e78a7..937c7360cd5f 100644
--- a/sdk/metricsadvisor/azure-ai-metricsadvisor/pom.xml
+++ b/sdk/metricsadvisor/azure-ai-metricsadvisor/pom.xml
@@ -32,13 +32,6 @@
HEAD
-
- UTF-8
-
- 0.49
- 0.68
-
-
com.azure
@@ -107,13 +100,6 @@
--add-exports com.azure.core/com.azure.core.implementation.http=ALL-UNNAMED
--add-opens com.azure.ai.metricsadvisor/com.azure.ai.metricsadvisor=ALL-UNNAMED
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
- 3.0.0-M3
-
diff --git a/sdk/metricsadvisor/azure-ai-metricsadvisor/src/main/java/com/azure/ai/metricsadvisor/MetricsAdvisorAsyncClient.java b/sdk/metricsadvisor/azure-ai-metricsadvisor/src/main/java/com/azure/ai/metricsadvisor/MetricsAdvisorAsyncClient.java
index b3e766b291ea..8a28cec4c5e3 100644
--- a/sdk/metricsadvisor/azure-ai-metricsadvisor/src/main/java/com/azure/ai/metricsadvisor/MetricsAdvisorAsyncClient.java
+++ b/sdk/metricsadvisor/azure-ai-metricsadvisor/src/main/java/com/azure/ai/metricsadvisor/MetricsAdvisorAsyncClient.java
@@ -3,13 +3,7 @@
package com.azure.ai.metricsadvisor;
-import com.azure.ai.metricsadvisor.implementation.util.AnomalyTransforms;
import com.azure.ai.metricsadvisor.implementation.AzureCognitiveServiceMetricsAdvisorRestAPIOpenAPIV2Impl;
-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.models.AlertingResultQuery;
import com.azure.ai.metricsadvisor.implementation.models.AnomalyDimensionQuery;
import com.azure.ai.metricsadvisor.implementation.models.AnomalyFeedback;
@@ -33,27 +27,32 @@
import com.azure.ai.metricsadvisor.implementation.models.PeriodFeedback;
import com.azure.ai.metricsadvisor.implementation.models.PeriodFeedbackValue;
import com.azure.ai.metricsadvisor.implementation.models.SeriesIdentity;
+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.Alert;
-import com.azure.ai.metricsadvisor.models.Anomaly;
+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.ErrorCodeException;
-import com.azure.ai.metricsadvisor.models.Incident;
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.ListDimensionValuesWithAnomaliesOptions;
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.ListMetricSeriesDataOptions;
import com.azure.ai.metricsadvisor.models.ListMetricSeriesDefinitionOptions;
-import com.azure.ai.metricsadvisor.models.ListValuesOfDimensionWithAnomaliesOptions;
import com.azure.ai.metricsadvisor.models.MetricAnomalyFeedback;
import com.azure.ai.metricsadvisor.models.MetricChangePointFeedback;
import com.azure.ai.metricsadvisor.models.MetricCommentFeedback;
@@ -122,49 +121,55 @@ public class MetricsAdvisorAsyncClient {
* List series definition for a metric.
*
* Code sample
- * {@codesnippet com.azure.ai.metricsadvisor.MetricsAdvisorAsyncClient.listMetricSeriesDefinitions#String-ListMetricSeriesDefinitionOptions}
+ * {@codesnippet com.azure.ai.metricsadvisor.MetricsAdvisorAsyncClient.listMetricSeriesDefinitions#String-OffsetDateTime-ListMetricSeriesDefinitionOptions}
*
* @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.
*
* @return A {@link PagedFlux} of the {@link MetricSeriesDefinition metric series definitions}.
* @throws IllegalArgumentException thrown if {@code metricId} fail the UUID format validation.
* @throws ErrorCodeException thrown if the request is rejected by server.
- * @throws NullPointerException thrown if the {@code metricId} or {@code options.activeSince}
+ * @throws NullPointerException thrown if the {@code metricId} or {@code activeSince}
* is null.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedFlux listMetricSeriesDefinitions(
String metricId,
- ListMetricSeriesDefinitionOptions options) {
+ OffsetDateTime activeSince, ListMetricSeriesDefinitionOptions options) {
try {
return new PagedFlux<>(() ->
withContext(context ->
- listMetricSeriesDefinitionSinglePageAsync(metricId, options, context)),
+ listMetricSeriesDefinitionSinglePageAsync(metricId, activeSince, options, context)),
continuationToken ->
- withContext(context -> listMetricSeriesDefinitionNextPageAsync(continuationToken, options,
- context)));
+ withContext(context -> listMetricSeriesDefinitionNextPageAsync(continuationToken, activeSince,
+ options, context)));
} catch (RuntimeException ex) {
return new PagedFlux<>(() -> monoError(logger, ex));
}
}
PagedFlux listMetricSeriesDefinitions(String metricId,
- ListMetricSeriesDefinitionOptions options, Context context) {
- return new PagedFlux<>(() -> listMetricSeriesDefinitionSinglePageAsync(metricId, options, context),
- continuationToken -> listMetricSeriesDefinitionNextPageAsync(continuationToken, options, context));
+ OffsetDateTime activeSince, ListMetricSeriesDefinitionOptions options, Context context) {
+ return new PagedFlux<>(() -> listMetricSeriesDefinitionSinglePageAsync(metricId, activeSince, options,
+ context),
+ continuationToken -> listMetricSeriesDefinitionNextPageAsync(continuationToken, activeSince, options,
+ context));
}
private Mono> listMetricSeriesDefinitionSinglePageAsync(String metricId,
- ListMetricSeriesDefinitionOptions options, Context context) {
- Objects.requireNonNull(options, "'options' cannot be null.");
+ OffsetDateTime activeSince, ListMetricSeriesDefinitionOptions options, Context context) {
+
+ if (activeSince == null) {
+ Objects.requireNonNull(options, "'activeSince' is required and cannot be null.");
+ }
- if (options.getActiveSince() == null) {
- Objects.requireNonNull(options, "'options.activeSince' is required and cannot be null.");
+ if (options == null) {
+ options = new ListMetricSeriesDefinitionOptions();
}
final MetricSeriesQueryOptions metricSeriesQueryOptions = new MetricSeriesQueryOptions()
- .setActiveSince(options.getActiveSince()).setDimensionFilter(options.getDimensionCombinationsToFilter());
+ .setActiveSince(activeSince).setDimensionFilter(options.getDimensionCombinationsToFilter());
return service.getMetricSeriesSinglePageAsync(UUID.fromString(metricId), metricSeriesQueryOptions,
options.getSkip(), options.getTop(), context)
@@ -175,16 +180,19 @@ private Mono> listMetricSeriesDefinitionSi
}
private Mono> listMetricSeriesDefinitionNextPageAsync(String nextPageLink,
- ListMetricSeriesDefinitionOptions options, Context context) {
+ OffsetDateTime activeSince, ListMetricSeriesDefinitionOptions options, Context context) {
if (CoreUtils.isNullOrEmpty(nextPageLink)) {
return Mono.empty();
}
- Objects.requireNonNull(options, "'options' cannot be null.");
- if (options.getActiveSince() == null) {
- Objects.requireNonNull(options, "'options.activeSince' is required and cannot be null.");
+ if (activeSince == null) {
+ Objects.requireNonNull(options, "'activeSince' is required and cannot be null.");
+ }
+
+ if (options == null) {
+ options = new ListMetricSeriesDefinitionOptions();
}
final MetricSeriesQueryOptions metricSeriesQueryOptions = new MetricSeriesQueryOptions()
- .setActiveSince(options.getActiveSince()).setDimensionFilter(options.getDimensionCombinationsToFilter());
+ .setActiveSince(activeSince).setDimensionFilter(options.getDimensionCombinationsToFilter());
return service.getMetricSeriesNextSinglePageAsync(nextPageLink, metricSeriesQueryOptions, context)
.doOnSubscribe(ignoredValue -> logger.info("Retrieving the next listing page - Page {}", nextPageLink))
@@ -198,7 +206,7 @@ private Mono> listMetricSeriesDefinitionNe
* Get time series data from metric.
*
* Code sample
- * {@codesnippet com.azure.ai.metricsadvisor.MetricsAdvisorAsyncClient.listMetricSeriesData#String-List-ListMetricSeriesDataOptions}
+ * {@codesnippet com.azure.ai.metricsadvisor.MetricsAdvisorAsyncClient.listMetricSeriesData#String-List-OffsetDateTime-OffsetDateTime}
*
* @param metricId metric unique id.
* @param seriesKeys the series key to filter.
@@ -206,20 +214,21 @@ private Mono> listMetricSeriesDefinitionNe
* 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 options query time series data condition.
+ * @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 PagedFlux} of the {@link MetricSeriesData metric series data points}.
* @throws IllegalArgumentException thrown if {@code metricId} fail the UUID format validation.
* @throws ErrorCodeException thrown if the request is rejected by server.
- * @throws NullPointerException thrown if the {@code metricId}, {@code options.startTime} or {@code options.endTime}
+ * @throws NullPointerException thrown if the {@code metricId}, {@code startTime} or {@code endTime}
* is null.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedFlux listMetricSeriesData(
- String metricId, List seriesKeys, ListMetricSeriesDataOptions options) {
+ String metricId, List seriesKeys, OffsetDateTime startTime, OffsetDateTime endTime) {
try {
return new PagedFlux<>(() -> withContext(context -> listMetricSeriesDataInternal(metricId, seriesKeys,
- options, context)),
+ startTime, endTime, context)),
null);
} catch (RuntimeException ex) {
return new PagedFlux<>(() -> monoError(logger, ex));
@@ -227,25 +236,28 @@ public PagedFlux listMetricSeriesData(
}
PagedFlux listMetricSeriesData(String metricId, List seriesKeys,
- ListMetricSeriesDataOptions options, Context context) {
- return new PagedFlux<>(() -> listMetricSeriesDataInternal(metricId, seriesKeys, options, context), null);
+ OffsetDateTime startTime, OffsetDateTime endTime, Context context) {
+ return new PagedFlux<>(() -> listMetricSeriesDataInternal(metricId, seriesKeys, startTime, endTime, context),
+ null);
}
private Mono> listMetricSeriesDataInternal(String metricId,
- List seriesKeys, ListMetricSeriesDataOptions options,
- Context context) {
+ List seriesKeys, OffsetDateTime startTime,
+ OffsetDateTime endTime, Context context) {
Objects.requireNonNull(metricId, "'metricId' cannot be null.");
- Objects.requireNonNull(options, "'options' cannot be null.");
- Objects.requireNonNull(options.getStartTime(), "'options.startTime' cannot be null.");
- Objects.requireNonNull(options.getEndTime(), "'options.endTime' cannot be null.");
+ Objects.requireNonNull(startTime, "'startTime' cannot be null.");
+ Objects.requireNonNull(endTime, "'endTime' cannot be null.");
if (CoreUtils.isNullOrEmpty(seriesKeys)) {
Objects.requireNonNull(seriesKeys, "'seriesKeys' cannot be null or empty.");
}
List