Splunk Search

How can I change duration [5s] to something I can calculate with?

svester
New Member

Hi, I made a search, and want to finetune it with something like "show duration >20seconds", but duration is showed as "duration [8s]". I tried extracting field and make "duration [8s]" a new extracted field, but I don't know how to calculate with these brackets, or how to define it.
Anyone who can help me out? Thanks!

Tags (1)
0 Karma
1 Solution

dkeck
Influencer

Hi,

so your field value is now "duration [8s]"?

than use this regex: duration\s+\[(?<field>\d+)

This will only give you the numbers.

View solution in original post

svester
New Member

One more problem I'm bumping in now.. what if I also get [..ms], so milliseconds... And I'm searching for, let's say duration>20, now I get results with >20 seconds AND >20 milliseconds. 2 regexes? Any other suggestions?

0 Karma

dkeck
Influencer

you can do a new field yes.

You can change the name of the field to "field_a" duration\s+\[(?<field_a>\d+).

So just give it a name where you now its milliseconds.

0 Karma

dkeck
Influencer

Hi,

so your field value is now "duration [8s]"?

than use this regex: duration\s+\[(?<field>\d+)

This will only give you the numbers.

svester
New Member

Thanks! It worked 🙂

0 Karma

dkeck
Influencer

Please accept my answer if it worked 🙂 Thank you

0 Karma

svester
New Member

Sorry, will do 🙂 Could you please check my 2nd comment? 🙂

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