DANISH P. avatar image
DANISH P. asked ·

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

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.

rest apiuser actions
10 |2000000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 50.0 MiB each and 250.0 MiB total.

1 Answer

Julius L. avatar image
Julius L. answered ·

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

2 comments Share
10 |2000000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 50.0 MiB each and 250.0 MiB total.

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?

0 Likes 0 · ·

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
1 Like 1 · ·

Space Topics

mobile monitoring dotnet synthetic monitoring reports iis chat kubernetes servicenow amazon web services mysql mainframe rest api errors cassandra dashboard oneagent sdk cmc application monitoring openkit smartscape request attributes monitoring developer community user tagging log monitoring services ufo syntheticadvisory activegate ip addresses auto-detection high five award oracle hyperion webserver uem usql iib test automation license web performance monitoring ios news migration management zones index ibm mq web services custom event alerts notifications sso host monitoring knowledge sharing reports browser monitors java hybris sap vmware maintenance window user action naming javascript appmon ai synthetic classic availability tipstricks automation extensions diagnostic tools session replay permissions davis assistant faq documentation problem detection http monitors server easytravel apdex aws-quickstart network docker tags and metadata cloud foundry google cloud platform synthetic monitoring process groups account usability dynatrace saas gui paas openshift key user actions administration user actions postgresql synthetic locations oneagent security Dynatrace Managed user management custom python technologies mongodb openstack user session monitoring continuous delivery citrix configuration alerting NGINX timestamp action naming linux nam installation masking error reporting database mission control jmeter recorder apache mobileapp RUM php threshold azure purepath davis scripting agent aix nodejs android