Splunk Search

search language

francly
Explorer

Hi, how do I get subtotal count for each Host and Total for all count, in additional count for all different status.

Host                            Status                             Count

HostADisconnected1
HostARunning19
HostARunningWithErrors2
HostABadConnectivity2
HostBDisabled2
HostBDisconnected1
HostBRunning17
HostBRunningWithErrors5
HostCBadConnectivity1
HostCRunning7
HostCRunningWithErrors5
Labels (1)
0 Karma
1 Solution

PickleRick
SplunkTrust
SplunkTrust

You're using count as a splunk function whereas in original post count is a field. So your count will just count the counts 😉 and what seems to be really needed is a sum of counts.

And your construction will yield some strange results.

What the OP wanted was simply one:

<original search> | stats sum(Count) by Host | addtotals row=f col=t labelfield=Host

and two:

<original search>| stats sum(Count) by Status | <optionaly addtotals as in example above>

 

View solution in original post

Tags (1)
0 Karma

PickleRick
SplunkTrust
SplunkTrust

You need two different searches - one to sum count over hosts (and then do addtotals to get total sum) and another one to sum over statuses. That's the simplest solution I think

0 Karma

francly
Explorer

thanks for response, can you provide the query.

Tags (1)
0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @francly,

you could try something like this.

index=your_index
| stats count BY host Status
| append [ search 
     index=your_index
     | stats count BY host
     | eval Status="Total"
     ]
| sort host Status
| rename host AS Host

Ciao.

Giuseppe

0 Karma

PickleRick
SplunkTrust
SplunkTrust

You're using count as a splunk function whereas in original post count is a field. So your count will just count the counts 😉 and what seems to be really needed is a sum of counts.

And your construction will yield some strange results.

What the OP wanted was simply one:

<original search> | stats sum(Count) by Host | addtotals row=f col=t labelfield=Host

and two:

<original search>| stats sum(Count) by Status | <optionaly addtotals as in example above>

 

Tags (1)
0 Karma
Get Updates on the Splunk Community!

Join Us for Splunk University and Get Your Bootcamp Game On!

If you know, you know! Splunk University is the vibe this summer so register today for bootcamps galore ...

.conf24 | Learning Tracks for Security, Observability, Platform, and Developers!

.conf24 is taking place at The Venetian in Las Vegas from June 11 - 14. Continue reading to learn about the ...

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...