MetricsAdvisorClient class
Client class for interacting with Azure Metrics Advisor Service to query alerts/incidents/anomalies, diagnose incidents, provide metric feedback
Constructors
Metrics |
Creates an instance of MetricsAdvisorClient. Example usage:
|
Properties
endpoint |
Url to service endpoint |
Methods
add |
Creates a metric feedback. |
get |
Retrieves a metric feedback for the given feedback id. |
get |
Gets the root causes of an incident. |
get |
Retrieves enriched metric series data for a detection configuration |
get |
Gets the time series data for a metric |
list |
Returns an async iterable iterator to list alerts for an alert configuration.
Example using
Example using
Example using
|
list |
Returns an async iterable iterator to list anamolies associated with an alert
Example using
Example using
Example using
|
list |
Returns an async iterable iterator to list anomalies for a detection configuration.
Example using
Example using
Example using
|
list |
Returns an async iterable iterator to list dimension values of anomalies detected by a detection configuration.
Example using
Example using
Example using
|
list |
Returns an async iterable iterator to list feedbacks for a metric.
Example using
Example using
Example using
|
list |
Returns an async iterable iterator to list incidents associated with an alert
Example using
Example using
Example using
|
list |
Returns an async iterable iterator to list incidents for an anomaly detection configuration.
Example using
Example using
Example using
|
list |
Returns an async iterable iterator to list all the values for a metric dimension.
Example using
Example using
Example using
|
list |
Returns an async iterable iterator to list incidents for an anomaly detection configuration.
Example using
Example using
Example using
|
list |
Returns an async iterable iterator to list series definitions (dimension combinations) for a metric.
Example using
Example using
Example using
|
Constructor Details
MetricsAdvisorClient(string, TokenCredential | MetricsAdvisorKeyCredential, MetricsAdvisorClientOptions)
Creates an instance of MetricsAdvisorClient.
Example usage:
import { MetricsAdvisorClient, MetricsAdvisorKeyCredential } from "@azure/ai-metrics-advisor";
const client = new MetricsAdvisorClient(
"<service endpoint>",
new MetricsAdvisorKeyCredential("<subscription key>", "<api key>")
);
new MetricsAdvisorClient(endpointUrl: string, credential: TokenCredential | MetricsAdvisorKeyCredential, options?: MetricsAdvisorClientOptions)
Parameters
- endpointUrl
-
string
Url to an Azure Metrics Advisor service endpoint
- credential
Used to authenticate requests to the service.
- options
- MetricsAdvisorClientOptions
Used to configure the Metrics Advisor client.
Property Details
endpointUrl
Url to service endpoint
endpointUrl: string
Property Value
string
Method Details
addFeedback(MetricFeedbackUnion, OperationOptions)
Creates a metric feedback.
function addFeedback(feedback: MetricFeedbackUnion, options?: OperationOptions): Promise<MetricFeedbackUnion>
Parameters
- feedback
- MetricFeedbackUnion
Content of the feedback
- options
- OperationOptions
The options parameter
Returns
Promise<MetricFeedbackUnion>
Response with Feedback object
getFeedback(string, OperationOptions)
Retrieves a metric feedback for the given feedback id.
function getFeedback(id: string, options?: OperationOptions): Promise<MetricFeedbackUnion>
Parameters
- id
-
string
Id of the feedback to retrieve
- options
- OperationOptions
The options parameter
Returns
Promise<MetricFeedbackUnion>
getIncidentRootCauses(string, string, OperationOptions)
Gets the root causes of an incident.
function getIncidentRootCauses(detectionConfigId: string, incidentId: string, options?: OperationOptions): Promise<GetIncidentRootCauseResponse>
Parameters
- detectionConfigId
-
string
Anomaly detection configuration id
- incidentId
-
string
Incident id
- options
- OperationOptions
The options parameter
Returns
Promise<GetIncidentRootCauseResponse>
getMetricEnrichedSeriesData(string, DimensionKey[], string | Date, string | Date, GetMetricEnrichedSeriesDataOptions)
Retrieves enriched metric series data for a detection configuration
function getMetricEnrichedSeriesData(detectionConfigId: string, seriesKey: DimensionKey[], startTime: string | Date, endTime: string | Date, options?: GetMetricEnrichedSeriesDataOptions): Promise<GetMetricEnrichedSeriesDataResponse>
Parameters
- detectionConfigId
-
string
Anomaly detection configuration id
- seriesKey
Series to retrieve their data
- startTime
-
string | Date
The start of time range to query metric enriched series data
- endTime
-
string | Date
The end of time range to query metric enriched series data
The options parameter.
Returns
Promise<GetMetricEnrichedSeriesDataResponse>
getMetricSeriesData(string, DimensionKey[], string | Date, string | Date, GetMetricSeriesDataOptions)
Gets the time series data for a metric
function getMetricSeriesData(metricId: string, seriesKey: DimensionKey[], startTime: string | Date, endTime: string | Date, options?: GetMetricSeriesDataOptions): Promise<GetMetricSeriesDataResponse>
Parameters
- metricId
-
string
Metric id
- seriesKey
A list of time series to retrieve their data
- startTime
-
string | Date
The start of the time range to retrieve series data
- endTime
-
string | Date
The end of the time range to retrieve series data
- options
- GetMetricSeriesDataOptions
The options parameter
Returns
Promise<GetMetricSeriesDataResponse>
listAlerts(string, string | Date, string | Date, AlertQueryTimeMode, ListAlertsOptions)
Returns an async iterable iterator to list alerts for an alert configuration.
.byPage()
returns an async iterable iterator to list the alerts in pages.
Example using for await
syntax:
const client = new MetricsAdvisorClient(endpoint,
new MetricsAdvisorKeyCredential(subscriptionKey, apiKey)
);
const alerts = client.listAlerts(alertConfigId,
startTime, endTime, timeMode
);
let i = 1;
for await (const alert of alerts) {
console.log(`alert ${i++}:`);
console.log(alert);
}
Example using iter.next()
:
let iter = client.listAlerts(alertConfigId, startTime, endTime, timeMode);
let result = await iter.next();
while (!result.done) {
console.log(` alert - ${result.value.id}`);
result = await iter.next();
}
Example using byPage()
:
const pages = client.listAlerts(alertConfigId, startTime, endTime, timeMode)
.byPage({ maxPageSize: 10 });
let page = await pages.next();
let i = 1;
while (!page.done) {
if (page.value) {
console.log(`-- page ${i++}`);
for (const alert of page.value) {
console.log(`${alert}`);
}
}
page = await pages.next();
}
function listAlerts(alertConfigId: string, startTime: string | Date, endTime: string | Date, timeMode: AlertQueryTimeMode, options?: ListAlertsOptions): PagedAsyncIterableIterator<AnomalyAlert, AlertsPageResponse, PageSettings>
Parameters
- alertConfigId
-
string
Anomaly alerting configuration unique id
- startTime
-
string | Date
The start of time range to query alert items for alerting configuration
- endTime
-
string | Date
The end of time range to query alert items for alerting configuration
- timeMode
- AlertQueryTimeMode
Query time mode - "AnomalyTime" | "CreatedTime" | "ModifiedTime"
- options
- ListAlertsOptions
The options parameter.
Returns
listAnomaliesForAlert(AnomalyAlert, ListAnomaliesForAlertConfigurationOptions)
Returns an async iterable iterator to list anamolies associated with an alert
.byPage()
returns an async iterable iterator to list the anomalies in pages.
Example using for await
syntax:
const client = new MetricsAdvisorClient(endpoint,
new MetricsAdvisorKeyCredential(subscriptionKey, apiKey));
const anamolyList = client.listAnomaliesForAlert({alertConfigId, id: alertId});
let i = 1;
for await (const anamoly of anamolyList){
console.log(`anamoly ${i++}:`);
console.log(anamoly);
}
Example using iter.next()
:
let iter = client.listAnomaliesForAlert({alertConfigId, id: alertId});
let result = await iter.next();
while (!result.done) {
console.log(` anamoly - ${result.value.metricId}, ${result.value.detectionConfigurationId} `);
result = await iter.next();
}
Example using byPage()
:
const pages = client.listAnomaliesForAlert({alertConfigId, id: alertId}).byPage({ maxPageSize: 10 });
let page = await pages.next();
let i = 1;
while (!page.done) {
if (page.value) {
console.log(`-- page ${i++}`);
for (const anomaly of page.value) {
console.log(`${anomaly}`);
}
}
page = await pages.next();
}
function listAnomaliesForAlert(alert: AnomalyAlert, options?: ListAnomaliesForAlertConfigurationOptions): PagedAsyncIterableIterator<DataPointAnomaly, AnomaliesPageResponse, PageSettings>
Parameters
- alert
- AnomalyAlert
Anomaly alert containing alertConfigId and id
The options parameter.
Returns
listAnomaliesForDetectionConfiguration(string, string | Date, string | Date, ListAnomaliesForDetectionConfigurationOptions)
Returns an async iterable iterator to list anomalies for a detection configuration.
.byPage()
returns an async iterable iterator to list the anomalies in pages.
Example using for await
syntax:
const client = new MetricsAdvisorClient(endpoint,
new MetricsAdvisorKeyCredential(subscriptionKey, apiKey));
const anomalies = client.listAnomaliesForDetectionConfiguration(detectionConfigId, startTime, endTime);
let i = 1;
for await (const anomaly of anomalies) {
console.log(`anomaly ${i++}:`);
console.log(anomaly);
}
Example using iter.next()
:
let iter = client.listAnomaliesForDetectionConfiguration(detectionConfigId, startTime, endTime);
let result = await iter.next();
while (!result.done) {
console.log(` anomaly - ${result.value.severity} ${result.value.status}`);
console.dir(result.value);
result = await iter.next();
}
Example using byPage()
:
const pages = client.listAnomaliesForDetectionConfiguration(detectionConfigId, startTime, endTime)
.byPage({ maxPageSize: 10 });
let page = await pages.next();
let i = 1;
while (!page.done) {
if (page.value) {
console.log(`-- page ${i++}`);
for (const anomaly of page.value) {
console.dir(anomaly);
}
}
page = await pages.next();
}
function listAnomaliesForDetectionConfiguration(detectionConfigId: string, startTime: string | Date, endTime: string | Date, options?: ListAnomaliesForDetectionConfigurationOptions): PagedAsyncIterableIterator<DataPointAnomaly, AnomaliesPageResponse, PageSettings>
Parameters
- detectionConfigId
-
string
Anomaly detection configuration id
- startTime
-
string | Date
The start of time range to query anomalies
- endTime
-
string | Date
The end of time range to query anomalies
The options parameter.
Returns
listAnomalyDimensionValues(string, string | Date, string | Date, string, ListAnomalyDimensionValuesOptions)
Returns an async iterable iterator to list dimension values of anomalies detected by a detection configuration.
.byPage()
returns an async iterable iterator to list the dimension values in pages.
Example using for await
syntax:
const client = new MetricsAdvisorClient(endpoint,
new MetricsAdvisorKeyCredential(subscriptionKey, apiKey));
const dimensionValues = client
.listAnomalyDimensionValues(detectionConfigId, startTime, endTime, dimensionName);
let i = 1;
for await (const dv of dimensionValues) {
console.log(`dimension value ${i++}: ${dv}`);
Example using iter.next()
:
let iter = client
.listAnomalyDimensionValues(detectionConfigId, startTime, endTime, dimensionName);
let result = await iter.next();
while (!result.done) {
console.log(` dimension value - '${result.value}'`);
result = await iter.next();
}
Example using byPage()
:
const pages = client
.listAnomalyDimensionValues(
detectionConfigId,
startTime,
endTime,
dimensionName
)
.byPage({ maxPageSize: 10 });
let page = await pages.next();
let i = 1;
while (!page.done) {
if (page.value) {
console.log(`-- page ${i++}`);
for (const dv of page.value) {
console.log(` dimension value - '${result.value}'`);
}
}
page = await pages.next();
}
function listAnomalyDimensionValues(detectionConfigId: string, startTime: string | Date, endTime: string | Date, dimensionName: string, options?: ListAnomalyDimensionValuesOptions): PagedAsyncIterableIterator<string, DimensionValuesPageResponse, PageSettings>
Parameters
- detectionConfigId
-
string
Anomaly detection configuration id
- startTime
-
string | Date
The start of time range to query anomalies
- endTime
-
string | Date
The end of time range to query anomalies
- dimensionName
-
string
Name of the dimension for anomaly detection config
The options parameter.
Returns
listFeedback(string, ListFeedbackOptions)
Returns an async iterable iterator to list feedbacks for a metric.
.byPage()
returns an async iterable iterator to list the feedbacks in pages.
Example using for await
syntax:
const client = new MetricsAdvisorClient(endpoint,
new MetricsAdvisorKeyCredential(subscriptionKey, apiKey));
const feedbacks = client.listFeedback(metricId);
let i = 1;
for await (const f of feedbacks){
console.log(`feedback ${i++}:`);
console.log(f);
}
Example using iter.next()
:
let iter = client.listFeedback(metricId);
let result = await iter.next();
while (!result.done) {
console.log(` feedback - ${result.value.id}`);
console.dir(result.value);
result = await iter.next();
}
Example using byPage()
:
const pages = client.listFeedback(metricId)
.byPage({ maxPageSize: 10 });
let page = await pages.next();
let i = 1;
while (!page.done) {
if (page.value) {
console.log(`-- page ${i++}`);
for (const f of page.value) {
console.dir(f);
}
}
page = await pages.next();
}
function listFeedback(metricId: string, options?: ListFeedbackOptions): PagedAsyncIterableIterator<MetricFeedbackUnion, MetricFeedbackPageResponse, PageSettings>
Parameters
- metricId
-
string
Metric id
- options
- ListFeedbackOptions
The options parameter
Returns
listIncidentsForAlert(AnomalyAlert, ListIncidentsForAlertOptions)
Returns an async iterable iterator to list incidents associated with an alert
.byPage()
returns an async iterable iterator to list the incidents in pages.
Example using for await
syntax:
const client = new MetricsAdvisorClient(endpoint,
new MetricsAdvisorKeyCredential(subscriptionKey, apiKey));
const incidentList = client.listIncidentsForAlert(anomalyAlert);
let i = 1;
for await (const incident of incidentList){
console.log(`incident ${i++}:`);
console.log(incident);
}
Example using iter.next()
:
let iter = client.listIncidentsForAlert(anomalyAlert);
let result = await iter.next();
while (!result.done) {
console.log(` incident - ${result.value.id}`);
console.dir(result.value);
result = await iter.next();
}
Example using byPage()
:
const pages = client.listIncidentsForAlert(anomalyAlert).byPage({ maxPageSize: 10 });
let page = await pages.next();
let i = 1;
while (!page.done) {
if (page.value) {
console.log(`-- page ${i++}`);
for (const incident of page.value) {
console.dir(incident);
}
}
page = await pages.next();
}
function listIncidentsForAlert(alert: AnomalyAlert, options?: ListIncidentsForAlertOptions): PagedAsyncIterableIterator<AnomalyIncident, IncidentsPageResponse, PageSettings>
Parameters
- alert
- AnomalyAlert
Anomaly alert containing alertConfigId and id
- options
- ListIncidentsForAlertOptions
The options parameter.
Returns
listIncidentsForDetectionConfiguration(string, string | Date, string | Date, ListIncidentsForDetectionConfigurationOptions)
Returns an async iterable iterator to list incidents for an anomaly detection configuration.
.byPage()
returns an async iterable iterator to list the incidents in pages.
Example using for await
syntax:
const client = new MetricsAdvisorClient(endpoint,
new MetricsAdvisorKeyCredential(subscriptionKey, apiKey));
const incidentList = client
.listIncidentsForDetectionConfiguration(detectionConfigId, startTime, endTime);
let i = 1;
for await (const incident of incidentList){
console.log(`incident ${i++}:`);
console.log(incident);
}
Example using iter.next()
:
let iter = client.listIncidentsForDetectionConfiguration(detectionConfigId, startTime, endTime);
let result = await iter.next();
while (!result.done) {
console.log(` incident - ${result.value.id}`);
console.dir(result.value);
result = await iter.next();
}
Example using byPage()
:
const pages = client.listIncidentsForDetectionConfiguration(detectionConfigId, startTime, endTime)
.byPage({ maxPageSize: 10 });
let page = await pages.next();
let i = 1;
while (!page.done) {
if (page.value) {
console.log(`-- page ${i++}`);
for (const incident of page.value) {
console.dir(incident);
}
}
page = await pages.next();
}
function listIncidentsForDetectionConfiguration(detectionConfigId: string, startTime: string | Date, endTime: string | Date, options?: ListIncidentsForDetectionConfigurationOptions): PagedAsyncIterableIterator<AnomalyIncident, IncidentsPageResponse, PageSettings>
Parameters
- detectionConfigId
-
string
Anomaly detection configuration id
- startTime
-
string | Date
The start of time range to query for incidents
- endTime
-
string | Date
The end of time range to query for incidents
The options parameter.
Returns
listMetricDimensionValues(string, string, ListMetricDimensionValuesOptions)
Returns an async iterable iterator to list all the values for a metric dimension.
.byPage()
returns an async iterable iterator to list the values in pages.
Example using for await
syntax:
const client = new MetricsAdvisorClient(endpoint,
new MetricsAdvisorKeyCredential(subscriptionKey, apiKey));
const values = client.listMetricDimensionValues(metricId, dimensionName);
let i = 1;
for await (const v of values){
console.log(`dimension value ${i++}:`);
console.log(v);
}
Example using iter.next()
:
let iter = client.listMetricDimensionValues(metricId, dimensionName);
let result = await iter.next();
while (!result.done) {
console.log(` dimension value - ${result.value}`);
console.dir(result.value);
result = await iter.next();
}
Example using byPage()
:
const pages = client.listMetricDimensionValues(metricId, dimensionName).byPage({ maxPageSize: 10 });
let page = await pages.next();
let i = 1;
while (!page.done) {
if (page.value) {
console.log(`-- page ${i++}`);
for (const dv of page.value) {
console.dir(dv);
}
}
page = await pages.next();
}
function listMetricDimensionValues(metricId: string, dimensionName: string, options?: ListMetricDimensionValuesOptions): PagedAsyncIterableIterator<string, DimensionValuesPageResponse, PageSettings>
Parameters
- metricId
-
string
Anomaly detection configuration id
- dimensionName
-
string
Name of the dimension to list value
- options
- ListMetricDimensionValuesOptions
The options parameter.
Returns
listMetricEnrichmentStatus(string, string | Date, string | Date, ListMetricEnrichmentStatusOptions)
Returns an async iterable iterator to list incidents for an anomaly detection configuration.
.byPage()
returns an async iterable iterator to list the incidents in pages.
Example using for await
syntax:
const client = new MetricsAdvisorClient(endpoint,
new MetricsAdvisorKeyCredential(subscriptionKey, apiKey));
const statusList = client.listMetricEnrichmentStatus(metricId, startTime, endTime);
let i = 1;
for await (const status of statusList){
console.log(`enrichment status ${i++}:`);
console.log(status);
}
Example using iter.next()
:
let iter = client.listMetricEnrichmentStatus(metricId, startTime, endTime);
let result = await iter.next();
while (!result.done) {
console.log(` enrichment status - ${result.value.status} ${result.value.message}`);
console.dir(result.value);
result = await iter.next();
}
Example using byPage()
:
const pages = client.listMetricEnrichmentStatus(metricId, startTime, endTime)
.byPage({ maxPageSize: 10 });
let page = await pages.next();
let i = 1;
while (!page.done) {
if (page.value) {
console.log(`-- page ${i++}`);
for (const status of page.value) {
console.dir(status);
}
}
page = await pages.next();
}
function listMetricEnrichmentStatus(metricId: string, startTime: string | Date, endTime: string | Date, options?: ListMetricEnrichmentStatusOptions): PagedAsyncIterableIterator<EnrichmentStatus, MetricEnrichmentStatusPageResponse, PageSettings>
Parameters
- metricId
-
string
Metric id
- startTime
-
string | Date
The start of time range to query for enrichment status
- endTime
-
string | Date
The end of time range to query for enrichment status
The options parameter.
Returns
listMetricSeriesDefinitions(string, string | Date, ListMetricSeriesDefinitionsOptions)
Returns an async iterable iterator to list series definitions (dimension combinations) for a metric.
.byPage()
returns an async iterable iterator to list the series definitions in pages.
Example using for await
syntax:
const client = new MetricsAdvisorClient(endpoint,
new MetricsAdvisorKeyCredential(subscriptionKey, apiKey));
const definitions = client.listMetricSeriesDefinitions(metricId, activeSince);
let i = 1;
for await (const definition of definitions){
console.log(`definition ${i++}:`);
console.log(definition);
}
Example using iter.next()
:
let iter = client.listMetricSeriesDefinitions(metricId, activeSince);
let result = await iter.next();
while (!result.done) {
console.log(` definition - ${result.value.metricId} ${result.value.dimension}`);
console.dir(result.value);
result = await iter.next();
}
Example using byPage()
:
const pages = client.listMetricSeriesDefinitions(metricId, activeSince).byPage({ maxPageSize: 10 });
let page = await pages.next();
let i = 1;
while (!page.done) {
if (page.value) {
console.log(`-- page ${i++}`);
for (const definition of page.value) {
console.dir(definition);
}
}
page = await pages.next();
}
function listMetricSeriesDefinitions(metricId: string, activeSince: string | Date, options?: ListMetricSeriesDefinitionsOptions): PagedAsyncIterableIterator<MetricSeriesDefinition, MetricSeriesPageResponse, PageSettings>
Parameters
- metricId
-
string
Metric id
- activeSince
-
string | Date
Definitions of series ingested after this time are returned
The options parameter.