Splunk Search

How to extract fields with a value greater than 3 seconds?

sp_lunky
New Member

First sorry for my english. I'm testing Splunk at the moment, and i have a task to extract a field from *.log files.

Raw value is :

..xxxxxxxxxxxxxxx Duration: 1 s. 466 ms....
..xxxxxxxxxxxxxxx Duration: 4 s. 066 ms...
..xxxxxxxxxxxxxxx Duration: 12 s. 300 ms...

I want to to make an alert when the Duration is greater than 3 s

for a Report I filtered with search command, but it won't show the value like: "11", "12"

host=NAME | search (duration:"4" OR "5" OR "6" OR "7" OR "8" OR "9" ) 

Any help please!?

0 Karma
1 Solution

paulstout
Path Finder

Could you try this search?

host=name | rex field=_raw "Duration\:\s(?<duration_s>\d+)\ss\.\s+(?<duration_ms>\d+)\sms" | eval duration=duration_s+(duration_ms/1000) | search duration_s="*"?

This would give you a float with the actual duration in duration and separate fields for the second and millisecond component to use your original filtering.

View solution in original post

sp_lunky
New Member

Thank you very much! Both are good and working. But I accepted paulstout answer because it satisfy both my needs.
Thank you again!

0 Karma

DalJeanis
Legend

I believe you can accept more than one answer, if they both helped.

0 Karma

sp_lunky
New Member

Sorry, i didn't now that

0 Karma

paulstout
Path Finder

Could you try this search?

host=name | rex field=_raw "Duration\:\s(?<duration_s>\d+)\ss\.\s+(?<duration_ms>\d+)\sms" | eval duration=duration_s+(duration_ms/1000) | search duration_s="*"?

This would give you a float with the actual duration in duration and separate fields for the second and millisecond component to use your original filtering.

paulstout
Path Finder

To meet the original 3 second requirement, | where duration_s>3 or | search duration_s>3 should suffice.

0 Karma

vasanthmss
Motivator

try this,

your base search | rex "Duration:\s+(?<duration>\d+)" | where duration>3

Hope this will help you.

V

somesoni2
Revered Legend

The threshold sp_lunky looking for is 3 sec. You may want to correct it.

0 Karma

vasanthmss
Motivator

updated the answer.

V
0 Karma
Get Updates on the Splunk Community!

Splunk Decoded: Service Maps vs Service Analyzer Tree View vs Flow Maps

It’s Monday morning, and your phone is buzzing with alert escalations – your customer-facing portal is running ...

What’s New in Splunk Observability – September 2025

What's NewWe are excited to announce the latest enhancements to Splunk Observability, designed to help ITOps ...

Fun with Regular Expression - multiples of nine

Fun with Regular Expression - multiples of nineThis challenge was first posted on Slack #regex channel ...