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!

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...