### YamlMime:JavaPackage
uid: "com.azure.ai.metricsadvisor.administration"
fullName: "com.azure.ai.metricsadvisor.administration"
name: "com.azure.ai.metricsadvisor.administration"
summary: "[Azure Metrics Advisor][] is a cloud-based service provided by Microsoft Azure that is designed to help organizations monitor and analyze metrics and time-series data from various sources.\n\n\n[Azure Metrics Advisor]: https://learn.microsoft.com/azure/ai-services/metrics-advisor/"
classes:
- "com.azure.ai.metricsadvisor.administration.MetricsAdvisorAdministrationAsyncClient"
- "com.azure.ai.metricsadvisor.administration.MetricsAdvisorAdministrationClient"
- "com.azure.ai.metricsadvisor.administration.MetricsAdvisorAdministrationClientBuilder"
desc: "[Azure Metrics Advisor][] is a cloud-based service provided by Microsoft Azure that is designed to help organizations monitor and analyze metrics and time-series data from various sources. It is particularly focused on aiding in the detection of anomalies, trends, and patterns within this data, which can be invaluable for improving operational efficiency, identifying issues early, and making data-driven decisions.\n\nHere are some key features and capabilities of Azure Metrics Advisor:\n\n * Anomaly Detection: Azure Metrics Advisor employs machine learning algorithms to automatically identify anomalies in time-series data. It can differentiate between normal variations and unusual patterns, helping organizations detect issues or opportunities for improvement.\n * Time-Series Data Ingestion: The service allows you to ingest time-series data from various sources, including Azure Monitor, Application Insights, IoT Hub, and custom data sources. This flexibility enables you to monitor a wide range of metrics.\n * Data Exploration: Users can explore their data, view historical trends, and gain insights into the behavior of various metrics over time. This can be useful for identifying seasonal patterns and understanding the normal behavior of your systems.\n * Integration with Azure Services: Azure Metrics Advisor integrates with other Azure services, such as Azure Monitor and Azure Data Explorer, making it part of a broader ecosystem for monitoring and analytics.\n * Alerts and Notifications: You can set up alerts and notifications based on detected anomalies or specific thresholds, ensuring that you are informed promptly when issues arise.\n\n## Getting Started ##\n\nThe Azure Metrics Advisor library provides advisor clients like and to connect to the Metrics Advisor Azure Cognitive Service to perform data monitoring. It also provides administration clients like and to build and manage models from custom documents.\n\nService clients are the point of interaction for developers to use Azure Form Recognizer. is the synchronous service client and 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\"][Azure Identity documentation].\n\n**Sample: Construct a MetricsAdvisorClient with DefaultAzureCredential**\n\nThe following code sample demonstrates the creation of a , using the \\`DefaultAzureCredentialBuilder\\` to configure it.\n\n```java\nMetricsAdvisorAdministrationClient metricsAdvisorAdminClient =\n new MetricsAdvisorAdministrationClientBuilder()\n .credential(new DefaultAzureCredentialBuilder().build())\n .endpoint(\"{endpoint}\")\n .buildClient();\n```\n\nFurther, see the code sample below to use for client creation.\n\n```java\nMetricsAdvisorAdministrationClient metricsAdvisorAdminClient =\n new MetricsAdvisorAdministrationClientBuilder()\n .credential(new MetricsAdvisorKeyCredential(\"{subscription_key}\", \"{api_key}\"))\n .endpoint(\"{endpoint}\")\n .buildClient();\n```\n\nLet's take a look at the advisor client scenarios and their respective usage below.\n\n\n--------------------\n\n## Onboard your data by connecting to an SQL data source ##\n\nMetrics Advisor provides connectors for different data sources, such as Azure SQL Database, Azure Data Explorer, and Azure Table Storage.\n\n**Sample: Onboard a given SQL source of data to Metrics Advisor service**\n\nThe following code sample demonstrates to connect data source to create a data feed using an SQL data source\n\n```java\nDataFeed dataFeed = new DataFeed()\n .setName(\"dataFeedName\")\n .setSource(new MySqlDataFeedSource(\"conn-string\", \"query\"))\n .setGranularity(new DataFeedGranularity().setGranularityType(DataFeedGranularityType.DAILY))\n .setSchema(new DataFeedSchema(\n Arrays.asList(\n new DataFeedMetric(\"cost\"),\n new DataFeedMetric(\"revenue\")\n )).setDimensions(\n Arrays.asList(\n new DataFeedDimension(\"city\"),\n new DataFeedDimension(\"category\")\n ))\n )\n .setIngestionSettings(new DataFeedIngestionSettings(OffsetDateTime.parse(\"2020-01-01T00:00:00Z\")))\n .setOptions(new DataFeedOptions()\n .setDescription(\"data feed description\")\n .setRollupSettings(new DataFeedRollupSettings()\n .setRollupType(DataFeedRollupType.AUTO_ROLLUP)));\n\n DataFeed createdDataFeed = metricsAdvisorAdminClient.createDataFeed(dataFeed);\n\n System.out.printf(\"Data feed Id: %s%n\", createdDataFeed.getId());\n System.out.printf(\"Data feed description: %s%n\", createdDataFeed.getOptions().getDescription());\n System.out.printf(\"Data feed source type: %s%n\", createdDataFeed.getSourceType());\n System.out.printf(\"Data feed creator: %s%n\", createdDataFeed.getCreator());\n```\n\n**Note:** For asynchronous sample, refer to API.\n\n\n--------------------\n\n## Subscribe anomalies for notification ##\n\nAfter an anomaly is detected by Metrics Advisor, an alert notification will be triggered based on alert settings, using a hook. An alert setting can be used with multiple detection configurations, various parameters are available to customize your alert rule.\n\nThe following code sample demonstrates how to configure an alert notification for a detected anomaly with multiple detection configurations\n\n**Sample: Configure alerts and get notifications using a hook.**\n\n\\`\\`\\`java readme-sample-createHook\n\n```java\nNotificationHook emailNotificationHook = new EmailNotificationHook(\"email Hook\")\n .setDescription(\"my email Hook\")\n .setEmailsToAlert(Collections.singletonList(\"alertme@alertme.com\"))\n .setExternalLink(\"https://adwiki.azurewebsites.net/articles/howto/alerts/create-hooks.html\");\n\n final NotificationHook notificationHook = metricsAdvisorAdminClient.createHook(emailNotificationHook);\n EmailNotificationHook createdEmailHook = (EmailNotificationHook) notificationHook;\n System.out.printf(\"Email Hook Id: %s%n\", createdEmailHook.getId());\n System.out.printf(\"Email Hook name: %s%n\", createdEmailHook.getName());\n System.out.printf(\"Email Hook description: %s%n\", createdEmailHook.getDescription());\n System.out.printf(\"Email Hook external Link: %s%n\", createdEmailHook.getExternalLink());\n System.out.printf(\"Email Hook emails to alert: %s%n\",\n String.join(\",\", createdEmailHook.getEmailsToAlert()));\n```\n\n**Note:** For asynchronous sample, refer to API.\n\n\n[Azure Metrics Advisor]: https://learn.microsoft.com/azure/ai-services/metrics-advisor/\n[managed identity]: https://learn.microsoft.com/azure/active-directory/managed-identities-azure-resources/\n[Azure Identity documentation]: https://learn.microsoft.com/java/api/overview/azure/identity-readme"
metadata: {}
package: "com.azure.ai.metricsadvisor.administration"
artifact: com.azure:azure-ai-metricsadvisor:1.2.1