gpt4 book ai didi

java - 如何使用 Java SDK 查询最近五分钟的 Azure 存储指标

转载 作者:行者123 更新时间:2023-11-30 06:41:19 25 4
gpt4 key购买 nike

我编写了一个独立代码来获取 Azure 存储 Blob 服务的指标,但我只想获取最后 5 分钟的指标,如何从 $MetricsMinutePrimaryTransactionsBlob 获取它,请提出建议

CloudTable cloudMetric = tableClient.getTableReference(cloud
.getHourMetricsTable(StorageService.BLOB).getName());
String partitionFilter2 = TableQuery.generateFilterCondition(
"PartitionKey", QueryComparisons.EQUAL, "20170602T1400");
String rowFilter3 = TableQuery.generateFilterCondition("RowKey",
QueryComparisons.EQUAL, "user;All");
String combinedFilter = TableQuery.combineFilters(partitionFilter2,
Operators.AND, rowFilter3);
TableQuery<MetricsPojo> partitionQuery2 = TableQuery.from(
MetricsPojo.class).where(combinedFilter);
for (MetricsPojo capacityMetrics2 : cloudMetric
.execute(partitionQuery2)) {
System.out.println(capacityMetrics2);
System.out.println(capacityMetrics2.getPartitionKey() + "\n"
+ capacityMetrics2.getRowKey() + "\n"
+ capacityMetrics2.getTimestamp());

最佳答案

根据您的描述和@FrancisYu-MSFT的回复,我编写了示例代码并重现了您当前的问题。

这是我的示例代码。

String connectionString = String.format("DefaultEndpointsProtocol=http;AccountName=%s;AccountKey=%s", ACCOUNT_NAME, ACCOUNT_KEY);
CloudStorageAccount account = CloudStorageAccount.parse(connectionString);
CloudAnalyticsClient client = account.createCloudAnalyticsClient();
CloudTable metrics = client.getMinuteMetricsTable(StorageService.BLOB);
System.out.println(metrics.getName());
String queryString = TableQuery.combineFilters(
TableQuery.generateFilterCondition("PartitionKey", QueryComparisons.GREATER_THAN_OR_EQUAL, "20170602T1400"),
Operators.AND,
TableQuery.generateFilterCondition("PartitionKey", QueryComparisons.LESS_THAN_OR_EQUAL, "20170602T1420"));
TableQuery<TableServiceEntity> query = TableQuery.from(TableServiceEntity.class).where(queryString);
for(TableServiceEntity entity : metrics.execute(query)) {
System.out.println(entity.getPartitionKey()+"\t"+entity.getRowKey());
}

然后我在运行代码时遇到了同样的问题,这是由于指标表$MetricsMinutePrimaryTransactionsBlob不存在引起的,因此需要启用相关的Diagnostics选项创建它,如下图。

enter image description here

关于java - 如何使用 Java SDK 查询最近五分钟的 Azure 存储指标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44334639/

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