# Live user session: what metrics?

**URL:** <https://community.dynatrace.com/t/live-user-session-what-metrics/33820>\
**Category:** Dashboarding\
**Tags:** customization, dynatrace-managed, dashboards-classic, user-sessions\
**Created:** [January 20, 2022, 2:04pm UTC](https://community.dynatrace.com/t/live-user-session-what-metrics/33820 "2022-01-20T14:04:04Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jduhamel](https://avatars.discourse-cdn.com/v4/letter/j/b9e5f3/32.png) [@jduhamel](https://community.dynatrace.com/u/jduhamel)\
**Post date:** [January 20, 2022, 2:04pm UTC](https://community.dynatrace.com/t/live-user-session-what-metrics/33820/1 "2022-01-20T14:04:04Z")

</div>

Hello everyone,

I&nbsp;would like to retrieve “User live” sessions in dashboard created with PowerBi with API method. I had custom APP and classic APP, i’m wonder what metrics i should use. After many tests no one gave me the same value with the dashboard Dynatrace.

(Api1 V1/V2, Custom metrics,)

I try to find a workaround with “Active session”?

Someone can help me?

Regards

J.

---

<div class="post-metadata">

**Author:** ![ChadTurner](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/chadturner/32/161_2.png) [@ChadTurner](https://community.dynatrace.com/u/ChadTurner)\
**Post date:** [March 30, 2022, 5:19pm UTC](https://community.dynatrace.com/t/live-user-session-what-metrics/33820/2 "2022-03-30T17:19:38Z")

</div>

You’ll want to use the API V2 -&nbsp;/metrics/query. You’ll build your query in USQL then paste it into the API and it will give you the CURL, URL and the json output for your Power BI. Just make sure you have created a token just for the Power BI.

---

<div class="post-metadata">

**Author:** ![\_davidemascolo](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/_davidemascolo/32/16111_2.png) [@\_davidemascolo](https://community.dynatrace.com/u/_davidemascolo)\
**Post date:** [April 15, 2022, 2:30pm UTC](https://community.dynatrace.com/t/live-user-session-what-metrics/33820/3 "2022-04-15T14:30:54Z")

</div>

That’s works fine!  
Thank you&nbsp;[@ChadTurner](https://community.dynatrace.com/user/14877)

---

<div class="post-metadata">

**Author:** ![gopher](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/gopher/32/5728_2.png) [@gopher](https://community.dynatrace.com/u/gopher)\
**Post date:** [April 18, 2022, 11:20pm UTC](https://community.dynatrace.com/t/live-user-session-what-metrics/33820/4 "2022-04-18T23:20:36Z")

</div>

Hi,

There is no clear answer hear as Dynatrace does not actually expose the live sessions, it is ‘in memory’ only and the values you see on the application and user sessions screen under ‘live’ are not retrievable via usql or metrics.

There are 2 options,

**1.** As mentioned above, use usql and extract via the API.

This is going to have to be delayed data (e.g what happened last hour) based on the completion of user sessions, so will never be entirely accurate for what you want and because the timestamp for usql extraction doesn’t have relative time frames will&nbsp; be required to calculate the to / from timestamps within your calling app&nbsp; or leave the default as ‘last 2 hours’ and then add a timestamp to the usql to limit the time (needs to be = polling time)

example queries below.

SELECT count(distinct UserId) as ‘Current Unique UserID’ FROM usersession  
Where useraction.application IN (“xxx”) and userId IS NOT NULL

SELECT count(distinct UserId) as ‘Sessions with Errors’ FROM usersession  
Where useraction.application IN (“xxx”) and userId IS NOT NULL and useraction.requestErrorCount \> 0

**2.** The better alternative is to use the inbuilt calculated metrics

builtin:apps.web.activeUsersEst

builtin:apps.web.activeSessions

builtin:apps.other.userCount.osAndVersion-std

 ![Peter_Ralston_0-1650322755617.png](https://global.discourse-cdn.com/dynatrace/original/2X/6/6021ba56915e4ad8f4ac7150d71cdb4a63117c24.png)

These will give you Dynatrace pre calculated ‘estimated’ number of active users and sessions.&nbsp; it is split between mobile & web, so you might need to show this data seperately.

This is retrieved via the api v2 metrics (as above) and can do relative timestamps (last 5 min), so is much easier to handle and graph.

Anyway, good luck

---

<div class="post-metadata">

**Author:** ![Malaik](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/malaik/32/32673_2.png) [@Malaik](https://community.dynatrace.com/u/Malaik)\
**Post date:** [September 13, 2022, 2:02pm UTC](https://community.dynatrace.com/t/live-user-session-what-metrics/33820/5 "2022-09-13T14:02:01Z")

</div>

Unfortunately,

The three metrics are only available for WEB applications.
