Splunk Search

How to extract fields with empty values at index time?

pavan_bhumanapa
New Member

In our logs, we have the below two lines where we need to extract both empty & values for Dms_Code. Currently we are getting only values, but not empty, due to this other values are not getting populated in the UI.

Regex :

EXTRACT-Server_Name=\[(?<TimeDate>[^]]+)\]\s\[(?P<Server_Name>[^]]+)\]\s\[(?P<severity>[^]]+)\]\s\[\w+\-(?P<Dms_Code>[^]]+)\]\s\[(?P<Incident>[^]]+)\]\s


[2014-07-16T22:38:17.251+08:00] [apj_corp1_osb_dit_admin] [NOTIFICATION] [] [oracle.security.audit.logger]

[2014-07-16T22:37:47.379+08:00] [apj_corp1_osb_dit_admin] [WARNING] [DMS-50966] [oracle.dms.collector]
Tags (2)
0 Karma

somesoni2
Revered Legend

Try this

EXTRACT-Server_Name = \[(?<TimeDate>[^\]]+)\]\s\[(?P<Server_Name>[^\]]+)\]\s\[(?P<severity>[^\]]+)\]\s\[(\w+-)*(?P<Dms_Code>\d*)]\s\[(?<Incident>[^\]]+)\]

strive
Influencer

I think it is because in your regex you have used w+ for Dms_Code, it is not getting empty values. Modify your regex to accept empty values also.

0 Karma
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 ...