Splunk Search

help me with field extraction

sravankaripe
Communicator

alt text

i want to convert it to

alt text

i want this fields

Average overtime
Max value overtime
min value overtime

Tags (1)
0 Karma
1 Solution

somesoni2
Revered Legend

Give this a try

your base search | rex field="ActualTime" "(?<sec>\d+) second (?<millisec>\d+) millisec (?<microsec>\d+) microsec (?<nanosec>\d+) nanosec" | eval ActualTime=round(sec+(millisec/1000)+(microsec/1000000)+(nanosec/1000000000),9) 

You can than add appropriate aggregation commands per your need. E.g.

your base search | rex field="ActualTime" "(?<sec>\d+) second (?<millisec>\d+) millisec (?<microsec>\d+) microsec (?<nanosec>\d+) nanosec" | eval ActualTime=round(sec+(millisec/1000)+(microsec/1000000)+(nanosec/1000000000),9) | stats avg(ActualTime) as "Average overtime" max(ActualTime) as "Max value overtime" min(ActualTime) as "min value overtime"

View solution in original post

somesoni2
Revered Legend

Give this a try

your base search | rex field="ActualTime" "(?<sec>\d+) second (?<millisec>\d+) millisec (?<microsec>\d+) microsec (?<nanosec>\d+) nanosec" | eval ActualTime=round(sec+(millisec/1000)+(microsec/1000000)+(nanosec/1000000000),9) 

You can than add appropriate aggregation commands per your need. E.g.

your base search | rex field="ActualTime" "(?<sec>\d+) second (?<millisec>\d+) millisec (?<microsec>\d+) microsec (?<nanosec>\d+) nanosec" | eval ActualTime=round(sec+(millisec/1000)+(microsec/1000000)+(nanosec/1000000000),9) | stats avg(ActualTime) as "Average overtime" max(ActualTime) as "Max value overtime" min(ActualTime) as "min value overtime"

sravankaripe
Communicator

| rex "ActualTime=\s(?[^|]*)\"" | rex field="ActualTime" "(?\d+) second (?\d+) millisec (?\d+) microsec (?\d+) nanosec" | eval ActualTime=round(sec+(millisec/1000)+(microsec/1000000)+(nanosec/1000000000),9)

it working for me thanks

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi sravankaripe,
did you tried with the round function?

| eval ActualTime=round(ActualTime,0)

after you can calculate avg, max and min

| stats avg(ActualTime) AS avg max(ActualTime) AS max min(ActualTime) AS min 

Bye.
Giuseppe

0 Karma

sravankaripe
Communicator

In above img ActualTime i extracted through rex.
So, the result which you gave not working for me.

0 Karma
Get Updates on the Splunk Community!

Upcoming Webinar: Unmasking Insider Threats with Slunk Enterprise Security’s UEBA

Join us on Wed, Dec 10. at 10AM PST / 1PM EST for a live webinar and demo with Splunk experts! Discover how ...

.conf25 technical session recap of Observability for Gen AI: Monitoring LLM ...

If you’re unfamiliar, .conf is Splunk’s premier event where the Splunk community, customers, partners, and ...

A Season of Skills: New Splunk Courses to Light Up Your Learning Journey

There’s something special about this time of year—maybe it’s the glow of the holidays, maybe it’s the ...