你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
LoadTestRunClient.GetServerMetricsConfigAsync(String, RequestContext) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
列出给定测试运行的服务器指标配置。
public virtual System.Threading.Tasks.Task<Azure.Response> GetServerMetricsConfigAsync (string testRunId, Azure.RequestContext context = default);
abstract member GetServerMetricsConfigAsync : string * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
override this.GetServerMetricsConfigAsync : string * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
Public Overridable Function GetServerMetricsConfigAsync (testRunId As String, Optional context As RequestContext = Nothing) As Task(Of Response)
参数
- testRunId
- String
负载测试运行的唯一名称只能包含小写字母、数字、下划线或连字符。
- context
- RequestContext
请求上下文,可以基于每个调用替代客户端管道的默认行为。
返回
从服务返回的响应。 响应正文架构的详细信息,请参阅下面的“备注”部分。
例外
testRunId
为 null。
testRunId
是一个空字符串,预期为非空。
服务返回了非成功状态代码。
示例
此示例演示如何使用所需的参数调用 GetServerMetricsConfigAsync 并分析结果。
var credential = new DefaultAzureCredential();
var endpoint = new Uri("<https://my-service.azure.com>");
var client = new LoadTestRunClient(endpoint, credential);
Response response = await client.GetServerMetricsConfigAsync("<testRunId>");
JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("testRunId").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 架构。
响应正文:
的 TestRunServerMetricConfig
架构:
{
testRunId: string, # Optional. Test run 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.
}
适用于
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