Splunk Search

How to get stats based on multiple values for a single source?

Nidheesh
Explorer

I have 3 sources source1, source2, source3 and 5 sourcetypes sourcetype1, sourcetype2, sourcetype3, sourcetype4, sourcetype5 for a single host host1.

Where sourcetype1 belongs exclusively to source1 and sourcetype2 to source2 but source3 has 3 sourcetypes; sourcetype3, sourcetype4 and sourcetype5.

Likewise, I have 2 sources source4, source5 and 3 sourcetypes sourcetype6, sourcetype7, sourcetype8 for another host host2. With source4 having sourcetype6 and source5 having sourcetype7 and sourcetype8.

I wish to have a stats count like this:

        ---------------------------------------
        host         source      sourcetype
        ---------------------------------------
        host1       source1     sourcetype1
        host1       source2     sourcetype2
        host1       source3     sourcetype3
        host1       source3     sourcetype4
        host1       source3     sourcetype5
        host2       source4     sourcetype6
        host2       source5     sourcetype7
        host2       source5     sourcetype8

Can someone please help?

0 Karma
1 Solution

adonio
Ultra Champion

maybe try this:

.... | stats values(sourcetype) as v_sourcetype by source host

View solution in original post

0 Karma

renjith_nair
Legend

It shouldn't be that simple but what's missing from

"your search"|stats count by host,source,sourcetype
---
What goes around comes around. If it helps, hit it with Karma 🙂

DalJeanis
Legend

It is that simple. Or, at least, that meets the request the OP wrote up.

0 Karma

493669
Super Champion

try below if you want count:

...|stats count by sourcetype

and if you want all values as well then try:

...|stats values(*) as * count by sourcetype

Nidheesh
Explorer

Thank you 🙂

0 Karma

adonio
Ultra Champion

maybe try this:

.... | stats values(sourcetype) as v_sourcetype by source host

0 Karma

Nidheesh
Explorer

Thank you Adonio. It worked.

0 Karma
Get Updates on the Splunk Community!

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...

.conf24 | Personalize your .conf experience with Learning Paths!

Personalize your .conf24 Experience Learning paths allow you to level up your skill sets and dive deeper ...

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...