<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: xml input in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/xml-input/m-p/92921#M5054</link>
    <description>&lt;P&gt;First, if you want to pull the data into Splunk, you can treat an XML file like any other text file. However, you will probably want to tell Splunk that this is a file that contains multi-line events, and how to identify the break between events.  This is a pretty good answer that describes how to set up an XML input: &lt;A href="http://splunk-base.splunk.com/answers/2141/xml-log-source-type"&gt;XML Log Sourcetype&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Splunk does not automatically parse XML data. In fact, you often don't need to parse in order to search. You can search for all events where the pqr id is 1 simply by putting&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;pqr id="1"&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;in the search box and specifying a time range. Once you have searched for the events that you want to report, you can ask Splunk to do "field extraction" on the events using the &lt;CODE&gt;xmlkv&lt;/CODE&gt; command. The kv stands for "key-value" and that is what Splunk does - it sets up fields based on the XML tags and values. You can see the fields if you just do this:&lt;/P&gt;

&lt;P&gt;yoursearchhere | xmlkv &lt;/P&gt;

&lt;P&gt;You can see the fields that Splunk extracted from your xml in the fields sidebar. Use them however you want, perhaps with a &lt;CODE&gt;table&lt;/CODE&gt; command.&lt;/P&gt;

&lt;P&gt;There is also an &lt;CODE&gt;spath&lt;/CODE&gt; command, which has a couple of examples in the manual &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Spath"&gt;here&lt;/A&gt;. &lt;CODE&gt;spath&lt;/CODE&gt; might be more useful in this case.&lt;/P&gt;

&lt;P&gt;ADDENDUM: Just found this... There is a way to tell Splunk to automatically create fields for XML data. Edit the appropriate props.conf and add&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[yoursourcetypehere]
KV_MODE=xml
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If you read the &lt;A href="http://splunk-base.splunk.com/answers/2141/xml-log-source-type"&gt;XML Log Sourcetype&lt;/A&gt; answer, you could put the &lt;CODE&gt;KV_MODE=xml&lt;/CODE&gt; right after the line &lt;CODE&gt;SHOULD_LINEMERGE = True&lt;/CODE&gt;&lt;BR /&gt;&lt;BR /&gt;
If you do this, you don't need the &lt;CODE&gt;xmlkv&lt;/CODE&gt; command at all...&lt;/P&gt;</description>
    <pubDate>Sat, 07 Jul 2012 01:45:09 GMT</pubDate>
    <dc:creator>lguinn2</dc:creator>
    <dc:date>2012-07-07T01:45:09Z</dc:date>
    <item>
      <title>xml input</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/xml-input/m-p/92920#M5053</link>
      <description>&lt;P&gt;how do i setup xml input like:&lt;BR /&gt;
&lt;ABC&gt;&lt;BR /&gt;
   &lt;PQR id="1"&gt;&lt;BR /&gt;
      &lt;XYZ&gt;&lt;BR /&gt;
        &lt;AA&gt;12&lt;/AA&gt;&lt;BR /&gt;
        &lt;BB&gt;34&lt;/BB&gt;&lt;BR /&gt;
      &lt;/XYZ&gt;&lt;BR /&gt;
      &lt;XYZ&gt;&lt;BR /&gt;
        &lt;AA&gt;0&lt;/AA&gt;&lt;BR /&gt;
        &lt;BB&gt;99&lt;/BB&gt;&lt;BR /&gt;
      &lt;/XYZ&gt;&lt;BR /&gt;
   &lt;/PQR&gt;&lt;BR /&gt;
   &lt;PQR id="2"&gt;&lt;BR /&gt;
      &lt;XYZ&gt;&lt;BR /&gt;
        &lt;AA&gt;4&lt;/AA&gt;&lt;BR /&gt;
        &lt;BB&gt;1&lt;/BB&gt;&lt;BR /&gt;
      &lt;/XYZ&gt;&lt;BR /&gt;
   &lt;/PQR&gt;&lt;BR /&gt;
&lt;/ABC&gt;&lt;/P&gt;

&lt;P&gt;Want to create a report of this form:&lt;BR /&gt;
pqr:1&lt;BR /&gt;
aa:12 bb:34&lt;BR /&gt;
aa:0 bb:99&lt;BR /&gt;
pqr:2&lt;BR /&gt;
aa:4 bb:1&lt;/P&gt;

