Splunk Search

how to get the total row number of a search result

KShen
New Member

I have a search string:

sourcetype=databaseError "object is null" 

to get the total row number of the result.

need to display like underneath:

object is null error: 28

Tags (2)
0 Karma
1 Solution

dwaddle
SplunkTrust
SplunkTrust

This is a little vague. Are you using this in a dashboard? Or just in the search bar or what? Traditionally you would use the stats command to get a count of events.

sourcetype=databaseError "object is null"  | stats count

But, if you're building a dashboard then you may want the events and the count both on the dashboard. One as a single value field (using | stats count) and one as a table of events.

Perhaps you could clarify your use for this in order to help folks come up with the best answer?

View solution in original post

stephanefotso
Motivator

Hello! Here is what you can do: sourcetype=databaseError|eval object_string=case(searchmatch("object is null"),"object is null")|stats count by object_string

You can take this as an example, with the _internal index:

index=_internal|eval error_tag=case(searchmatch("error"),"error")|stats count by object_tag
SGF
0 Karma

bill_bartlett
Path Finder

Are you looking for something more detailed than the obvious 'stats count'?

sourcetype=databaseError "object is null" | stats count

dwaddle
SplunkTrust
SplunkTrust

This is a little vague. Are you using this in a dashboard? Or just in the search bar or what? Traditionally you would use the stats command to get a count of events.

sourcetype=databaseError "object is null"  | stats count

But, if you're building a dashboard then you may want the events and the count both on the dashboard. One as a single value field (using | stats count) and one as a table of events.

Perhaps you could clarify your use for this in order to help folks come up with the best answer?

Get Updates on the Splunk Community!

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer at Splunk .conf24 ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

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