Options
All
  • Public
  • Public/Protected
  • All
Menu

Class MetricsAdvisorClient

Package version

Client class for interacting with Azure Metrics Advisor Service to query alerts/incidents/anomalies, diagnose incidents, provide metric feedback

Hierarchy

  • MetricsAdvisorClient

Index

Constructors

constructor

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

    Parameters

    Returns MetricsAdvisorClient

Properties

endpointUrl

endpointUrl: string

Url to service endpoint

Methods

createMetricFeedback

getIncidentRootCauses

  • Gets the root causes of an incident.

    Parameters

    • detectionConfigId: string

      Anomaly detection configuration id

    • incidentId: string

      Incident id

    • Default value options: OperationOptions = {}

      The options parameter

    Returns Promise<GetIncidentRootCauseResponse>

getMetricEnrichedSeriesData

getMetricFeedback

  • Retrives a metric feedback for the given feedback id.

    Parameters

    • id: string

      Id of the feedback to retrieve

    • Default value options: OperationOptions = {}

      The options parameter

    Returns Promise<GetFeedbackResponse>

getMetricSeriesData

  • Gets the time series data for a metric

    Parameters

    • metricId: string

      Metric id

    • startTime: Date

      The start of the time range to retrieve series data

    • endTime: Date

      The end of the time range to retrieve series data

    • seriesToFilter: Record<string, string>[]

      A list of time series to retrieve their data

    • Default value options: GetMetricSeriesDataOptions = {}

      The optiosn parameter

    Returns Promise<GetMetricSeriesDataResponse>

listAlertsForAlertConfiguration

  • 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.listAlertsForAlertConfiguration(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.listAlertsForAlertConfiguration(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.listAlertsForAlertConfiguration(alertConfigId, startTime, endTime, timeMode)
      .byPage({ maxPageSize: 10 });
    let page = await pages.next();
    let i = 1;
    while (!page.done) {
     if (page.value.alerts) {
       console.log(`-- page ${i++}`);
       for (const alert of page.value.alerts) {
         console.log(`${alert}`);
       }
     }
     page = await pages.next();
    }
    

    Parameters

    • alertConfigId: string

      anomaly alerting configuration unique id

    • startTime: Date

      The start of time range to query alert items for alerting configuration

    • endTime: Date

      The end of time range to query alert items for alerting configuration

    • timeMode: TimeMode

      Query time mode - "AnomalyTime" | "CreatedTime" | "ModifiedTime"

    • Default value options: ListAlertsOptions = {}

      The options parameter.

    Returns PagedAsyncIterableIterator<Alert, ListAlertsForAlertConfigurationPageResponse>

listAnomaliesForAlert

  • 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, 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, 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, alertId).byPage({ maxPageSize: 10 });
    let page = await pages.next();
    let i = 1;
    while (!page.done) {
     if (page.value.anomalies) {
       console.log(`-- page ${i++}`);
       for (const anomaly of page.value.anomalies) {
         console.log(`${anomaly}`);
       }
     }
     page = await pages.next();
    }
    

    Parameters

    Returns PagedAsyncIterableIterator<Anomaly, ListAnomaliesForAlertPageResponse>

listAnomaliesForDetectionConfiguration

  • 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.anomalies) {
       console.log(`-- page ${i++}`);
       for (const anomaly of page.value.anomalies) {
         console.dir(anomaly);
       }
     }
     page = await pages.next();
    }
    

    Parameters

    • detectionConfigId: string

      Anomaly detection configuration id

    • startTime: Date

      The start of time range to query anomalies

    • endTime: Date

      The end of time range to query anomalies

    • Default value options: ListAnomaliesForDetectionConfigurationOptions = {}

      The options parameter.

    Returns PagedAsyncIterableIterator<Anomaly, ListAnomaliesForDetectionConfigurationPageResponse>

