Please, tell me, I’m stuck and for several days I can not find a solution.
For example, I have data that comes in every minute, for a month (the period can be any) and there is a need to compare them with the same period for the last year or the previous month. The result must be displayed on a single graph. Those it is necessary to somehow bring these two data sets to a single time interval. The timeline should remain the one selected by the user.
I tried a lot of different solutions from the documentation for Flux lang and Grafana (timeshift(), alignTime(), merge(), join(), window(),…), info from the Internet, but such an example is not considered anywhere. Although it seems to me that this is some kind of typical task.
I drew about what I want to get. Please, if you give the right direction for thought or a link - I will be very grateful.It seems that the solution is on the surface, but I just can not understand the essence.
Did you try this? If it works, you would then have to do a binary transformation to get the difference between the two time periods.
Thanks for answering!
Yes, of course I tried alignTime(), but the best thing I could do with it was this chart.
The code: --------------------------
todayDate = date.truncate(t: now(), unit: 1d)
minus1dayDate = date.sub(d: 1d, from: todayDate)
minus2dayDate = date.sub(d: 2d, from: todayDate)
|> range(start: minus2dayDate, stop: todayDate)
|> filter(fn: (r) => r[“deviceName”] == “F3-W-346.4”)
|> aggregateWindow(every: 1h, fn: mean, createEmpty: false)
|> window(every: 1d)
|> experimental.alignTime(alignTo: minus1dayDate)
|> yield(name: “result”)
The course of thought
I take today’s date at 00:00:00 and subtract 2 days from it. I build a graph for these two days, divided by one day. It turns out not bad, but for some reason the data does not fall by the hour. A third graph appears from one point. I can’t bring them all into the same range.
What i did wrong?
Any progress? I am using the experimentel.alignTime() function to overlap multiple periodic signals within the dashboard timeRange. Using the alignTo all the signals are shifted to the begining of the timeRange so that I can see only the small portion of the data due to the wide timeRange. How did u overcome this issue?