15 Apr 2021 11:50 AM - last edited on 01 Jul 2021 02:04 PM by MaciejNeumann
Hello,
Iam trying to force a query to give me the results of the last 15 minutes only.
As there is no "Last X" parameter in the USQL language i was wondering if there is another way.
FYI : It must always give me the last 15 minutes no matter when i execute it so i can't actually specify a timeframe.
Example :
Solved! Go to Solution.
15 Apr 2021 11:57 AM
Just set the time frame to 15 minutes. If you pin it to a dashboard you can select a custom timeframe of -15m for the USQL dashlet.
This won't get you the result you want probably though. USQL only querries completed sessions and not live sessions.
15 Apr 2021 12:01 PM
If it were a Dashboard it would be easier.
I actually wanna extract the JSON file via API and publish the results on another website.
So the custom Dynatrace timeframe won't really help here. i was looking for something to add to the Query actually...
15 Apr 2021 12:06 PM
If it's the API you have to set the time frame via startTimestamp and endTimestamp, there is no relative option unfortunately. It would be a good RFE to add a relativeTime field like for other API endpoints.
It would still contain only completed sessoins though.
15 Apr 2021 12:25 PM - edited 15 Apr 2021 12:27 PM
Actually found a solution to do it inside the query. You can use the variable $NOW in the query to filter for an endTime. You can subtract an amount in milliseconds from it.
An example to get the end date of all sessions that ended in the last 15 minutes would be:
SELECT endTime FROM usersession WHERE endTime > $NOW-900000 order by endTime desc
With WHERE endTime > $NOW-900000 you can filter your quert for all sessions that ended in the last 15min.
You could also use it to filter for user actions in the last 15 min, depending on what your query looks like.
15 Apr 2021 03:43 PM
That was helpful. thanks a lot !