Hello Community,
I am in the process of understanding the use case of bins and the rate function in the timeseries command.
I wrote a small script that sends a random whole number as a custom metric into Dynatrace every 30s. Here are a few example metrics I sent:
Sent: custom.random.whole_number 18 2025-07-17 10:04:25
Sent: custom.random.whole_number 6 2025-07-17 10:04:55
Sent: custom.random.whole_number 60 2025-07-17 10:05:25
Sent: custom.random.whole_number 55 2025-07-17 10:05:56
Sent: custom.random.whole_number 72 2025-07-17 10:06:26
Sent: custom.random.whole_number 71 2025-07-17 10:06:56
Sent: custom.random.whole_number 63 2025-07-17 10:07:26
Sent: custom.random.whole_number 45 2025-07-17 10:07:56
…
…
etc
When I plot the data using the DQL: timeseries avg(custom.random.whole_number) for a 10m time interval (i.e., 10:00 AM to 10:10 AM), I can see that Dynatrace by default uses a 1m bin and takes the average value of each 1m interval. Everything looks fine, e.g., I can see 12 ((18+6)/2), 57.5 ((60+55)/2), etc.
My intention was to show raw data in the graph, so I thought the rate function might help here. I updated it to, avg(custom.random.whole_number, rate:30s)
I was under the impression that the rate function would override the default 1-minute interval with 30s so that I could see the raw data as a result. But unfortunately, I got different results, which were actually half the values from the previous result, i.e., 6, 28.75, etc. This seems like the raw data is divided into each second and then averaged over 30s.
For example, does it work like this?
((18 + 6) / 60) * 30) / 2
Is that how it works?
If yes, is there any way to display the raw data in the timeseries?
Additionally, one more question, if we add the bin function in the DQL like this:
timeseries avg(custom.random.whole_number), bins:24
What exactly does this do?