你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

LoadTestAdministrationClient.GetServerMetricsConfig 方法

定义

列出给定测试的服务器指标配置。

public virtual Azure.Response GetServerMetricsConfig (string testId, Azure.RequestContext context = default);
abstract member GetServerMetricsConfig : string * Azure.RequestContext -> Azure.Response
override this.GetServerMetricsConfig : string * Azure.RequestContext -> Azure.Response
Public Overridable Function GetServerMetricsConfig (testId As String, Optional context As RequestContext = Nothing) As Response

参数

testId
String

负载测试的唯一名称只能包含小写字母、数字、下划线或连字符字符。

context
RequestContext

请求上下文,它可以基于每个调用替代客户端管道的默认行为。

返回

从服务返回的响应。 响应正文架构的详细信息位于下面的“备注”部分。

例外

testId 为 null。

testId 是一个空字符串,预期为非空。

服务返回了不成功状态代码。

示例

此示例演示如何使用所需参数调用 GetServerMetricsConfig 并分析结果。

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

Response response = client.GetServerMetricsConfig("<testId>");

JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("testId").ToString());
Console.WriteLine(result.GetProperty("metrics").GetProperty("<test>").GetProperty("id").ToString());
Console.WriteLine(result.GetProperty("metrics").GetProperty("<test>").GetProperty("resourceId").ToString());
Console.WriteLine(result.GetProperty("metrics").GetProperty("<test>").GetProperty("metricNamespace").ToString());
Console.WriteLine(result.GetProperty("metrics").GetProperty("<test>").GetProperty("displayDescription").ToString());
Console.WriteLine(result.GetProperty("metrics").GetProperty("<test>").GetProperty("name").ToString());
Console.WriteLine(result.GetProperty("metrics").GetProperty("<test>").GetProperty("aggregation").ToString());
Console.WriteLine(result.GetProperty("metrics").GetProperty("<test>").GetProperty("unit").ToString());
Console.WriteLine(result.GetProperty("metrics").GetProperty("<test>").GetProperty("resourceType").ToString());
Console.WriteLine(result.GetProperty("createdDateTime").ToString());
Console.WriteLine(result.GetProperty("createdBy").ToString());
Console.WriteLine(result.GetProperty("lastModifiedDateTime").ToString());
Console.WriteLine(result.GetProperty("lastModifiedBy").ToString());

注解

下面是响应有效负载的 JSON 架构。

响应正文:

TestServerMetricConfig架构:

{
  testId: string, # Optional. Test identifier
  metrics: Dictionary<string, ResourceMetric>, # Optional. Azure resource metrics collection {metric id : metrics object} (Refer : https://docs.microsoft.com/en-us/rest/api/monitor/metric-definitions/list#metricdefinition for metric id).
  createdDateTime: string (ISO 8601 Format), # Optional. The creation datetime(ISO 8601 literal format).
  createdBy: string, # Optional. The user that created.
  lastModifiedDateTime: string (ISO 8601 Format), # Optional. The last Modified datetime(ISO 8601 literal format).
  lastModifiedBy: string, # Optional. The user that last modified.
}

适用于