Splunk Search

How extract field and value using rex?

karthi2809
Builder

29-Mar-2023 04:56:35:PM: |CPU Utilization % Average ------- 11

 

Expected result:

11

Labels (1)
Tags (1)
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
| rex "(?<expected>\d+)$"
0 Karma

karthi2809
Builder

@ITWhisperer 

rex field=_raw "MemoryUsage %(?<MemoryUtilization>[^']+)"

MY result is

------------ 41.4

 

expected result

41.4

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

If you move the goal posts by providing different examples, you can expect the solution to break. Try something like this (based on the two examples given so far!)

| rex "(?<expected>[\d\.]+)$"
Get Updates on the Splunk Community!

Join Us for Splunk University and Get Your Bootcamp Game On!

If you know, you know! Splunk University is the vibe this summer so register today for bootcamps galore ...

.conf24 | Learning Tracks for Security, Observability, Platform, and Developers!

.conf24 is taking place at The Venetian in Las Vegas from June 11 - 14. Continue reading to learn about the ...

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...