Splunk Search

How to obtain x% of the data

flora123
Path Finder

hello!

I want to know whether I can get 10% of the data?

...| eventstats count | eval ten_p=floor(count*0.1) | head ten_p...

BUT!

Error in 'head' command: The argument must be a positive number or a boolean expression.

Some people know how to obtain this information?
Thanks a lot.m(_ _)m

Tags (2)
0 Karma
1 Solution

sideview
SplunkTrust
SplunkTrust

You can use the head command with a boolean expression, and it will allow the streaming search to continue until the boolean expression returns false. This can be a neat trick especially when you can have it entirely in the streaming portion of the search, because you can get far fewer events off disk sometimes.

In this particular case though, the eventstats command is going to run through the entire search and so when the head command terminates it, it'll be too late to avoid getting all the events off disk.

Anyway, it would look more like this:

... | streamstats count as thisRowCount | eventstats count as totalCount | head thisRowCount<totalCount/10 

View solution in original post

sideview
SplunkTrust
SplunkTrust

You can use the head command with a boolean expression, and it will allow the streaming search to continue until the boolean expression returns false. This can be a neat trick especially when you can have it entirely in the streaming portion of the search, because you can get far fewer events off disk sometimes.

In this particular case though, the eventstats command is going to run through the entire search and so when the head command terminates it, it'll be too late to avoid getting all the events off disk.

Anyway, it would look more like this:

... | streamstats count as thisRowCount | eventstats count as totalCount | head thisRowCount<totalCount/10 
Get Updates on the Splunk Community!

Enter the Agentic Era with Splunk AI Assistant for SPL 1.4

  &#x1f680; Your data just got a serious AI upgrade — are you ready? Say hello to the Agentic Era with the ...

Stronger Security with Federated Search for S3, GCP SQL & Australian Threat ...

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

Accelerating Observability as Code with the Splunk AI Assistant

We’ve seen in previous posts what Observability as Code (OaC) is and how it’s now essential for managing ...