question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Azure Monitor - Determining what aggregation interval to use

See original GitHub issue

I’m currently working on Promitor which is scraping the Azure Monitor API for metrics based on a configuration file.

As part of an Azure Monitor query an interval needs to be defined in order to specify the metrics granularity such as:

 var metricQuery = metricDefinition.DefineQuery()
                .StartingFrom(recordDateTime.AddDays(-5))
                .EndsBefore(recordDateTime)
                .WithAggregation(metricAggregation.ToString())
                .WithInterval(TimeSpan.FromMinutes(5));

However, depending on the metric this is different and the value needs to be exact. Otherwise you will have exceptions like these:

Invalid time grain duration: PT3M, supported ones are: 00:01:00,00:05:00,00:15:00,00:30:00,01:00:00,06:00:00,12:00:00,1.00:00:00

This brings me with a few questions:

  • What is the best approach to ensure that these are correct? Is that to check the “Metric Availabilities” for a specific metric and verify that it’s present?
  • Are they really different for every metric or is there an enum that can help us with this?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
anirudhcavalecommented, Oct 23, 2018

@hovsepm, @tomkerkhove : The metric granularity enums are PT1M PT5M PT15M PT30M PT1H PT6H PT1D. Most metrics support all of these granulartires. However there are some exceptions, a few metrics only support PT5M, or only support PT1H and higher. As you guessed @tomkerkhove the only way to know is to call “Metric Availabilities”.

1reaction
hovsepmcommented, Oct 23, 2018

@anirudhcavale could you help here?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Azure Monitor metrics aggregation and display explained
In this case, all the data from all the individual servers are aggregated into a 1-minute interval metric and stored in the metrics...
Read more >
Advanced features of Metrics Explorer - Azure Monitor
Count : The number of measurements captured during the aggregation interval. When the metric is always captured with the value of 1, the...
Read more >
Analyze metrics for an Azure resource - Azure Monitor
The chart uses the specified aggregation to calculate all sampled values over the time granularity specified.
Read more >
Azure Monitoring Complete Guide (2023)
Azure Monitor can capture metrics in near real-time. The metrics are collected at regular intervals and are useful for alerting because of their...
Read more >
Aggregating pre-aggregated metrics in Azure Monitor
Short version. Suppose your metrics are called “TestMetrics” and you'd like to aggregate all the values. You can use this query in Log...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found