Getting Data In

Can not extract value with whitespace at index time

sebastian_pribn
Engager

Hello,

 

I have a not ideal log, looking like this, for example:

"field1=value1"  "field2=val ue 2" "field3=value3"

 

And I want to exlude the key-value pairs at index time.

Combinations like the first kv-pair is not problem. The second value however is a problem. With my extraction I can only get the "val" part, and the extraction stops at the whitespace.

 

My rule in transforms.conf looks like this:

 

 

[example]
REGEX = (?<_KEY_1>([^=\"]+)=(?<_VAL_1>([^=\"]+)

 

 

 

To clarify, my results in splunk are looking like this:

field1 = value1

field2 = val

field3 = value3

 

I am not sure what I am missing.

Labels (1)
Tags (2)
0 Karma

richgalloway
SplunkTrust
SplunkTrust

You have the right regex, but with a slightly muddled syntax (too many left parens).  Try this alternative:

[example]
REGEX = ([^=\"]+)=([^=\"]+)
FORMAT = $1::$2

 

---
If this reply helps you, Karma would be appreciated.

sebastian_pribn
Engager

Oh, you are right. I had run so many tests yesterday that it was getting a little confusing.

 

I've tried both variants, with the same regex:

 

[example]
REGEX = (?<_KEY_1>([^=\"]+))=(?<_VAL_1>([^=\"]+))

 

and

 

[example]
REGEX = ([^=\"]+)=([^=\"]+)
FORMAT = $1::$2

 

but I am only getting the value to the first whitespace.

"key=val ue"

will result in

key=val

with both variants.

 

I've tested all changes in props.conf / transforms.conf under etc/system/local to ensure, that there is no other setting that is overwriting my tests.

 

Maybe I should also mention that these value are embedded in some kind of pseudo json format. I am, however, not using indexed extractions.

The events are looking something like this:

{"severity":"info","time":"123456789","message":"key1=value1" "key2=val ue 2"}

0 Karma

richgalloway
SplunkTrust
SplunkTrust

The regex should work.  It works in regex101.com.  See https://regex101.com/r/ZHCFQp/1

---
If this reply helps you, Karma would be appreciated.
0 Karma

PickleRick
SplunkTrust
SplunkTrust

If the key-value pairs are enclosed in parentheses I'd anchor the regex in parentheses as well.

0 Karma
Get Updates on the Splunk Community!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...