Splunk Search

Extract and count IDs from a table

wkk
Explorer

Hi! 🙂 

I have a fallowing table:

SESSION_IDSUBMITTED_FROMSTAGE
1 submit
1startPagesomeStage1
2 submit
2page1someStage1
2page2someStage2


How could I count the number of SESSION_IDs that has SUBMITTED_FROM=startPage and STAGE=submit?

So looking at the above table the outcome of that logic should be SESSION_IDs

Labels (3)
0 Karma
1 Solution

gcusello
SplunkTrust
SplunkTrust

Hi @wkk,

you could try something like this:

index=your_index
| stats 
   values(SUBMITTED_FROM) AS SUBMITTED_FROM
   values(STAGE) AS STAGE
   BY SESSION_ID
| mvexpand SUBMITTED_FROM
| mvexpand STAGE
| search SUBMITTED_FROM=startPage STAGE=submit
| stats count BY SESSION_ID

Ciao.

Giuseppe

View solution in original post

wkk
Explorer

I slightly changed the query, as I didn't want to use search. Query ends up with the same results.

index=your_index
| stats 
   values(SUBMITTED_FROM) AS SUBMITTED_FROM
   values(STAGE) AS STAGE
   BY SESSION_ID
| where SUBMITTED_FROM=startPage STAGE=submit
| stats count BY SESSION_ID

 

0 Karma

wkk
Explorer

@gcusello thank you that solved my case 

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @wkk,

you could try something like this:

index=your_index
| stats 
   values(SUBMITTED_FROM) AS SUBMITTED_FROM
   values(STAGE) AS STAGE
   BY SESSION_ID
| mvexpand SUBMITTED_FROM
| mvexpand STAGE
| search SUBMITTED_FROM=startPage STAGE=submit
| stats count BY SESSION_ID

Ciao.

Giuseppe

gcusello
SplunkTrust
SplunkTrust

Hi @wkk ,

good for you, see next time!

Ciao and happy splunking

Giuseppe

P.S.: Karma Points are appreciated 😉

0 Karma
Get Updates on the Splunk Community!

.conf24 | Day 0

Hello Splunk Community! My name is Chris, and I'm based in Canberra, Australia's capital, and I travelled for ...

Enhance Security Visibility with Splunk Enterprise Security 7.1 through Threat ...

(view in My Videos)Struggling with alert fatigue, lack of context, and prioritization around security ...

Troubleshooting the OpenTelemetry Collector

  In this tech talk, you’ll learn how to troubleshoot the OpenTelemetry collector - from checking the ...