Open Q&A
If there's no good subforum for your question - ask it here!
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

I want to know how to create line graph comparing "this week" and "last week".

Taihei
Observer

I created the following DQL to generate this graph.
It adds and removes fields within the timeframe.
Is there a more efficient way to achieve this?

 

timeseries req_now=avg(dt.service.request.response_time),timeframe:"2025-11-21T12:00:00+0900/2025-11-21T15:00:00+0900"
| fields interval, req_now
| fieldsAdd timeframe = timeframe(from:"2025-11-14T12:00:00+0900",to:"2025-11-14T15:00:00+0900" )
| append [
timeseries {req_old=avg(dt.service.request.response_time),timeframe:"2025-11-14T12:00:00+0900/2025-11-14T15:00:00+0900"}
]

 

 

 

 

1 REPLY 1

For last week:

| fieldsAdd startTime=-1w@w, endTime=@w-1s
| fieldsAdd startTime=formatTimestamp(startTime, format:"MMM-dd-yyyy")
| fieldsAdd endTime=formatTimestamp(endTime, format:"MMM-dd-yyyy")
| fieldsAdd WeekNumber = getWeekOfYear(-1w@w)

 

For current week:

| fieldsAdd startTime=@w, endTime=now()

Featured Posts