<?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: Automatically extract xml key value pairs? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Is-there-away-to-have-Splunk-automatically-extract-XML-key-value/m-p/14154#M1450</link>
    <description>&lt;P&gt;try this:&lt;BR /&gt;&lt;BR /&gt;
LINE_BREAKER = ([\r\n]{2})&lt;/P&gt;</description>
    <pubDate>Tue, 06 Dec 2011 22:16:17 GMT</pubDate>
    <dc:creator>woodcock</dc:creator>
    <dc:date>2011-12-06T22:16:17Z</dc:date>
    <item>
      <title>Is there away to have Splunk automatically extract XML key value pairs?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-away-to-have-Splunk-automatically-extract-XML-key-value/m-p/14149#M1445</link>
      <description>&lt;P&gt;I'm using SPLUNK to index an xml file. Is there a way to have SPLUNK automatically extract the key-value pairs for each event (xmlkv) for every search. I don't want the user to have to type the | xmlkv in the search bar each time. I see in props.conf you can set the KV_MODE, but none of the settings indicate xml extraction.&lt;/P&gt;</description>
      <pubDate>Fri, 13 May 2022 16:47:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-away-to-have-Splunk-automatically-extract-XML-key-value/m-p/14149#M1445</guid>
      <dc:creator>lyndac</dc:creator>
      <dc:date>2022-05-13T16:47:12Z</dc:date>
    </item>
    <item>
      <title>Re: Automatically extract xml key value pairs?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-away-to-have-Splunk-automatically-extract-XML-key-value/m-p/14150#M1446</link>
      <description>&lt;P&gt;Edited for version 4.3:&lt;/P&gt;

&lt;P&gt;As for version 4.3, while the below accepted answer works, you can also use the props.conf setting:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;KV_MODE = xml
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;this performs &lt;CODE&gt;spath&lt;/CODE&gt;-type extraction on the events.&lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;Maybe. As it turns out, the &lt;CODE&gt;xmlkv&lt;/CODE&gt; command is not really a real XML extraction, it's just a regular regex that can be done by Splunk config probably better than the &lt;CODE&gt;xmlkv&lt;/CODE&gt; command itself. (See &lt;CODE&gt;$SPLUNK_HOME/etc/apps/search/bin/xmlkv.py&lt;/CODE&gt;.)&lt;/P&gt;

&lt;P&gt;Just define a search-time extraction for your sourcetype (or source or whatever) in &lt;CODE&gt;props.conf&lt;/CODE&gt;:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[mysourcetype]
REPORT-xmlkv = xmlkv-alternative
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and in &lt;CODE&gt;transforms.conf&lt;/CODE&gt;:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[xmlkv-alternative]
REGEX = &amp;lt;([^\s\&amp;gt;]*)[^\&amp;gt;]*\&amp;gt;([^&amp;lt;]*)\&amp;lt;\/\1\&amp;gt;
FORMAT = $1::$2
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 25 May 2010 20:02:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-away-to-have-Splunk-automatically-extract-XML-key-value/m-p/14150#M1446</guid>
      <dc:creator>gkanapathy</dc:creator>
      <dc:date>2010-05-25T20:02:29Z</dc:date>
    </item>
    <item>
      <title>Re: Automatically extract xml key value pairs?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-away-to-have-Splunk-automatically-extract-XML-key-value/m-p/14151#M1447</link>
      <description>&lt;P&gt;Nice trick.  You could also add &lt;CODE&gt;MV_ADD = True&lt;/CODE&gt; to your &lt;CODE&gt;xmlkv-alternative&lt;/CODE&gt; stanza if you want to capture repeating XML elements as a multi-value field, for example if your XML represents a list of items.  This is something that you can't do with the default &lt;CODE&gt;xmlkv&lt;/CODE&gt; command.  Pretty cool.&lt;/P&gt;</description>
      <pubDate>Tue, 25 May 2010 20:48:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-away-to-have-Splunk-automatically-extract-XML-key-value/m-p/14151#M1447</guid>
      <dc:creator>Lowell</dc:creator>
      <dc:date>2010-05-25T20:48:43Z</dc:date>
    </item>
    <item>
      <title>Re: Automatically extract xml key value pairs?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-away-to-have-Splunk-automatically-extract-XML-key-value/m-p/14152#M1448</link>
      <description>&lt;P&gt;Worked perfectly!  Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 26 May 2010 02:52:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-away-to-have-Splunk-automatically-extract-XML-key-value/m-p/14152#M1448</guid>
      <dc:creator>lyndac</dc:creator>
      <dc:date>2010-05-26T02:52:37Z</dc:date>
    </item>
    <item>
      <title>Re: Automatically extract xml key value pairs?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-away-to-have-Splunk-automatically-extract-XML-key-value/m-p/14153#M1449</link>
      <description>&lt;P&gt;hey gkanapathy &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;I used your mad skillz regex in my transforms.conf but it negates the line breaker in my props.conf &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;Any ideas on how to ensure the line breaker still works in this example?&lt;/P&gt;

