# User session events and actions by session ID

**URL:** <https://community.dynatrace.com/t/user-session-events-and-actions-by-session-id/34823>\
**Category:** Dynatrace API\
**Tags:** user-sessions, dynatrace-api\
**Created:** [April 13, 2022, 9:30pm UTC](https://community.dynatrace.com/t/user-session-events-and-actions-by-session-id/34823 "2022-04-13T21:30:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![TripleP](https://avatars.discourse-cdn.com/v4/letter/t/a9a28c/32.png) [@TripleP](https://community.dynatrace.com/u/TripleP)\
**Post date:** [April 13, 2022, 9:30pm UTC](https://community.dynatrace.com/t/user-session-events-and-actions-by-session-id/34823/1 "2022-04-13T21:30:39Z")

</div>

I’m trying to get the events/actions for a specific session.

I have tried this query:

SELECT userevent.\* FROM usersession WHERE ((useraction.application=‘[site.com](http://site.com)’ OR userevent.application=‘[site.com](http://site.com)’ OR usererror.application=‘[site.com](http://site.com)’)) AND userId IS “User Name” AND usersession.userSessionId IS "session-id"I get this back:  
{&nbsp;&nbsp;&nbsp;&nbsp;“extrapolationLevel”:&nbsp;1,&nbsp;&nbsp;&nbsp;&nbsp;“columnNames”:&nbsp;[&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;“userevent.application”,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;“userevent.domain”,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;“userevent.internalApplicationId”,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;“userevent.name”,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;“userevent.page”,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;“userevent.pageGroup”,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;“userevent.pageReferrer”,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;“userevent.pageReferrerGroup”,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;“userevent.startTime”,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;“userevent.type”&nbsp;&nbsp;&nbsp;&nbsp;],&nbsp;&nbsp;&nbsp;&nbsp;“values”:&nbsp;[]}But when I look at the same session in the dynatrace website I see a bunch of records.&nbsp; I’m not sure how to craft the query to get the event/action detail I see on the dynatrace site when I query user sessions.

I am trying to provide data to a 3rd party that had a data breach so I’m just trying to gather as much information as possible to help them out.

---

<div class="post-metadata">

**Author:** ![Fin\_Ubels](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/fin_ubels/32/18008_2.png) [@Fin\_Ubels](https://community.dynatrace.com/u/Fin_Ubels)\
**Post date:** [April 13, 2022, 10:54pm UTC](https://community.dynatrace.com/t/user-session-events-and-actions-by-session-id/34823/2 "2022-04-13T22:54:25Z")

</div>

Hey TripleP

Having a look at the query there is no need for this **((useraction.application=‘[site.com](http://site.com)’&nbsp;OR&nbsp;userevent.application=‘[site.com](http://site.com)’&nbsp;OR&nbsp;usererror.application=‘[site.com](http://site.com)’****))&nbsp;AND&nbsp;userId&nbsp;IS&nbsp;“User Name”&nbsp;AND** as later on in the query you are specifying a session ID which doesn’t need an application or user ID to narrow down a query. So if you already know the ID of the session then all you need to do is:

 ![Fin_Ubels_2-1649890294035.png](https://global.discourse-cdn.com/dynatrace/original/3X/b/5/b59b35f3db388847424bc43370a9dadaebfd9a30.png)

SELECT userevent.\* FROM usersession WHERE usersession.userSessionId IS “sessionID”

This returns the events from a session with ID&nbsp;“sessionID”.

---

<div class="post-metadata">

**Author:** ![TripleP](https://avatars.discourse-cdn.com/v4/letter/t/a9a28c/32.png) [@TripleP](https://community.dynatrace.com/u/TripleP)\
**Post date:** [April 14, 2022, 4:01pm UTC](https://community.dynatrace.com/t/user-session-events-and-actions-by-session-id/34823/3 "2022-04-14T16:01:01Z")

</div>

That works fine in the site, but when I make the API call using Postman it doesn’t return anything.

Postman:

GET:&nbsp;[https://XXXXX.live.dynatrace.com/api/v1/userSessionQueryLanguage/table?query=SELECT%20userevent.\*%20FROM%20usersession%20WHERE%20usersession.userSessionId%20IS%20"QKSKGBOGPCTKCCQANCIFUAKIWKMSUAOC-0"](https://XXXXX.live.dynatrace.com/api/v1/userSessionQueryLanguage/table?query=SELECT%20userevent.%2A%20FROM%20usersession%20WHERE%20usersession.userSessionId%20IS%20%22QKSKGBOGPCTKCCQANCIFUAKIWKMSUAOC-0%22)

Response:

{&nbsp;&nbsp;&nbsp;&nbsp;“extrapolationLevel”:&nbsp;1,&nbsp;&nbsp;&nbsp;&nbsp;“columnNames”:&nbsp;[&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;“userevent.application”,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;“userevent.domain”,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;“userevent.internalApplicationId”,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;“userevent.name”,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;“userevent.page”,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;“userevent.pageGroup”,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;“userevent.pageReferrer”,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;“userevent.pageReferrerGroup”,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;“userevent.startTime”,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;“userevent.type”&nbsp;&nbsp;&nbsp;&nbsp;],&nbsp;&nbsp;&nbsp;&nbsp;“values”:&nbsp;[]}

Dynatrace Site:

 ![TripleP_0-1649951899488.png](https://global.discourse-cdn.com/dynatrace/original/3X/9/3/937297a8dbb76c7f08f582f1eb638f85cf510feb.png)

Another thing I noticed is that the Dynatrace site has an IP address that doesn’t match anything in my webserver logs.&nbsp; Any idea why the don’t match?

Thanks for the help

---

<div class="post-metadata">

**Author:** ![Fin\_Ubels](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/fin_ubels/32/18008_2.png) [@Fin\_Ubels](https://community.dynatrace.com/u/Fin_Ubels)\
**Post date:** [April 18, 2022, 11:14pm UTC](https://community.dynatrace.com/t/user-session-events-and-actions-by-session-id/34823/4 "2022-04-18T23:14:57Z")

</div>

Hey TripleP

The only thing I can think of as to why it wouldn’t work is that you haven’t specified a timeframe to search within and if you don’t specify a timeframe then it defaults to the last 2 hours. As you can see in the following image I specified a starting time as a query parameter.

 ![Fin_Ubels_0-1650323413782.png](https://global.discourse-cdn.com/dynatrace/original/2X/6/64e1323e4566db3ddaa182839aec95d16eec31b7.png)

As for the IP addresses not matching check the settings page for your application as by default I believe they are set to be masked to comply with regulations.

 ![Fin_Ubels_1-1650323553822.png](https://global.discourse-cdn.com/dynatrace/original/3X/a/2/a27d3816e03df9674a5f815553801fd67df86038.png)
