I wrote the following query for today's comparison with last week:
index = abc App_Name=xyz earliest=-0d@d latest=now | multikv | eval ReportKey="Today"|append[search index = abc App_Name=xyz earliest=-7d@d latest=-6d@d | multikv | eval ReportKey="LastWeek"| eval _time=_time+60*60*24*7]|eval _time=if(isnotnull(new_time), new_time, _time)|timechart span=5m sum(TOTAL_TRANSACTIONS) as Transactions by ReportKey
I want the query to do the following: allow someone to view the comparison of yesterday's data and last week's(considering yesterday to its one week data), or the "day before yesterday" to its corresponding "last week" data, and so on.
So, could you please help how can i write the query for that?
You should use relative_time
or timewrap
to do this. It will be much cleaner
Hi @sager_shubham,
did you try out Skoelpin's suggestion? Did it work? Let us know, so we can convert it to answer, and then you can approve it! Thanks.
could you please refer me with an example
?
A quick and dirty way would be to use timewrap
like this.
index = abc App_Name=xyz
| timechart span=5m sum(TOTAL_TRANSACTIONS) as Transactions by ReportKey
| timewrap 1d
If this doesn't work then you will need to use relative time like this
index = abc App_Name=xyz
| eval today=relative_time(now(),"-d@d")
| eval yesterday=relative_time('today', "-d@d")