&lt;P&gt;props.conf:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[nagiosstatus]
MAX_EVENTS = 500000
TIME_PREFIX = \&amp;lt;created\&amp;gt;
MAX_TIMESTAMP_LOOKAHEAD = 500
SHOULD_LINEMERGE = false
LINE_BREAKER = (\n\n)
REPORT-xmlkv = xmlkv-alternative
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;transforms.conf:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[xmlkv-alternative]
REGEX = &amp;lt;([^\s\&amp;gt;]*)[^\&amp;gt;]*\&amp;gt;([^&amp;lt;]*)\&amp;lt;\/\1\&amp;gt;
FORMAT = $1::$2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;sample xml log:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;nagios&amp;gt;

&amp;lt;info&amp;gt;
    &amp;lt;created&amp;gt;1299121157&amp;lt;/created&amp;gt;
    &amp;lt;version&amp;gt;3.2.1&amp;lt;/version&amp;gt;
    &amp;lt;last_update_check&amp;gt;1299108670&amp;lt;/last_update_check&amp;gt;
    &amp;lt;update_available&amp;gt;1&amp;lt;/update_available&amp;gt;
    &amp;lt;last_version&amp;gt;3.2.1&amp;lt;/last_version&amp;gt;
    &amp;lt;new_version&amp;gt;3.2.3&amp;lt;/new_version&amp;gt;
&amp;lt;/info&amp;gt;

&amp;lt;programstatus&amp;gt;
    &amp;lt;modified_host_attributes&amp;gt;1&amp;lt;/modified_host_attributes&amp;gt;
    &amp;lt;modified_service_attributes&amp;gt;1&amp;lt;/modified_service_attributes&amp;gt;
    &amp;lt;nagios_pid&amp;gt;15961&amp;lt;/nagios_pid&amp;gt;
    &amp;lt;daemon_mode&amp;gt;1&amp;lt;/daemon_mode&amp;gt;
    &amp;lt;program_start&amp;gt;1299103468&amp;lt;/program_start&amp;gt;
    &amp;lt;last_command_check&amp;gt;1299121108&amp;lt;/last_command_check&amp;gt;
    &amp;lt;last_log_rotation&amp;gt;0&amp;lt;/last_log_rotation&amp;gt;
    &amp;lt;enable_notifications&amp;gt;1&amp;lt;/enable_notifications&amp;gt;
    &amp;lt;active_service_checks_enabled&amp;gt;1&amp;lt;/active_service_checks_enabled&amp;gt;
    &amp;lt;passive_service_checks_enabled&amp;gt;1&amp;lt;/passive_service_checks_enabled&amp;gt;
    &amp;lt;active_host_checks_enabled&amp;gt;1&amp;lt;/active_host_checks_enabled&amp;gt;
    &amp;lt;passive_host_checks_enabled&amp;gt;1&amp;lt;/passive_host_checks_enabled&amp;gt;
    &amp;lt;enable_event_handlers&amp;gt;1&amp;lt;/enable_event_handlers&amp;gt;
    &amp;lt;obsess_over_services&amp;gt;0&amp;lt;/obsess_over_services&amp;gt;
    &amp;lt;obsess_over_hosts&amp;gt;0&amp;lt;/obsess_over_hosts&amp;gt;
    &amp;lt;check_service_freshness&amp;gt;1&amp;lt;/check_service_freshness&amp;gt;
    &amp;lt;check_host_freshness&amp;gt;0&amp;lt;/check_host_freshness&amp;gt;
    &amp;lt;enable_flap_detection&amp;gt;0&amp;lt;/enable_flap_detection&amp;gt;
    &amp;lt;enable_failure_prediction&amp;gt;1&amp;lt;/enable_failure_prediction&amp;gt;
    &amp;lt;process_performance_data&amp;gt;1&amp;lt;/process_performance_data&amp;gt;
    &amp;lt;global_host_event_handler&amp;gt;&amp;lt;/global_host_event_handler&amp;gt;
    &amp;lt;global_service_event_handler&amp;gt;&amp;lt;/global_service_event_handler&amp;gt;
    &amp;lt;next_comment_id&amp;gt;94586&amp;lt;/next_comment_id&amp;gt;
    &amp;lt;next_downtime_id&amp;gt;35813&amp;lt;/next_downtime_id&amp;gt;
    &amp;lt;next_event_id&amp;gt;1185528&amp;lt;/next_event_id&amp;gt;
    &amp;lt;next_problem_id&amp;gt;532761&amp;lt;/next_problem_id&amp;gt;
    &amp;lt;next_notification_id&amp;gt;1337020&amp;lt;/next_notification_id&amp;gt;
    &amp;lt;total_external_command_buffer_slots&amp;gt;4096&amp;lt;/total_external_command_buffer_slots&amp;gt;
    &amp;lt;used_external_command_buffer_slots&amp;gt;11&amp;lt;/used_external_command_buffer_slots&amp;gt;
    &amp;lt;high_external_command_buffer_slots&amp;gt;128&amp;lt;/high_external_command_buffer_slots&amp;gt;
    &amp;lt;active_scheduled_host_check_stats&amp;gt;21,132,401&amp;lt;/active_scheduled_host_check_stats&amp;gt;
    &amp;lt;active_ondemand_host_check_stats&amp;gt;33,278,834&amp;lt;/active_ondemand_host_check_stats&amp;gt;
    &amp;lt;passive_host_check_stats&amp;gt;0,0,0&amp;lt;/passive_host_check_stats&amp;gt;
