Splunk Search

How to get the events where the value is greater than 40 using where condition?

jip31
Motivator

hello

I use this code

index="perfmon" sourcetype="perfmon:logicaldisk" instance=c:  | eval Value=round(Value, 2)."%" | where Value > "40.00%"  | dedup host | table host Value

but the WHEN condition dont works because when I do I have also datas
what I have to do for having 1 if Value > 40% and 0 if Value <40% when i count the events?
thanks

0 Karma
1 Solution

kmaron
Motivator
index="perfmon" sourcetype="perfmon:logicaldisk" instance=c: Value>40 
| dedup host 
| eval Value=round(Value, 2)."%" 
| table host Value

If you only want the events where the Value is greater than 40 you can add that to your initial search and it will drop any other events.

View solution in original post

0 Karma

ddrillic
Ultra Champion

"(?<percent>.*)%" will extract the numerical value...

You can test it with -

index=<any index>
| eval _raw="40.00%"
| rex field=_raw "(?<percent>.*)%"
0 Karma

jip31
Motivator

thanks!
regards

0 Karma

ddrillic
Ultra Champion

And this might be useful -

index=<any index>
| eval _raw="40.00%"
| rex field=_raw "(?<percent>.*)%"
| eval percent2  = case(percent >= 40, 1, percent < 40, 0)
0 Karma

kmaron
Motivator
index="perfmon" sourcetype="perfmon:logicaldisk" instance=c: Value>40 
| dedup host 
| eval Value=round(Value, 2)."%" 
| table host Value

If you only want the events where the Value is greater than 40 you can add that to your initial search and it will drop any other events.

0 Karma

jip31
Motivator

perfect thanks!

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!

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

Data Persistence in the OpenTelemetry Collector

This blog post is part of an ongoing series on OpenTelemetry. What happens if the OpenTelemetry collector ...

Thanks for the Memories! Splunk University, .conf25, and our Community

Thank you to everyone in the Splunk Community who joined us for .conf25, which kicked off with our iconic ...