Splunk Search

How to count until a specific number and go to next value in field

rvalli
Explorer

Here is my current query:

index=abc* |stats count by user,date |eval highcount=(if count >=1000,1000,count)

This gives me output like this:

user1 200 200
user2 34 34
user3 1200 1000 --> I want to stop counting for this user once high count reaches 1000 and continue counting other users as it finds.

Thanks

Tags (1)
0 Karma
1 Solution

woodcock
Esteemed Legend

Like this:

index=abc* 
| stats count BY user date 
| eval count = min(1000, count)

View solution in original post

0 Karma

woodcock
Esteemed Legend

Like this:

index=abc* 
| stats count BY user date 
| eval count = min(1000, count)
0 Karma

rvalli
Explorer

Yes please ,Yes please.

0 Karma

to4kawa
Ultra Champion

First of all, what is the purpose and duration of the search?(Do you want to count the number of users?)

Please provide a sample log.

How many items are you searching for?

0 Karma

rvalli
Explorer

I think I figured:
index=abc* |stats count by user,date |eval count=(if count >=1000,1000,count)

Is there a better way to do this?

to4kawa
Ultra Champion

Do you want to reduce search time?

Splunk basically searches for search criteria within the search period.

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

Tech Talk Recap | Mastering Threat Hunting

Mastering Threat HuntingDive into the world of threat hunting, exploring the key differences between ...

Observability for AI Applications: Troubleshooting Latency

If you’re working with proprietary company data, you’re probably going to have a locally hosted LLM or many ...

Splunk AI Assistant for SPL vs. ChatGPT: Which One is Better?

In the age of AI, every tool promises to make our lives easier. From summarizing content to writing code, ...