DQL
Questions about Dynatrace Query Language
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Datadog - Calendar-based rollup in Dynatrace (weekly/monthly/yearly with custom start & timezone)

anuj08_jain
Frequent Guest

Hello Team,

In Datadog dashboards, we can configure rollups like:

avg weekly UTC starting Sunday

avg monthly UTC starting <date>

avg yearly UTC starting <month>


In Dynatrace, I can use every <interval> for fixed rollups, but I don’t see how to configure calendar-aligned rollups with:

Custom week start (e.g., Sunday)

Custom month start date

Custom year start month

Custom timezone for aggregation

Is this supported in Dynatrace (dashboard, DQL, or calculated metrics)? If yes, how can we achieve this?

1 REPLY 1

krzysztof_hoja
Dynatrace Champion
Dynatrace Champion

I inderstand that you are talking about metrics, so data retirvable usig timeseries command. Indeed, it allows only retrieval of data in uniform intervals, not related to calendar is defines units of different length and flexible starting point.

What DQL can offer to acheive this, if further aggregation of data returned but timeseries command. Of course it cannot be done using makeTimeseries, because it also operates on fixed size intervals, but summarize does not have this limitation and the output is accepted by out visualizations in notebooks and dashboards.

To get the data ready for further aggregation we need to do this:

timeseries {d=sum(dt.service.request.count), t=start()}, from: (-1y)@y, to: @y, interval:24h
| fieldsAdd d = record(d=d[], t=t[])
| expand d

 

This way we have metric value in separate rows as single record holding value with timestamp (beginning of interval). Size of interval needs to be selected accordingly. In my example I want to have data for full year, so I selected 24h intervals to have less intervals then limit allows (1.5k)

Now we can aggregate as you wish. To get weekle bins starting on Wendnesdays:

| summarize d=sum(d[d]), by: { t =  timeframe(from: (d[t]+interval/2)@w3, to: (d[t]+interval/2)@w3+1w ) }
 

To get monthly bins:

| summarize d=sum(d[d]), by: { t =  timeframe(from: (d[t]+interval/2)@M, to: (d[t]+interval/2)@M+1M ) }

 

To get monthly bins, but when month starts from 10th day

| summarize d=sum(d[d]), by: { t =  timeframe(from: (d[t]+interval/2)@M+9d, to: (d[t]+interval/2)@M+1M+9d ) }

Unfortunately this method is not perfect. Due to dalight saving time part of the year is not midnight-to-midnigth, so some moths give one of theit hour to neighboring month and take one hour from month on other side.  

 

Custom timezone can be achived using bin() function where you can set offset (now I am getting past month in hourly resolution:

timeseries {d=sum(dt.service.request.count), t=start()}, from: @M-1M, to: @M, interval:1h
| fieldsAdd d = record(d=d[], t=t[])
| expand d
| summarize d=sum(d[d]), by: { t =  timeframe(from: bin(d[t], 24h, at:2h), to: bin(d[t], 24h, at:2h)+24h) }

 Also this methos will ignore DST changes.

Featured Posts