Dashboards & Visualizations

convert pseudo XML file content to readable format

Rajshekhar
New Member

We have a file content in the format

</MSG>
<MSG _NO="3" _ID="15" _COMP="RunTime" _TEXT=" $PARAMETER$=$VALUE$">
 <MSG_ARGS
   _FILE="RTEConf_ParameterAccessKernelInterface+noPIC.cpp"
   _LINE="1141"
   _TIME="2011-11-11 19:01:41.000"
   _MESSAGEVERSION="1"
   PARAMETER="ADMIN"
   VALUE="1"

This is in pseudo XML format and we want this to be convereted to readable format. At OS level we execute the command spwdfvml0249:sqdixv 96> protconv /sapdb/data/wrk/IXV/KnlMsg > knldiag.txt_1511
to convert and read. How can we do this in splunk? is there any option to parse this data to readable format. Please help
Thanks|Rajshekhar

Tags (3)
0 Karma
1 Solution

Ayn
Legend

Splunk does not itself convert any data. OK, not completely true - there is some functionality for rewriting event data sed style, but nothing that parses an XML file and reformats the whole thing into a completely different format.

However from the sample event you pasted your XML seems well-suited enough to simply read into Splunk and create events for each <MSG> tag in the XML. After you've done that you can create field extractions for all the interesting fields in each msg and use the field values however you want to create an output for the events that's more human readable. Splunk will even automatically parse key=value definitions in the XML, so with most of these keys and values you won't have to create any field extractions yourself.

View solution in original post

0 Karma

Ayn
Legend

Splunk does not itself convert any data. OK, not completely true - there is some functionality for rewriting event data sed style, but nothing that parses an XML file and reformats the whole thing into a completely different format.

However from the sample event you pasted your XML seems well-suited enough to simply read into Splunk and create events for each <MSG> tag in the XML. After you've done that you can create field extractions for all the interesting fields in each msg and use the field values however you want to create an output for the events that's more human readable. Splunk will even automatically parse key=value definitions in the XML, so with most of these keys and values you won't have to create any field extractions yourself.

0 Karma

Rajshekhar
New Member

Thanks for your help 🙂

0 Karma

Ayn
Legend

I'm no Splunk employee so any help I provide is done on my spare time on this site. So, you're better off asking your questions here instead - if I have time and possibility to help you out I will, and if not, hopefully someone else will step in!

0 Karma

Rajshekhar
New Member

Yes I will definitely do that. Would you please provide your mailId to me so that in future if I need any help on Splunk it would be easy for me to communicate.

0 Karma

Ayn
Legend

Awesome! Could you please mark my answer as accepted? Thanks!

0 Karma

Rajshekhar
New Member

Thank you very much! Now I can see the output as desired

0 Karma

Ayn
Legend

COMP and TEXT, not _COMP and _TEXT. Splunk automatically removes the leading underscore characters.

0 Karma

Rajshekhar
New Member

I am giving below search string:
host="spwdfvml0249" index="erp_maxdb" source= "/sapdb/data/wrk/IXV/KnlMsg" | table _COMP,_TEXT

it says no matching fields exist and below that 97888 matching events and in detailed area it says No results found.. Please advice

0 Karma

Ayn
Legend

OK! In that case, just issue table with any fields you want in tabular form. For instance for getting _time, COMP and FILE:

... | table _time, COMP, FILE
0 Karma

Rajshekhar
New Member

Thank you so much for answering..
On the left hand side under other interesting fields if i select All 67 fields I can see COMP, FILE and other fields.

0 Karma

Ayn
Legend

OK, so you're seeing all these as fields in the field picker to the left in the search app? For instance is there a "_comp" field and a "_FILE" field?

0 Karma

Rajshekhar
New Member

I have configured splunk to index the XML file, and its displaying the results as below.


<MSG_ARGS
_FILE="RTEConf_ParameterAccessKernelInterface+noPIC.cpp"
_LINE="1141"
_TIME="2011-11-11 19:01:41.000"
_MESSAGEVERSION="1"
PARAMETER="ADMIN"
VALUE="1"
Please let me know how to divide the fields and show only those fields in tabular format

0 Karma

Ayn
Legend

How far have you come? Do you have the XML events loaded into Splunk and properly divided up?

0 Karma

Rajshekhar
New Member

I want extract few fields(for example, _TEXT, _COMP) and show only those fields in tabular format.
How can I do this. Please assist

0 Karma

sushildabare
Path Finder

Thanks for answering!
The requirement is when we extract few fields for example _ID,_TEXT from the above sample event, we want to display that in single line and other fields should not be shown at all. How can we achieve this.

0 Karma
Get Updates on the Splunk Community!

Introducing Splunk Enterprise 9.2

WATCH HERE! Watch this Tech Talk to learn about the latest features and enhancements shipped in the new Splunk ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...