MetricsQueryClient class

A client that can query metrics, get metric definitions and get metric namespaces.

Constructors

MetricsQueryClient(TokenCredential, MetricsClientOptions)

Creates a MetricsQueryClient.

Methods

listMetricDefinitions(string, ListMetricDefinitionsOptions)

/**

Returns an async iterable iterator to list metric definitions.

Example using for await syntax:

const metricsQueryClient = new MetricsQueryClient(tokenCredential);
const metricDefinitions = client.listMetricDefinitions(resourceUri, options);
let i = 1;
for await (const metricDefinition of metricDefinitions) {
  console.log(`metricDefinition ${i++}:`);
  console.log(metricDefinition);
}

Example using iter.next():

let iter = client.listMetricDefinitions(resourceUri, options);
let result = await iter.next();
while (!result.done) {
  console.log(` metricDefinitions - ${result.value.id}, ${result.value.name}`);
  result = await iter.next();
}

Get a list of metric definitions, given a resource URI.

listMetricNamespaces(string, ListMetricNamespacesOptions)

Returns an async iterable iterator to list metric namespaces.

Example using for await syntax:

const metricsQueryClient = new MetricsQueryClient(tokenCredential);
const metricNamespaces = client.listMetricNamespaces(resourceUri, options);
let i = 1;
for await (const metricNamespace of metricNamespaces) {
  console.log(`metricNamespace ${i++}:`);
  console.log(metricNamespace);
}

Example using iter.next():

let iter = client.listMetricNamespaces(resourceUri, options);
let result = await iter.next();
while (!result.done) {
  console.log(` metricNamespace - ${result.value.id}, ${result.value.name}`);
  result = await iter.next();
}

Get a list of metric namespaces, given a resource URI.

queryResource(string, string[], MetricsQueryOptions)

Query metrics, given a resource URI

Constructor Details

MetricsQueryClient(TokenCredential, MetricsClientOptions)

Creates a MetricsQueryClient.

new MetricsQueryClient(tokenCredential: TokenCredential, options?: MetricsClientOptions)

Parameters

tokenCredential
TokenCredential

A TokenCredential that has rights to query metrics on resources.

options
MetricsClientOptions

Options for the client like controlling request retries.

Method Details

listMetricDefinitions(string, ListMetricDefinitionsOptions)

/**

Returns an async iterable iterator to list metric definitions.

Example using for await syntax:

const metricsQueryClient = new MetricsQueryClient(tokenCredential);
const metricDefinitions = client.listMetricDefinitions(resourceUri, options);
let i = 1;
for await (const metricDefinition of metricDefinitions) {
  console.log(`metricDefinition ${i++}:`);
  console.log(metricDefinition);
}

Example using iter.next():

let iter = client.listMetricDefinitions(resourceUri, options);
let result = await iter.next();
while (!result.done) {
  console.log(` metricDefinitions - ${result.value.id}, ${result.value.name}`);
  result = await iter.next();
}

Get a list of metric definitions, given a resource URI.

function listMetricDefinitions(resourceUri: string, options?: ListMetricDefinitionsOptions): PagedAsyncIterableIterator<MetricDefinition, MetricDefinition[], PageSettings>

Parameters

resourceUri

string

The resource URI to get metric definitions for.

options
ListMetricDefinitionsOptions

Options for getting metric definitions.

Returns

Metric definitions for a given resource URI.

listMetricNamespaces(string, ListMetricNamespacesOptions)

Returns an async iterable iterator to list metric namespaces.

Example using for await syntax:

const metricsQueryClient = new MetricsQueryClient(tokenCredential);
const metricNamespaces = client.listMetricNamespaces(resourceUri, options);
let i = 1;
for await (const metricNamespace of metricNamespaces) {
  console.log(`metricNamespace ${i++}:`);
  console.log(metricNamespace);
}

Example using iter.next():

let iter = client.listMetricNamespaces(resourceUri, options);
let result = await iter.next();
while (!result.done) {
  console.log(` metricNamespace - ${result.value.id}, ${result.value.name}`);
  result = await iter.next();
}

Get a list of metric namespaces, given a resource URI.

function listMetricNamespaces(resourceUri: string, options?: ListMetricNamespacesOptions): PagedAsyncIterableIterator<MetricNamespace, MetricNamespace[], PageSettings>

Parameters

resourceUri

string

The resource URI to get metric namespaces for.

options
ListMetricNamespacesOptions

Options for getting metric namespaces.

Returns

Metric namespaces for a given resource URI.

queryResource(string, string[], MetricsQueryOptions)

Query metrics, given a resource URI

function queryResource(resourceUri: string, metricNames: string[], options?: MetricsQueryOptions): Promise<MetricsQueryResult>

Parameters

resourceUri

string

The resource URI to query.

metricNames

string[]

The names of the metrics to retrieve.

options
MetricsQueryOptions

Options for querying metrics.

Returns

A response containing metrics.