Knowledge Management

Problem with parsing multi-line Key Value events from DBconnect Dump

hmdoan
Explorer

I'm fairly new to using DB Connect. But I needed to index event data from a netcool reporting database (Oracle 11g). As this is an event correlation database, I was forced to perform a dump to Splunk on a daily basis (rising column tailing won't work here). I was using key-value format initially and it seemed to work just fine - until I realized that some Oracle columns were really poorly formatted with unmatched quotes, new lines, CRs, etc. in them.

This broke how Splunk indexed those events resulting in me missing about 10% of my total events.

The way around this was to use Multi-line Key Value format for my output.

Now everything came in just fine. All events were accounted for. However, my Splunk fields were all truncated:

Example:
The event shows the following:
summary=The power supply in Bay # 1 has changed to state: general failure
name=Bob Edwards
ticketnumber=No fault found

Splunk field shows up as:
summary=The
name=Bob
ticketnumber=No

How do I make Splunk pull in everything?

This was not a problem when I used the single key-value output - due to the quotes be automatically put in for strings. Not sure what to do form MKV.

0 Karma
1 Solution

hmdoan
Explorer

I really wish Splunk would put the same intelligence for field extraction in the MKV output as for the KV output. The KV output is smart enough to escape funny characters and add quotes for strings with spaces in them.

Oh well. My solution was even simpler. Clean up the events at the source. I ended up cleaning up my poorly formatted strings by running regexp_replace in my SQL query where ever I knew I might have had an ugly string. This cleaned up any special control characters as well as un-matched quotes. With this string clean-up in place, going back and using the KV output worked perfectly:

select
   to_char(lastmodified,'YYYY/MM/DD HH24:MI:SS') timestamp,
   to_char(lastmodified,'YYYY/MM/DD HH24:MI:SS') lastmodified,
   to_char(firstoccurrence,'YYYY/MM/DD HH24:MI:SS') firstoccurrence,
   to_char(lastoccurrence,'YYYY/MM/DD HH24:MI:SS') lastoccurrence,
   regexp_replace(summary,'[[:cntrl:]]|\"', '')summary,
   regexp_replace(text1,'[[:cntrl:]]|\"', '')text1,
   regexp_replace(text2,'[[:cntrl:]]|\"', ' ')text2,
   regexp_replace(text3,'[[:cntrl:]]|\"', ' ')text3,
   serial

from 
   Blah...

where
   Blah-Blah

View solution in original post

hmdoan
Explorer

I really wish Splunk would put the same intelligence for field extraction in the MKV output as for the KV output. The KV output is smart enough to escape funny characters and add quotes for strings with spaces in them.

Oh well. My solution was even simpler. Clean up the events at the source. I ended up cleaning up my poorly formatted strings by running regexp_replace in my SQL query where ever I knew I might have had an ugly string. This cleaned up any special control characters as well as un-matched quotes. With this string clean-up in place, going back and using the KV output worked perfectly:

select
   to_char(lastmodified,'YYYY/MM/DD HH24:MI:SS') timestamp,
   to_char(lastmodified,'YYYY/MM/DD HH24:MI:SS') lastmodified,
   to_char(firstoccurrence,'YYYY/MM/DD HH24:MI:SS') firstoccurrence,
   to_char(lastoccurrence,'YYYY/MM/DD HH24:MI:SS') lastoccurrence,
   regexp_replace(summary,'[[:cntrl:]]|\"', '')summary,
   regexp_replace(text1,'[[:cntrl:]]|\"', '')text1,
   regexp_replace(text2,'[[:cntrl:]]|\"', ' ')text2,
   regexp_replace(text3,'[[:cntrl:]]|\"', ' ')text3,
   serial

from 
   Blah...

where
   Blah-Blah

jcoates_splunk
Splunk Employee
Splunk Employee

the fields with spaces in them need to be quoted, or you need to change your delimiter (though if you do it that way, you'll then need to do your own key-value extraction).

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas     Cisco Live 2026 is almost here, and this ...

What Is the Name of the USB Key Inserted by Bob Smith? (BOTS Hint, Not the Answer)

Hello Splunkers,   So you searched, “what is the name of the usb key inserted by bob smith?”  Not gonna lie… ...

Automating Threat Operations and Threat Hunting with Recorded Future

    Automating Threat Operations and Threat Hunting with Recorded Future June 29, 2026 | Register   Is your ...