Splunk Search

help fixing cli search with sourcetype specified

alfredoh14
Explorer

when i type in the command line (cmd not powershell):
splunk search "*" -maxout 0 | find /c /v ""

I get the return of about 195k records.

however when i filter by one of the sourcetype, from one of the splunk free tutorials, by typeing:
splunk search "*" 'sourcetype=e' -maxout 0 | find /c /v ""

I still get the same result of 195k records.

the "| find /c /v "" " should return only the line count.
so if i filter by the sourcetype it should return around 165k records which are the number of records associated with that source type currently in my splunk db.

can someone help me correct my syntax, i tried google searches but none were able to give me an example, which I think is due to the fact I do not know how the syntax should work in the first place.
I am using the windows cmd, and I plan to use the windows cmd, not the website interface, thanks for understanding.

Labels (1)
0 Karma

tscroggins
Influencer

@alfredoh14 

In your examples, "*" is your search string. To expand it, add search terms to that string:

splunk search "* sourcetype=e" -maxout 0 | find /c /v ""

To dispense with find and have Splunk report the event count:

splunk search "* sourcetype=e | stats count"

If you know the index you're searching, you can use tstats for much faster results:

splunk search "| tstats count where index=main sourcetype=e"

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...