All Apps and Add-ons

JMS Messaging Modular Input: How to automatically run xmlkv?

David
Splunk Employee
Splunk Employee

I am using the JMS Mod Input. The mod input outputs the timestamp, eventid, and then a msg_body="[Giant XML Blob]". If I run in search and use |xmlkv, it nicely pulls out the xml fields from the middle of that event, but that doesn't work if I set kv_mode=XML (I think) because the entire event isn't XML.

I can't seem to find a way to have xmlkv automatically run, though. Has anyone dealt with this before?

0 Karma

Damien_Dallimor
Ultra Champion

Fast Forward 2 years......November 2016 update....

In the latest version of the code , you should use com.splunk.modinput.jms.custom.handler.BodyOnlyMessageHandler , this is built in with the core release , so you don't need to do anything other than declaring this handler to be applied in your JMS stanza.

https://github.com/damiendallimore/SplunkModularInputsJavaFramework/blob/master/jms/src/com/splunk/m...

0 Karma

rahlers_splunk
Splunk Employee
Splunk Employee

You can also strip it down to just the JSON or XML message this way:
http://answers.splunk.com/answers/201739/how-to-get-a-sourcetype-of-json-mixed-with-text-th.html

If it is XML, add the following to you props.conf

SEDCMD-stripnonxml-1=s/^.*msg_body="//
SEDCMD-stripnonxml-2=s/\"$//
0 Karma

Damien_Dallimor
Ultra Champion
The 'xml' and 'json' modes will not extract any fields when used on data that isn't of the  correct format (JSON or XML)

So , if you want to use KV_MODE in props.conf , the indexed event has to be just the XML payload.

You can plug in a custom message handler to the JMS Modular Input that will index only the XML message payload.

Here is some code : https://gist.github.com/damiendallimore/eef6434b8daec578c42a

1) compile this code and add the class file to a jar file
2) place this jar file in SPLUNK_HOME/etc/apps/jms_ta/bin/lib
3) in your JMS stanza , declare this custom handler to be used

alt text

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!

Index This | What travels the world but is also stuck in place?

April 2026 Edition  Hayyy Splunk Education Enthusiasts and the Eternally Curious!   We’re back with this ...

Discover New Use Cases: Unlock Greater Value from Your Existing Splunk Data

Realizing the full potential of your Splunk investment requires more than just understanding current usage; it ...

Continue Your Journey: Join Session 2 of the Data Management and Federation Bootcamp ...

As data volumes continue to grow and environments become more distributed, managing and optimizing data ...