06 Feb 2025 08:58 AM
I want to create tile with day -1 or previous date but at the same time I want to use common dashboard timeframe.
Mean if I set 4 hours in dashboard time duration tile show yesterday's 4 hours data so that I can compare with today's data.
Solved! Go to Solution.
06 Feb 2025 09:35 AM
There are 2 ways to approach it:
Yes, it is possible using special build-in variables: $dt_timeframe_from and $dt_timeframe_to.
Use can use them explicitly in query to specify interesting time range as well as include them in expression which results in different time range as original.
In the query below I am going for timeframe 24h earlier then this specified in dashboard controls:
fetch logs, from:toTimestamp($dt_timeframe_from)-24h,
to: toTimestamp($dt_timeframe_to)-24h
| summarize m1=min(timestamp), m2=max(timestamp)
Here is how result looks like. Left tile show results of same query without any time modification, so for last 30 minutes.
When dealing with timeseries you can also use shift: parameter, to go for time range different then specified, but in relation to it. Query below will contain 2 timeseries: current one and this from previous day, but "mapped" into current time, so results will be synchronized on chart:
timeseries cpu=avg(dt.host.cpu.usage)
| append [
timeseries cpu=avg(dt.host.cpu.usage), shift: -24h
]
Result looks like this:
Please select X-axis->Displayed timeframe->Data to adjust x-axis to basic timeframe.
06 Feb 2025 10:08 AM
Could you please share Document page to explore it ?
06 Feb 2025 09:58 AM
Thanks, It is working as expected.