gpt4 book ai didi

Azure 自动缩放指标名称值

转载 作者:行者123 更新时间:2023-12-03 06:02:08 26 4
gpt4 key购买 nike

我需要为我的虚拟机定义缩放规则我已阅读以下内容

The MetricName and MetricNamespace are not values I just made up.These have to be precise. You can get these values from theMetricsClient API and there is some sample code in this link to showhow to get the values.

http://rickrainey.com/2013/12/15/auto-scaling-cloud-services-on-cpu-percentage-with-the-windows-azure-monitoring-services-management-library/

但仍然不清楚我是否可以获得可能值的 MetricName 列表,因为我没有找到任何示例代码

最佳答案

这是我用来获取云服务的可用 MetricNames 的代码。它是单元测试项目的一部分,因此具有 [TestMethod] 属性。

    [TestMethod]
public async Task GetMetricDefinitions()
{
// Build the resource ID string.
string resourceId = ResourceIdBuilder.BuildCloudServiceResourceId(
cloudServiceName, deploymentName, roleName );

Console.WriteLine("Resource Id: {0}", resourceId);

//Get the metric definitions.
var retrieveMetricsTask =
metricsClient.MetricDefinitions.ListAsync(resourceId, null, null, CancellationToken.None);
var metricListResponse = await retrieveMetricsTask;

MetricDefinitionCollection metricDefinitions = metricListResponse.MetricDefinitionCollection;

// Make sure something was returned.
Assert.IsTrue(metricDefinitions.Value.Count > 0);

// Display the metric definitions.
int count = 0;
foreach (MetricDefinition metricDefinition in metricDefinitions.Value)
{
Console.WriteLine("MetricDefinitio: " + count++);
Console.WriteLine("Display Name: " + metricDefinition.DisplayName);
Console.WriteLine("Metric Name: " + metricDefinition.Name);
Console.WriteLine("Metric Namespace: " + metricDefinition.Namespace);
Console.WriteLine("Is Altertable: " + metricDefinition.IsAlertable);
Console.WriteLine("Min. Altertable Time Window: " + metricDefinition.MinimumAlertableTimeWindow);
Console.WriteLine();
}
}

这是我的云服务测试的输出:

enter image description here

关于Azure 自动缩放指标名称值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25744081/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com