I have written a stand alone code to get the metrics for Azure Storage Blob Services but i want to get only last 5mins metric how can i get it from $MetricsMinutePrimaryTransactionsBlob please suggest
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());
There is no simple way to query last 5 minutes rows now. As PartitionKey is the time stamp in minute unit, you can propose the query filter for last 20 minutes rows and find last 5 minutes rows from the result locally.
TableQuery.combineFilters(
TableQuery.generateFilterCondition("PartitionKey", QueryComparisons.GreaterThanOrEqual, "20170602T1400"),
TableOperators.And,
TableQuery.generateFilterCondition("PartitionKey", QueryComparisons.LessThanOrEqual, "20170602T1420"));
According to your description and @FrancisYu-MSFT reply, I wrote a sample code and reproduced your current issue.
Here is my sample code.
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());
}
Then I got the same issue when running my code, which was caused by the metrics table $MetricsMinutePrimaryTransactionsBlob
not exists, so you need to enable the related Diagnostics
options to create it, as the figure below.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.