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
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Observe and Secure All Apps with Splunk

 Join Us for Our Next Tech Talk: Observe and Secure All Apps with SplunkAs organizations continue to innovate ...

What's New in Splunk Observability - August 2025

What's New We are excited to announce the latest enhancements to Splunk Observability Cloud as well as what is ...

Introduction to Splunk AI

How are you using AI in Splunk? Whether you see AI as a threat or opportunity, AI is here to stay. Lucky for ...