20 Jan 2022 02:04 PM - last edited on 30 May 2023 02:38 PM by Michal_Gebacki
Hello everyone,
I 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.
Solved! Go to Solution.
30 Mar 2022 06:19 PM
You'll want to use the API V2 - /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.
15 Apr 2022 03:30 PM
That's works fine!
Thank you @ChadTurner
19 Apr 2022 12:20 AM
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 be required to calculate the to / from timestamps within your calling app 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
These will give you Dynatrace pre calculated 'estimated' number of active users and sessions. 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
13 Sep 2022 03:02 PM
Unfortunately,
The three metrics are only available for WEB applications.