Splunk Search

Count field on specific value using streamstats

bernanda
Explorer

Hi Splunkers,

 

Anyone can help, I need to count field Flag where value is 0.

I've tried using this command " streamstats count(Flag=0) as Results_0 | table Results_0"

But the table is blank.

 

Please advice.

 

Thanks

Labels (1)
Tags (3)
0 Karma
1 Solution

bowesmana
SplunkTrust
SplunkTrust

Do you need to get a streaming count or a total count

| streamstats sum(eval(if(Flag=0,1,0))) as Results_0

You can use streamstats where Results_0 will be a new field added to each row, or if you just want to get a single count of the total where Flag=0, use stats, not streamstats.

 

View solution in original post

bowesmana
SplunkTrust
SplunkTrust

Do you need to get a streaming count or a total count

| streamstats sum(eval(if(Flag=0,1,0))) as Results_0

You can use streamstats where Results_0 will be a new field added to each row, or if you just want to get a single count of the total where Flag=0, use stats, not streamstats.

 

bernanda
Explorer

Thanks, it works 😁

0 Karma
Get Updates on the Splunk Community!

Splunk at Cisco Live 2025: Learning, Innovation, and a Little Bit of Mr. Brightside

Pack your bags (and maybe your dancing shoes)—Cisco Live is heading to San Diego, June 8–12, 2025, and Splunk ...

Splunk App Dev Community Updates – What’s New and What’s Next

Welcome to your go-to roundup of everything happening in the Splunk App Dev Community! Whether you're building ...

The Latest Cisco Integrations With Splunk Platform!

Join us for an exciting tech talk where we’ll explore the latest integrations in Cisco + Splunk! We’ve ...