Splunk Search

Field extraction for multiple types of values

srinivasgowda
Explorer

Hello all,

I am trying to extract the data from the field evtComponent from the below event, and this has a multiple types of data that is coming in as below.

1) ZENOSS-MIB::evtComponent = STRING: "HostSystem_host-1240" ZENOSS-MIB::evtClass = STRING: "/Status/Ping"

2) ZENOSS-MIB::evtComponent = STRING: "\"London\"" ZENOSS-MIB::evtClass = STRING:

 

The highlighted fields needs to be extracted, however when I use the below extraction this only satisfies the correct extraction on example 1 but fails to just extract the field from example 2. Can you please suggest.

Below is the extraction that I am using.

ZENOSS-MIB::evtComponent = STRING: \"(?<component>.*)\"\s+ZENOSS-MIB::evtClass\s

 

Thank you.

Labels (2)
0 Karma

srinivasgowda
Explorer

This worked. Thank you @gcusello 

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @srinivasgowda,

you should try to use two regexes:

the first

| rex "evtComponent\s+\=\s+STRING:\s+\"(?<evtComponent>[^\"]+)\"\s+"

that you can test at https://regex101.com/r/Ip8Vj2/1

the second

| rex "evtComponent\s+\=\s+STRING:\s+\"\\\"(?<evtComponent>[^\\]+)"

that you can test at https://regex101.com/r/Ip8Vj2/2

Ciao.

Giuseppe

Get Updates on the Splunk Community!

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer Certification at ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

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