cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

User session Query (Last 15 minutes)

service_apms
Organizer

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 : 

 

SELECT AVG(duration)
FROM useraction
WHERE useraction.application='XXXX'
and useraction.name = 'YYYYYY'
 
Thank you
5 REPLIES 5

pahofmann
DynaMight Guru
DynaMight Guru

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.

 

Dynatrace Certified Master - Dynatrace Partner - 360Performance.net

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...

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. 

 

Dynatrace Certified Master - Dynatrace Partner - 360Performance.net

pahofmann
DynaMight Guru
DynaMight Guru

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.

Dynatrace Certified Master - Dynatrace Partner - 360Performance.net

That was helpful. thanks a lot !

Featured Posts