&lt;P&gt;Have been searching around, but very new to Splunk and seems i couldn't find many pointers to follow.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jul 2012 18:04:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/xml-input/m-p/92920#M5053</guid>
      <dc:creator>daxaatfss</dc:creator>
      <dc:date>2012-07-06T18:04:58Z</dc:date>
    </item>
    <item>
      <title>Re: xml input</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/xml-input/m-p/92921#M5054</link>
      <description>&lt;P&gt;First, if you want to pull the data into Splunk, you can treat an XML file like any other text file. However, you will probably want to tell Splunk that this is a file that contains multi-line events, and how to identify the break between events.  This is a pretty good answer that describes how to set up an XML input: &lt;A href="http://splunk-base.splunk.com/answers/2141/xml-log-source-type"&gt;XML Log Sourcetype&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Splunk does not automatically parse XML data. In fact, you often don't need to parse in order to search. You can search for all events where the pqr id is 1 simply by putting&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;pqr id="1"&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;in the search box and specifying a time range. Once you have searched for the events that you want to report, you can ask Splunk to do "field extraction" on the events using the &lt;CODE&gt;xmlkv&lt;/CODE&gt; command. The kv stands for "key-value" and that is what Splunk does - it sets up fields based on the XML tags and values. You can see the fields if you just do this:&lt;/P&gt;

&lt;P&gt;yoursearchhere | xmlkv &lt;/P&gt;

&lt;P&gt;You can see the fields that Splunk extracted from your xml in the fields sidebar. Use them however you want, perhaps with a &lt;CODE&gt;table&lt;/CODE&gt; command.&lt;/P&gt;

&lt;P&gt;There is also an &lt;CODE&gt;spath&lt;/CODE&gt; command, which has a couple of examples in the manual &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Spath"&gt;here&lt;/A&gt;. &lt;CODE&gt;spath&lt;/CODE&gt; might be more useful in this case.&lt;/P&gt;

&lt;P&gt;ADDENDUM: Just found this... There is a way to tell Splunk to automatically create fields for XML data. Edit the appropriate props.conf and add&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[yoursourcetypehere]
KV_MODE=xml
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If you read the &lt;A href="http://splunk-base.splunk.com/answers/2141/xml-log-source-type"&gt;XML Log Sourcetype&lt;/A&gt; answer, you could put the &lt;CODE&gt;KV_MODE=xml&lt;/CODE&gt; right after the line &lt;CODE&gt;SHOULD_LINEMERGE = True&lt;/CODE&gt;&lt;BR /&gt;&lt;BR /&gt;
If you do this, you don't need the &lt;CODE&gt;xmlkv&lt;/CODE&gt; command at all...&lt;/P&gt;</description>
      <pubDate>Sat, 07 Jul 2012 01:45:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/xml-input/m-p/92921#M5054</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2012-07-07T01:45:09Z</dc:date>
    </item>
    <item>
      <title>Re: xml input</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/xml-input/m-p/92922#M5055</link>
      <description>&lt;P&gt;That works, thank you!&lt;BR /&gt;
Now i have another problem where i want '&lt;AA&gt;' and '&lt;BB&gt;' field values to be grouped together by '&lt;PQR&gt;'. For example,&lt;BR /&gt;
spath path=abc.pqr{*} gives me something like&lt;BR /&gt;
1    12(aa)&lt;BR /&gt;
2    34(bb)&lt;BR /&gt;
     0(aa)&lt;BR /&gt;
     99(bb)&lt;BR /&gt;
     4(aa)&lt;BR /&gt;
     1(bb)&lt;/PQR&gt;&lt;/BB&gt;&lt;/AA&gt;&lt;/P&gt;

&lt;P&gt;But i want output like:&lt;BR /&gt;
1    12(aa)&lt;BR /&gt;
     34(bb)&lt;BR /&gt;
     0(aa)&lt;BR /&gt;
     99(bb)&lt;BR /&gt;
2    4(aa)&lt;BR /&gt;
     1(bb)&lt;/P&gt;</description>
      <pubDate>Mon, 09 Jul 2012 16:37:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/xml-input/m-p/92922#M5055</guid>
      <dc:creator>daxaatfss</dc:creator>
      <dc:date>2012-07-09T16:37:44Z</dc:date>
    </item>
  </channel>
</rss>

