Splunk Search

regex formation

harsh1734
New Member

hi,
in my log files there is a field name cpu time with different time values like 57.682 sec,0.572 sec and among the highest it is 1133.982 secs when i am trying to extract 1133.982,it showing me the message..

No regex could be learned. Try providing different examples or restriction
so how can i extract this field

Tags (1)
0 Karma

mothmen
Engager

Using the regex to get establish field name can be a pretty big pain.

Unless there's a good reason not to, I'd recommend logging the CPU Time within the .log file as something like: "CPU_Time=1133.982" (minus the quotation marks)

Splunk will automatically create the field "CPU_Time" if you log your information this way. It's extremely convenient.

0 Karma

jonuwz
Influencer
... | rex "(?<cpu_time>\d+(?:\.\d+)?) sec"

This looks for a number, optionally followed by .xxxx follwowd by "sec", and sets a field called cpu_time to the number component of the string.

0 Karma

Drainy
Champion

If you could post an example event one of the community or myself could probably write a regex for you

0 Karma
Get Updates on the Splunk Community!

Index This | What goes away as soon as you talk about it?

May 2025 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with this month’s ...

What's New in Splunk Observability Cloud and Splunk AppDynamics - May 2025

This month, we’re delivering several new innovations in Splunk Observability Cloud and Splunk AppDynamics ...

Getting Started with Splunk Artificial Intelligence, Insights for Nonprofits, and ...

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...