你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
LoadTestRunClient.GetMetricDefinitions(String, String, RequestContext) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
列出负载测试运行的指标定义。
public virtual Azure.Response GetMetricDefinitions (string testRunId, string metricNamespace, Azure.RequestContext context = default);
abstract member GetMetricDefinitions : string * string * Azure.RequestContext -> Azure.Response
override this.GetMetricDefinitions : string * string * Azure.RequestContext -> Azure.Response
Public Overridable Function GetMetricDefinitions (testRunId As String, metricNamespace As String, Optional context As RequestContext = Nothing) As Response
参数
- testRunId
- String
负载测试运行的唯一名称只能包含小写字母、数字、下划线或连字符。
- metricNamespace
- String
要查询其指标定义的指标命名空间。
- context
- RequestContext
请求上下文,可以基于每个调用替代客户端管道的默认行为。
返回
从服务返回的响应。 响应正文架构的详细信息,请参阅下面的“备注”部分。
例外
testRunId
或 metricNamespace
为 null。
testRunId
是一个空字符串,预期为非空。
服务返回了非成功状态代码。
示例
此示例演示如何使用所需参数调用 GetMetricDefinitions 并分析结果。
var credential = new DefaultAzureCredential();
var endpoint = new Uri("<https://my-service.azure.com>");
var client = new LoadTestRunClient(endpoint, credential);
Response response = client.GetMetricDefinitions("<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());
注解
下面是响应有效负载的 JSON 架构。
响应正文:
的 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.
}