Splunk Enterprise

Help to accelerate search

jip31
Motivator

Hi

I use the search below which has to be used only in real time

The goal of the search is to calculate a percentage

It works fine except the performances because the subsearch returns a lot of events 

inde=toto (sourcetype= titi OR sourcetype=tutu) web-status=405

| fields web-status

| stats count as total by web-status

| appendcols 

[ search 

inde=toto (sourcetype= titi OR sourcetype=tutu) web-status=*

| fields web-status

| stats count as total2 by web-status]

| eval perc=(toto / toto2) * 100

What i can do please?

 

Tags (1)
0 Karma
1 Solution

jip31
Motivator

thanks for inormation I done a test with the 2 search on the same range time

your searck too 14, 2 seconds to end

my search 16,5

other question

and the percentage result is exactly the same...

 

View solution in original post

0 Karma

richgalloway
SplunkTrust
SplunkTrust

If the subsearch returns multiple results as you say then this query will fail.  The appendcols command does not ensure the subsearch results align with the main search results so the numbers used to calculate the perc value may be incorrect.

This can be done without a subsearch.

 

index=toto (sourcetype= titi OR sourcetype=tutu) web-status=*
| fields web-status
| stats count as total, sum(eval('web-status'=405)) as total405
| eval perc=(total405 * 100 / total)

 

Pro tip: Avoid using hypens (-) in field names as they can confuse the parser.

---
If this reply helps you, Karma would be appreciated.
0 Karma

jip31
Motivator

thanks for inormation I done a test with the 2 search on the same range time

your searck too 14, 2 seconds to end

my search 16,5

other question

and the percentage result is exactly the same...

 

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, ...