LoadTestRunClient.GetMetrics Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
GetMetrics(String, String, String, String, MetricsFilters, String, Nullable<TimeGrain>, CancellationToken) |
List the metric values for a load test run. |
GetMetrics(String, String, String, String, RequestContent, String, String, RequestContext) |
List the metric values for a load test run. |
GetMetrics(String, String, String, String, MetricsFilters, String, Nullable<TimeGrain>, CancellationToken)
- Source:
- LoadTestRunClient.cs
List the metric values for a load test run.
public virtual Azure.Pageable<Azure.Developer.LoadTesting.TimeSeriesElement> GetMetrics(string testRunId, string metricname, string metricNamespace, string timespan, Azure.Developer.LoadTesting.MetricsFilters body = default, string aggregation = default, Azure.Developer.LoadTesting.TimeGrain? interval = default, System.Threading.CancellationToken cancellationToken = default);
abstract member GetMetrics : string * string * string * string * Azure.Developer.LoadTesting.MetricsFilters * string * Nullable<Azure.Developer.LoadTesting.TimeGrain> * System.Threading.CancellationToken -> Azure.Pageable<Azure.Developer.LoadTesting.TimeSeriesElement>
override this.GetMetrics : string * string * string * string * Azure.Developer.LoadTesting.MetricsFilters * string * Nullable<Azure.Developer.LoadTesting.TimeGrain> * System.Threading.CancellationToken -> Azure.Pageable<Azure.Developer.LoadTesting.TimeSeriesElement>
Public Overridable Function GetMetrics (testRunId As String, metricname As String, metricNamespace As String, timespan As String, Optional body As MetricsFilters = Nothing, Optional aggregation As String = Nothing, Optional interval As Nullable(Of TimeGrain) = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Pageable(Of TimeSeriesElement)
Parameters
- testRunId
- String
Unique name for the load test run, must contain only lower-case alphabetic, numeric, underscore or hyphen characters.
- metricname
- String
Metric name.
- metricNamespace
- String
Metric namespace to query metric definitions for.
- timespan
- String
The timespan of the query. It is a string with the following format 'startDateTime_ISO/endDateTime_ISO'.
- body
- MetricsFilters
Metric dimension filter.
- aggregation
- String
The aggregation.
- cancellationToken
- CancellationToken
The cancellation token to use.
Returns
Exceptions
testRunId
, metricname
, metricNamespace
or timespan
is null.
testRunId
is an empty string, and was expected to be non-empty.
Applies to
GetMetrics(String, String, String, String, RequestContent, String, String, RequestContext)
- Source:
- LoadTestRunClient.cs
- Source:
- LoadTestRunClient.cs
List the metric values for a load test run.
public virtual Azure.Pageable<BinaryData> GetMetrics(string testRunId, string metricName, string metricNamespace, string timespan, Azure.Core.RequestContent content = default, string aggregation = default, string interval = default, Azure.RequestContext context = default);
public virtual Azure.Pageable<BinaryData> GetMetrics(string testRunId, string metricName, string metricNamespace, string timespan, Azure.Core.RequestContent content, string aggregation, string interval, Azure.RequestContext context);
abstract member GetMetrics : string * string * string * string * Azure.Core.RequestContent * string * string * Azure.RequestContext -> Azure.Pageable<BinaryData>
override this.GetMetrics : string * string * string * string * Azure.Core.RequestContent * string * string * Azure.RequestContext -> Azure.Pageable<BinaryData>
Public Overridable Function GetMetrics (testRunId As String, metricName As String, metricNamespace As String, timespan As String, Optional content As RequestContent = Nothing, Optional aggregation As String = Nothing, Optional interval As String = Nothing, Optional context As RequestContext = Nothing) As Pageable(Of BinaryData)
Public Overridable Function GetMetrics (testRunId As String, metricName As String, metricNamespace As String, timespan As String, content As RequestContent, aggregation As String, interval As String, context As RequestContext) As Pageable(Of BinaryData)
Parameters
- testRunId
- String
Unique name for the load test run, must contain only lower-case alphabetic, numeric, underscore or hyphen characters.
- metricName
- String
Metric name.
- metricNamespace
- String
Metric namespace to query metric definitions for.
- timespan
- String
The timespan of the query. It is a string with the following format 'startDateTime_ISO/endDateTime_ISO'.
- content
- RequestContent
The content to send as the body of the request. Details of the request body schema are in the Remarks section below.
- aggregation
- String
The aggregation.
- interval
- String
The interval (i.e. timegrain) of the query. Allowed values: "PT5S" | "PT10S" | "PT1M" | "PT5M" | "PT1H".
- context
- RequestContext
The request context, which can override default behaviors of the client pipeline on a per-call basis.
Returns
The Pageable<T> from the service containing a list of BinaryData objects. Details of the body schema for each item in the collection are in the Remarks section below.
Exceptions
testRunId
, metricName
, metricNamespace
or timespan
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 GetMetrics 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);
var data = new {};
foreach (var data in client.GetMetrics("<testRunId>", "<metricname>", "<metricNamespace>", "<timespan>", RequestContent.Create(data)))
{
JsonElement result = JsonDocument.Parse(data.ToStream()).RootElement;
Console.WriteLine(result.ToString());
}
This sample shows how to call GetMetrics with all parameters and request content, and how to parse the result.
var credential = new DefaultAzureCredential();
var endpoint = new Uri("<https://my-service.azure.com>");
var client = new LoadTestRunClient(endpoint, credential);
var data = new {
filters = new[] {
new {
name = "<name>",
values = new[] {
"<String>"
},
}
},
};
foreach (var data in client.GetMetrics("<testRunId>", "<metricname>", "<metricNamespace>", "<timespan>", RequestContent.Create(data), "<aggregation>", "<interval>"))
{
JsonElement result = JsonDocument.Parse(data.ToStream()).RootElement;
Console.WriteLine(result.GetProperty("data")[0].GetProperty("timestamp").ToString());
Console.WriteLine(result.GetProperty("data")[0].GetProperty("value").ToString());
Console.WriteLine(result.GetProperty("dimensionValues")[0].GetProperty("name").ToString());
Console.WriteLine(result.GetProperty("dimensionValues")[0].GetProperty("value").ToString());
}
Remarks
Below is the JSON schema for the request payload and one item in the pageable response.
Request Body:
Schema for MetricRequestPayload
:
{
filters: [
{
name: string, # Optional. The dimension name
values: [string], # Optional. The dimension values. Maximum values can be 20.
}
], # Optional. Get metrics for specific dimension values. Example: Metric contains dimension like SamplerName, Error. To retrieve all the time series data where SamplerName is equals to HTTPRequest1 or HTTPRequest2, the DimensionFilter value will be {"SamplerName", ["HTTPRequest1", "HTTPRequest2"}
}
Response Body:
Schema for MetricsValue
:
{
data: [
{
timestamp: string, # Optional. The timestamp for the metric value in ISO 8601 format.
value: number, # Optional. The metric value.
}
], # Optional. An array of data points representing the metric values.
dimensionValues: [
{
name: string, # Optional. The name of the dimension.
value: string, # Optional. The value of the dimension.
}
], # Optional. The dimension values
}