Splunk Search

Why don't transaction results match?

ang3loliveira
Loves-to-Learn

Hello all,

The transaction command is not correctly grouping the events in query 1). The expected result is given by query 2). In the end, I need to run the query without the user_id filter which I used just for results validation.

Please, help!

1)

 

index="myindex" system="mysystem" url="https://myurl/"
| fields _raw, userId, eventDate
| rex field=_raw "(?<session_id_key_value>x-sessionid:[^;]*)"
| eval fields=split(session_id_key_value, ":")
| eval session_id=mvindex(fields, 1)
| rex field=_raw "(?<original_url>X-Original-URL:[^;]*)"
| eval fields=split(original_url, ":")
| eval original_url=mvindex(fields, 1)
| where isnotnull(session_id) AND session_id != "" AND isnotnull(userId) AND userId != ""
| rename userId as user_id
| transaction session_id maxevents=150 keepevicted=true mvlist=true
| where user_id="123456"
| table user_id, session_id, eventcount, duration, eventDate, original_url

 

 

Result:

4 events
Eventcounts: 15 (session_id: 123), 3 (session_id: 345), 4 (session_id: 345), 14 (session_id: 345)
eventDates:
04/30/2022 18:57:37 - 04/30/2022 18:57:43,
04/26/2022 20:21:23 - 04/26/2022 20:21:24,
04/26/2022 20:12:04 - 04/26/2022 20:15:43,
04/26/2022 20:01:30 - 04/26/2022 20:01:39,

2)

 

index="myindex" system="mysystem" url="https://myurl/" userId="123456"
| fields _raw, userId, eventDate
| rex field=_raw "(?<session_id_key_value>x-sessionid:[^;]*)"
| eval fields=split(session_id_key_value, ":")
| eval session_id=mvindex(fields, 1)
| rex field=_raw "(?<original_url>X-Original-URL:[^;]*)"
| eval fields=split(original_url, ":")
| eval original_url=mvindex(fields, 1)
| where isnotnull(session_id) AND session_id != "" AND isnotnull(userId) AND userId != ""
| rename userId as user_id
| transaction session_id maxevents=150 keepevicted=true mvlist=true
| table user_id, session_id, eventcount, duration, eventDate, original_url

 

 

2 events
Eventcounts: 15 (session_id: 123), 21 (session_id: 345)
eventDates:
04/30/2022 18:57:37 - 04/30/2022 18:57:43,
04/26/2022 20:01:30 - 04/26/2022 20:21:24

 

Thanks!

Labels (1)
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Why have you got 3 instances of transaction 345? What is it about your events that produces this?

0 Karma

ang3loliveira
Loves-to-Learn

Hello!

That's exactly the problem! The transaction command is not correctly grouping by session_id in the 1st query.

result_1.jpg

Tags (1)
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Do any of the other users use the same transactionids?

0 Karma

ang3loliveira
Loves-to-Learn

You mean, session_id? What's transactionid?

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Sorry, yes session_id

0 Karma
Get Updates on the Splunk Community!

Index This | When is October more than just the tenth month?

October 2025 Edition  Hayyy Splunk Education Enthusiasts and the Eternally Curious!   We’re back with this ...

Observe and Secure All Apps with Splunk

  Join Us for Our Next Tech Talk: Observe and Secure All Apps with SplunkAs organizations continue to innovate ...

What’s New & Next in Splunk SOAR

 Security teams today are dealing with more alerts, more tools, and more pressure than ever.  Join us for an ...