Share via


LoadTestRunClient.GetMetricDefinitionsAsync Method

Definition

List the metric definitions for a load test run.

public virtual System.Threading.Tasks.Task<Azure.Response> GetMetricDefinitionsAsync (string testRunId, string metricNamespace, Azure.RequestContext context = default);
abstract member GetMetricDefinitionsAsync : string * string * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
override this.GetMetricDefinitionsAsync : string * string * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
Public Overridable Function GetMetricDefinitionsAsync (testRunId As String, metricNamespace As String, Optional context As RequestContext = Nothing) As Task(Of Response)

Parameters

testRunId
String

Unique name for the load test run, must contain only lower-case alphabetic, numeric, underscore or hyphen characters.

metricNamespace
String

Metric namespace to query metric definitions for.

context
RequestContext

The request context, which can override default behaviors of the client pipeline on a per-call basis.

Returns

The response returned from the service. Details of the response body schema are in the Remarks section below.

Exceptions

testRunId or metricNamespace is null.

testRunId is an empty string, and was expected to be non-empty.

Service returned a non-success status code.

Examples

This sample shows how to call GetMetricDefinitionsAsync with required parameters and parse the result.

var credential = new DefaultAzureCredential();
var endpoint = new Uri("<https://my-service.azure.com>");
var client = new LoadTestRunClient(endpoint, credential);

Response response = await client.GetMetricDefinitionsAsync("<testRunId>", "<metricNamespace>");

JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("value")[0].GetProperty("dimensions")[0].GetProperty("description").ToString());
Console.WriteLine(result.GetProperty("value")[0].GetProperty("dimensions")[0].GetProperty("name").ToString());
Console.WriteLine(result.GetProperty("value")[0].GetProperty("description").ToString());
Console.WriteLine(result.GetProperty("value")[0].GetProperty("name").ToString());
Console.WriteLine(result.GetProperty("value")[0].GetProperty("namespace").ToString());
Console.WriteLine(result.GetProperty("value")[0].GetProperty("primaryAggregationType").ToString());
Console.WriteLine(result.GetProperty("value")[0].GetProperty("supportedAggregationTypes")[0].ToString());
Console.WriteLine(result.GetProperty("value")[0].GetProperty("unit").ToString());
Console.WriteLine(result.GetProperty("value")[0].GetProperty("metricAvailabilities")[0].GetProperty("timeGrain").ToString());

Remarks

Below is the JSON schema for the response payload.

Response Body:

Schema for MetricDefinitionCollection:

{
  value: [
    {
      dimensions: [
        {
          description: string, # Optional. The description
          name: string, # Optional. The name
        }
      ], # Optional. List of dimensions
      description: string, # Optional. The metric description
      name: string, # Optional. The metric name
      namespace: string, # Optional. The namespace the metric belongs to.
      primaryAggregationType: "Average" | "Count" | "None" | "Total" | "Percentile90" | "Percentile95" | "Percentile99", # Optional. The primary aggregation type value defining how to use the values for display.
      supportedAggregationTypes: [string], # Optional. The collection of what all aggregation types are supported.
      unit: "NotSpecified" | "Percent" | "Count" | "Seconds" | "Milliseconds" | "Bytes" | "BytesPerSecond" | "CountPerSecond", # Optional. The unit of the metric.
      metricAvailabilities: [
        {
          timeGrain: "PT5S" | "PT10S" | "PT1M" | "PT5M" | "PT1H", # Optional. The time grain specifies the aggregation interval for the metric. Expressed as a duration 'PT1M', 'PT1H', etc.
        }
      ], # Optional. Metric availability specifies the time grain (aggregation interval or frequency).
    }
  ], # Required. the values for the metric definitions.
}

Applies to