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
Get Updates on the Splunk Community!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...