Splunk Search

Grouping by two fields, want to get distinct count of values in second field

jbrenner
Path Finder

Hi,

I wrote the following Splunk query which returns a list of distinct USER_AGENTs for each SESSION_ID:

index=abc | rex field=_raw "-S:(?<SESSION_ID>\w+)-.+User agent: '(?<USER_AGENT>.+)', Referrer" | stats count by SESSION_ID, USER_AGENT

I would now like to modify this query to return a list of SESSION_IDs that have more than one unique value for USER_AGENT, and the count of the unique values.

Thanks!
Jonathan

0 Karma
1 Solution

somesoni2
Revered Legend

Try this

index=abc | rex field=_raw "-S:(?<SESSION_ID>\w+)-.+User agent: '(?<USER_AGENT>.+)', Referrer" | stats dc(USER_AGENT) as USER_AGENTs by SESSION_ID | where USER_AGENTs>1

View solution in original post

somesoni2
Revered Legend

Try this

index=abc | rex field=_raw "-S:(?<SESSION_ID>\w+)-.+User agent: '(?<USER_AGENT>.+)', Referrer" | stats dc(USER_AGENT) as USER_AGENTs by SESSION_ID | where USER_AGENTs>1

jbrenner
Path Finder

That worked.
Thanks!

0 Karma
Get Updates on the Splunk Community!

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer Certification at ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...