&amp;lt;/programstatus&amp;gt;

&amp;lt;/nagios&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks in advance,&lt;/P&gt;

&lt;P&gt;Luke &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Mar 2011 07:29:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-away-to-have-Splunk-automatically-extract-XML-key-value/m-p/14153#M1449</guid>
      <dc:creator>lukeh</dc:creator>
      <dc:date>2011-03-04T07:29:55Z</dc:date>
    </item>
    <item>
      <title>Re: Automatically extract xml key value pairs?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-away-to-have-Splunk-automatically-extract-XML-key-value/m-p/14154#M1450</link>
      <description>&lt;P&gt;try this:&lt;BR /&gt;&lt;BR /&gt;
LINE_BREAKER = ([\r\n]{2})&lt;/P&gt;</description>
      <pubDate>Tue, 06 Dec 2011 22:16:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-away-to-have-Splunk-automatically-extract-XML-key-value/m-p/14154#M1450</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2011-12-06T22:16:17Z</dc:date>
    </item>
    <item>
      <title>Re: Automatically extract xml key value pairs?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-away-to-have-Splunk-automatically-extract-XML-key-value/m-p/14155#M1451</link>
      <description>&lt;P&gt;Very Nice &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Aug 2012 14:07:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-away-to-have-Splunk-automatically-extract-XML-key-value/m-p/14155#M1451</guid>
      <dc:creator>jangid</dc:creator>
      <dc:date>2012-08-06T14:07:23Z</dc:date>
    </item>
    <item>
      <title>Re: Automatically extract xml key value pairs?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-away-to-have-Splunk-automatically-extract-XML-key-value/m-p/14156#M1452</link>
      <description>&lt;P&gt;As of version 4.3, you can now use the setting in props.conf:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;KV_MODE = xml
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;which will perform &lt;CODE&gt;spath&lt;/CODE&gt; extraction.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Aug 2012 15:04:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-away-to-have-Splunk-automatically-extract-XML-key-value/m-p/14156#M1452</guid>
      <dc:creator>gkanapathy</dc:creator>
      <dc:date>2012-08-06T15:04:32Z</dc:date>
    </item>
    <item>
      <title>Re: Automatically extract xml key value pairs?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-away-to-have-Splunk-automatically-extract-XML-key-value/m-p/597808#M208169</link>
      <description>&lt;P&gt;This answer is still helpful 12 years later.&amp;nbsp; Thanks,&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/45"&gt;@gkanapathy&lt;/a&gt;&amp;nbsp;!&lt;/P&gt;</description>
      <pubDate>Fri, 13 May 2022 16:41:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-away-to-have-Splunk-automatically-extract-XML-key-value/m-p/597808#M208169</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2022-05-13T16:41:24Z</dc:date>
    </item>
  </channel>
</rss>

