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

How can DynaTrace API be used to calculate the total duration of a user session?

dparkar
Contributor

I have been trying the following DynaTrace user session query:

Select userid, usersessionid from usersession

adding duration to the above query retrieves the duration for the visually completeness of the useraction.

May be we can fetch the timestamp for the first useraction in the session and subtract it from the last useraction of the session.


3 REPLIES 3

Julius_Loman
DynaMight Legend
DynaMight Legend

Why are you not using the duration field for usersession?

You should query the usersession.duration, not the useraction.duration (that will be the selected key metric for user actions).


Certified Dynatrace Master | Alanata a.s., Slovakia, Dynatrace Master Partner

Thanks Julius that helped

But I can only retrieve 1000 rows

Tried adding LIMIT 10000 to the query

Doesn't help?

Can you please advise?


This API is not intended to be used to serve as export of all individual sessions. You should use session export for that. It should be used to retrieve aggregated values or individual sessions.

Not sure what you are trying to accomplish, but you can use aggregation functions such as avg and group by clause to get meaningul output. For example - get average session duration by country and city:

select avg(duration),city,country from usersession group by country,city

Certified Dynatrace Master | Alanata a.s., Slovakia, Dynatrace Master Partner

Featured Posts