listDimensionValuesForDetectionConfiguration

  • Returns an async iterable iterator to list dimension values for 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
      .listDimensionValuesForDetectionConfiguration(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
      .listDimensionValuesForDetectionConfiguration(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
      .listDimensionValuesForDetectionConfiguration(
        detectionConfigId,
        startTime,
        endTime,
        dimensionName
      )
      .byPage({ maxPageSize: 10 });
    let page = await pages.next();
    let i = 1;
    while (!page.done) {
      if (page.value.dimensionValues) {
        console.log(`-- page ${i++}`);
        for (const dv of page.value.dimensionValues) {
          console.log(` dimension value - '${result.value}'`);
        }
      }
      page = await pages.next();
    }

    Parameters

    • detectionConfigId: string

      Anomaly detection configuration id

    • startTime: Date

      The start of time range to query anomalies

    • endTime: Date

      The end of time range to query anomalies

    • dimensionName: string
    • Default value options: ListDimensionValuesForDetectionConfigurationOptions = {}

      The options parameter.

    Returns PagedAsyncIterableIterator<string, ListDimensionValuesForDetectionConfigurationPageResponse>

listIncidentsForAlert

  • 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(alertConfigId, alertId);
    let i = 1;
    for await (const incident of incidentList){
      console.log(`incident ${i++}:`);
      console.log(incident);
    }

    Example using iter.next():

    let iter = client.listIncidentsForAlert(alertConfigId, alertId);
    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(alertConfigId, alertId).byPage({ maxPageSize: 10 });
    let page = await pages.next();
    let i = 1;
    while (!page.done) {
     if (page.value.incidents) {
       console.log(`-- page ${i++}`);
       for (const incident of page.value.incidents) {
         console.dir(incident);
       }
     }
     page = await pages.next();
    }

    Parameters

    • alertConfigId: string

      Anomaly alert configuration id

    • alertId: string

      Alert id

    • Default value options: ListIncidentsForAlertOptions = {}

      The options parameter.

    Returns PagedAsyncIterableIterator<Incident, ListIncidentsForAlertPageResponse>

listIncidentsForDetectionConfiguration

  • 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.incidents) {
       console.log(`-- page ${i++}`);
       for (const incident of page.value.incidents) {
         console.dir(incident);
       }
     }
     page = await pages.next();
    }

    Parameters

    • detectionConfigId: string

      Anomaly detection configuration id

    • startTime: Date

      The start of time range to query for incidents

    • endTime: Date

      The end of time range to query for incidents

    • Default value options: ListIncidentsForDetectionConfigurationOptions = {}

      The options parameter.

    Returns PagedAsyncIterableIterator<Incident, ListIncidentsByDetectionConfigurationPageResponse>

listMetricDimensionValues

  • 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.dimensionValues) {
        console.log(`-- page ${i++}`);
        for (const dv of page.value.dimensionValues) {
          console.dir(dv);
        }
      }
      page = await pages.next();
    }

    Parameters

    • metricId: string

      Anomaly detection configuration id

    • dimensionName: string

      Name of the dimension to list value

    • Default value options: ListMetricDimensionValuesOptions = {}

      The options parameter.

    Returns PagedAsyncIterableIterator<string, ListMetricDimensionValuesPageResponse>

listMetricEnrichmentStatus

  • 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.statusList) {
       console.log(`-- page ${i++}`);
       for (const status of page.value.statusList) {
         console.dir(status);
       }
     }
     page = await pages.next();
    }

    Parameters

    • metricId: string

      Metric id

    • startTime: Date

      The start of time range to query for enrichment status

    • endTime: Date

      The end of time range to query for enrichment status

    • Default value options: ListMetricEnrichmentStatusOptions = {}

      The options parameter.

    Returns PagedAsyncIterableIterator<EnrichmentStatus, ListMetricEnrichmentStatusPageResponse>

listMetricFeedbacks

  • 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.listMetricFeedbacks(metricId);
    let i = 1;
    for await (const f of feedbacks){
     console.log(`feedback ${i++}:`);
     console.log(f);
    }

    Example using iter.next():

    let iter = client.listMetricFeedbacks(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.listMetricFeedbacks(metricId)
      .byPage({ maxPageSize: 10 });
    let page = await pages.next();
    let i = 1;
    while (!page.done) {
     if (page.value.feedbacks) {
       console.log(`-- page ${i++}`);
       for (const f of page.value.feedbacks) {
         console.dir(f);
       }
     }
     page = await pages.next();
    }

    Parameters

    Returns PagedAsyncIterableIterator<MetricFeedbackUnion, ListMetricFeedbackPageResponse>

listMetricSeriesDefinitions

  • 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.definitions) {
        console.log(`-- page ${i++}`);
        for (const definition of page.value.definitions) {
          console.dir(definition);
        }
      }
      page = await pages.next();
    }

    Parameters

    • metricId: string

      Metric id

    • activeSince: Date

      Definitions of series ingested after this time are returned

    • Default value options: ListMetricSeriesDefinitionsOptions = {}

      The options parameter.

    Returns PagedAsyncIterableIterator<MetricSeriesDefinition, ListMetricSeriesPageResponse>

Generated using TypeDoc