0

https://learn.microsoft.com/en-us/azure/virtual-machines/extensions/diagnostics-template#wadmetrics-tables-in-storage

RowKey: Follows the format :. The descending time tick calculation is max time ticks minus the time of the beginning of the aggregation period. For example if the sample period started on 10-Nov-2015 and 00:00Hrs UTC then the calculation would be: DateTime.MaxValue.Ticks - (new DateTime(2015,11,10,0,0,0,DateTimeKind.Utc).Ticks). For the memory available bytes performance counter the row key will look like: 2519551871999999999__:005CMemory:005CAvailable:0020Bytes

So I'm confused as to how to generate this rowkey value, as I have no idea what the aggregation period is. I've tried the last minute or the last hour with no luck, despite the ticks being very similar.

OneTwo
  • 2,291
  • 6
  • 33
  • 55

1 Answers1

1

1. The aggregation period

If you enable diagnostic for a VM, all the metrics data will be stored in a storage account table.

enter image description here

The aggregation period is in the table name. For example: WADMetricsPT1HP10DV2S20190927

PT1H / PT1M: The MetricAggregation value of PT1M and PT1H signify an aggregation over a minute and an aggregation over an hour

P10D : It means that it contains 10 days data

20190927: It is the start aggregation period.


2. Rowkey value

Just as mentioned in the official documentation, it follows the format : The descending time tick calculation is max time ticks minus the time of the beginning of the aggregation period.

I will take one record in my table as a sample:

RowKey -> :2518363979999999999__:005CProcessor:0020Information:0028:005FTotal:0029:005C:0025:0020User:0020Time
TIMESTAMP -> 2019-08-15T21:00:00.000Z

Firstly, the RowKey value contains some Basic Latin characters in Unicode.

:005C = \
:0020 = blank space

So, the readable RowKey would looks like:

:2518363979999999999__:\Processor Information(-Total)\% User Time

Then, let's talk about the number -- 2518363979999999999.

As the record is from table "WADMetricsPT1HP10DV2S20190808", so:

In C#, you may get the value as:

DateTime.MaxValue.Ticks - (new DateTime(2019,08,08,0,0,0,DateTimeKind.Utc).Ticks)

In java, you may try the following code:

public class TickTest {

    public static Instant MAX = Instant.parse("9999-12-31T23:59:59.999Z");

    public static long toTicks(Instant start)
    {
        return toTicks(start, MAX);
    }

    public static long toTicks(Instant start, Instant end)
    {
        return Duration.between(start, end).toMillis() * 10000;
    }

    // Test
    public static void main(String[] args) {
        System.out.println(toTicks(Instant.parse("2019-08-08T00:00:00.000Z")));
    }
}
Jack Jia
  • 5,268
  • 1
  • 12
  • 14
  • If this is what the row key was, then why wouldn't all of the numerical part of the RowKey's in the DB have the same value? As in they are all calculating from the same date. – OneTwo Oct 24 '19 at 10:28
  • 1
    Same date? Sorry, the TIMESTAMP of each record is different from others in my table. – Jack Jia Oct 24 '19 at 10:35
  • Sorry, to clarify, you are saying the number in the RowKey is equal to (some constant MaxTicks - Amount of ticks at the date in the table name)? If so, then inside that table every record would have the same number in the RowKey, as both Ticks are constant. – OneTwo Oct 24 '19 at 10:50
  • But as you can see, even in your picture, they are not the same. So I must be understanding something wrong. – OneTwo Oct 24 '19 at 10:51
  • 1
    "20190927" in table name "WADMetricsPT1HP10DV2S20190927" is the beginning of the table's aggregation period. But the beginning of a record's aggregation period is its TIMESTAMP. – Jack Jia Oct 24 '19 at 10:57
  • 1
    Sorry for not explaining it clearly. Will update it later. – Jack Jia Oct 24 '19 at 11:01
  • Ah I see, thanks. I'm trying to extract data from this table, but querying by timestamp takes forever, so I was looking for a better way to query the table using the RowKey, guess I will have to go back to the slow Timestamp. – OneTwo Oct 24 '19 at 11:03