Can't merge rows together

Occasional Visitor


I'm using Grafana with Azure Monitor as datasource to monitor our AKS cluster. I've installed a Grafana dashboard which shows Node CPU usage for the past 12 hours, which is great, but it would be more useful to me if it showed me the last 7 days. This is very easy to adjust in Grafana, but when I change timespan to 7 days, the graph is pretty opaque, since it's trying to plot some 23.000 entries (see  attached image).

To make it more comprehensible, I would like to aggregate the entires together in for instance timespans of 3 hours. I know theres a function to do just that in the query language:

bin(TimeGenerated, 3h)

I've tried so hard to make it work in my query, but I just can't make it work. Next step is to really dive into the query language, but it's time I would like to really spare.


So can anyone help me make this query aggregate the data with 3 hours intervals?



| where ObjectName == "K8SNode"
| where CounterName == "cpuCapacityNanoCores"
| where $__timeFilter(TimeGenerated)
| where InstanceName contains '$AKS'
| summarize arg_max(TimeGenerated, *) by Computer
| project Computer, CpuTotal=(CounterValue)
| join kind=inner (
    | where ObjectName == "K8SNode"
    | where CounterName == "cpuUsageNanoCores"
    | where $__timeFilter(TimeGenerated)
    | where InstanceName contains '$AKS'
    | project TimeGenerated, Computer, CpuUsed=(CounterValue)
) on Computer
| order by TimeGenerated asc
| project TimeGenerated, Computer, CpuPercentageUsad=(CpuUsed / CpuTotal) * 100


 Thanks in advance

1 Reply

I made a small example for you, where the CPU graph is summarized to an average per hour.
Does this help you?

| where Computer == "idala"
| where ObjectName == "Processor"
| where CounterName == "% Processor Time"
| summarize avg(CounterValue) by bin(TimeGenerated, 1h), CounterName