<?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: How to extract fields from XML data at search-time? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-fields-from-XML-data-at-search-time/m-p/120563#M32419</link>
    <description>&lt;P&gt;I did try field extraction (as in 6.2) but then it is not accurate. The regex I write dont work on the data I have. &lt;/P&gt;</description>
    <pubDate>Thu, 13 Nov 2014 09:46:27 GMT</pubDate>
    <dc:creator>yostwal_synechr</dc:creator>
    <dc:date>2014-11-13T09:46:27Z</dc:date>
    <item>
      <title>How to extract fields from XML data at search-time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-fields-from-XML-data-at-search-time/m-p/120556#M32412</link>
      <description>&lt;P&gt;I have a .log file that I need to analyse using Splunk. The structure of the log data is as below&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;root&amp;gt;
    &amp;lt;ns0:LogMessage xmlns:ns0="http://some_namespace.com/schemas/logmessage/3.1.2"&amp;gt;
        &amp;lt;ns0:Fields&amp;gt;
            &amp;lt;ns0:Field&amp;gt;
                &amp;lt;ns0:name&amp;gt;Action&amp;lt;/ns0:name&amp;gt;
                &amp;lt;ns0:value&amp;gt;Start&amp;lt;/ns0:value&amp;gt;
            &amp;lt;/ns0:Field&amp;gt;
            &amp;lt;ns0:Field&amp;gt;
                &amp;lt;ns0:name&amp;gt;MessageTypeName&amp;lt;/ns0:name&amp;gt;
                &amp;lt;ns0:value&amp;gt;Logging request for ABC service&amp;lt;/ns0:value&amp;gt;
            &amp;lt;/ns0:Field&amp;gt;
            &amp;lt;ns0:Field&amp;gt;
                &amp;lt;ns0:name&amp;gt;CreatedBy&amp;lt;/ns0:name&amp;gt;
                &amp;lt;ns0:value&amp;gt;domain/user.name&amp;lt;/ns0:value&amp;gt;
            &amp;lt;/ns0:Field&amp;gt;
            .
            .
            .
            .
            &amp;lt;ns0:Field&amp;gt;
                &amp;lt;ns0:name&amp;gt;MessageID&amp;lt;/ns0:name&amp;gt;
                &amp;lt;ns0:value&amp;gt;1234&amp;lt;/ns0:value&amp;gt;
            &amp;lt;/ns0:Field&amp;gt;
        &amp;lt;/ns0:Fields&amp;gt;
    &amp;lt;/ns0:LogMessage&amp;gt;
&amp;lt;/root&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I want to extract the fields like Action and use them during my searches. Is there a why that I can search something like &lt;CODE&gt;Action=Start MessageID=1234&lt;/CODE&gt; ?&lt;/P&gt;

&lt;P&gt;If yes, how can I achieve that? I went through other questions posted here related to XML, but I couldn't find something similar to the scenario that I have,&lt;/P&gt;</description>
      <pubDate>Tue, 11 Nov 2014 09:41:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-fields-from-XML-data-at-search-time/m-p/120556#M32412</guid>
      <dc:creator>yostwal_synechr</dc:creator>
      <dc:date>2014-11-11T09:41:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract fields from XML data at search-time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-fields-from-XML-data-at-search-time/m-p/120557#M32413</link>
      <description>&lt;P&gt;Have you tried using the &lt;CODE&gt;xpath&lt;/CODE&gt; &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.2.0/SearchReference/xpath"&gt;command&lt;/A&gt;?&lt;/P&gt;</description>
      <pubDate>Tue, 11 Nov 2014 16:44:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-fields-from-XML-data-at-search-time/m-p/120557#M32413</guid>
      <dc:creator>aljohnson_splun</dc:creator>
      <dc:date>2014-11-11T16:44:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract fields from XML data at search-time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-fields-from-XML-data-at-search-time/m-p/120558#M32414</link>
      <description>&lt;P&gt;Have you tried using the &lt;CODE&gt;xmlkv&lt;/CODE&gt; &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Xmlkv"&gt;command&lt;/A&gt;?&lt;/P&gt;</description>
      <pubDate>Tue, 11 Nov 2014 20:54:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-fields-from-XML-data-at-search-time/m-p/120558#M32414</guid>
      <dc:creator>aljohnson_splun</dc:creator>
      <dc:date>2014-11-11T20:54:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract fields from XML data at search-time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-fields-from-XML-data-at-search-time/m-p/120559#M32415</link>
      <description>&lt;P&gt;I also have similar requirement, I have lot of xml webservice responses in logs. So for example lets say we have above xml in log, and first I want to search all those log stmts that has Logging request for ABC service  and then I want to have all those xmls that matching that will key value of fields of xml , so I can perform other search based on that.&lt;/P&gt;

&lt;P&gt;spath ? xmlkv  ? xpath ?&lt;/P&gt;</description>
      <pubDate>Tue, 11 Nov 2014 22:46:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-fields-from-XML-data-at-search-time/m-p/120559#M32415</guid>
      <dc:creator>patelmiral</dc:creator>
      <dc:date>2014-11-11T22:46:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract fields from XML data at search-time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-fields-from-XML-data-at-search-time/m-p/120560#M32416</link>
      <description>&lt;P&gt;Yes I did. I tried both &lt;CODE&gt;xpath&lt;/CODE&gt; and &lt;CODE&gt;spath&lt;/CODE&gt;. But I am not getting the results as desired. &lt;/P&gt;

&lt;P&gt;To give you an example of what I want, I want to look at events where the element &lt;CODE&gt;ns0:name&lt;/CODE&gt; is Action and &lt;CODE&gt;ns0:value&lt;/CODE&gt; is Start&lt;/P&gt;

&lt;P&gt;I tried the following: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=AppLogs.log | xpath outfield=Action "//root/ns0:LogMessage/ns0:Fields/ns0:Field[ns0:name=\"Action\" AND ns0:value=\"Start\"]"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This just returns all the events.&lt;/P&gt;

&lt;P&gt;What I am doing, is that correct? Please correct me if not. &lt;/P&gt;</description>
      <pubDate>Wed, 12 Nov 2014 07:59:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-fields-from-XML-data-at-search-time/m-p/120560#M32416</guid>
      <dc:creator>yostwal_synechr</dc:creator>
      <dc:date>2014-11-12T07:59:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract fields from XML data at search-time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-fields-from-XML-data-at-search-time/m-p/120561#M32417</link>
      <description>&lt;P&gt;You could use the &lt;STRONG&gt;Interactive Field Extractor&lt;/STRONG&gt; to do this&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;Go to the event&lt;/LI&gt;
&lt;LI&gt;Click "Event Actions"&lt;/LI&gt;
&lt;LI&gt;Click  "Extract Fields"&lt;/LI&gt;
&lt;LI&gt;Copy examples of the fields you want from your data into the examples box, like multiple actions or message ids. &lt;/LI&gt;
&lt;LI&gt;Test generated regex, edit as needed. &lt;/LI&gt;
&lt;LI&gt;Save as field extraction&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;See this &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.1.5/Knowledge/ExtractfieldsinteractivelywithIFX"&gt;guide&lt;/A&gt;  (for 6.1). &lt;/P&gt;

&lt;P&gt;Note this process becomes &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.2.0/Knowledge/ExtractfieldsinteractivelywithIFX"&gt;significantly easier in 6.2.&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Nov 2014 00:39:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-fields-from-XML-data-at-search-time/m-p/120561#M32417</guid>
      <dc:creator>aljohnson_splun</dc:creator>
      <dc:date>2014-11-13T00:39:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract fields from XML data at search-time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-fields-from-XML-data-at-search-time/m-p/120562#M32418</link>
      <description>&lt;P&gt;patelmiral, you should ask a separate question, post more data, desired output, attempted searches, etc. and it will be easier for someone to help you with your question.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Nov 2014 00:40:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-fields-from-XML-data-at-search-time/m-p/120562#M32418</guid>
      <dc:creator>aljohnson_splun</dc:creator>
      <dc:date>2014-11-13T00:40:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract fields from XML data at search-time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-fields-from-XML-data-at-search-time/m-p/120563#M32419</link>
      <description>&lt;P&gt;I did try field extraction (as in 6.2) but then it is not accurate. The regex I write dont work on the data I have. &lt;/P&gt;</description>
      <pubDate>Thu, 13 Nov 2014 09:46:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-fields-from-XML-data-at-search-time/m-p/120563#M32419</guid>
      <dc:creator>yostwal_synechr</dc:creator>
      <dc:date>2014-11-13T09:46:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract fields from XML data at search-time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-fields-from-XML-data-at-search-time/m-p/120564#M32420</link>
      <description>&lt;P&gt;What you need to do then, is edit the regex that is generated so that it &lt;EM&gt;does&lt;/EM&gt; work on the data you have.&lt;/P&gt;

&lt;P&gt;&lt;A href="http://i.imgur.com/YIQUSN9.png"&gt;Example image&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;You can also use the "require" as well as the "extract" in 6.2 field extraction.&lt;/P&gt;

&lt;P&gt;If neither of these work, look into using the configuration files for search-time field extractions: &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.2.0/Knowledge/Createandmaintainsearch-timefieldextractionsthroughconfigurationfiles"&gt;Create and maintain search-time field extractions through configuration files&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Nov 2014 16:58:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-fields-from-XML-data-at-search-time/m-p/120564#M32420</guid>
      <dc:creator>aljohnson_splun</dc:creator>
      <dc:date>2014-11-13T16:58:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract fields from XML data at search-time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-fields-from-XML-data-at-search-time/m-p/120565#M32421</link>
      <description>&lt;P&gt;Hi aljohnson_splunk,&lt;/P&gt;

&lt;P&gt;Further to this, I also tried extraction using props.conf and transforms.conf as below:&lt;/P&gt;

&lt;P&gt;In props.conf, I added the following statement under &lt;CODE&gt;[default]&lt;/CODE&gt; (as I want this extraction for all the sources and sourcetypes):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;REPORT-Action=Action
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And, in transforms.conf I added the following statements:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[Action]
REGEX = ?&amp;lt;root&amp;gt;.?&amp;lt;ns0:LogMessage\s.&amp;gt;.?&amp;lt;ns0:Fields&amp;gt;.+&amp;lt;ns0:Field&amp;gt;.+&amp;lt;ns0:name&amp;gt;(Action)&amp;lt;/ns0:name&amp;gt;.+&amp;lt;ns0:value&amp;gt;([^&amp;lt;]+)&amp;lt;/ns0:value&amp;gt;.+
FORMAT = Action::$1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Am I doing something wrong here? I have a doubt on my regex. Please refer the example of the logs above.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Nov 2014 10:43:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-fields-from-XML-data-at-search-time/m-p/120565#M32421</guid>
      <dc:creator>yostwal_synechr</dc:creator>
      <dc:date>2014-11-18T10:43:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract fields from XML data at search-time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-fields-from-XML-data-at-search-time/m-p/120566#M32422</link>
      <description>&lt;P&gt;I like this solution using transforms.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[views_std]
MV_ADD = 1
REGEX = \&amp;lt;(\w+[^\n\/\&amp;gt;]+)\/?\&amp;gt;([^\&amp;lt;\n][^\&amp;lt;]*)\&amp;lt;
FORMAT = $1::$2
CLEAN_KEYS = true

[views_param]
MV_ADD = 1
REGEX = \&amp;lt;(\w+ [^\n\/\&amp;gt;]+)\/?\&amp;gt;
FORMAT = param::$1
CLEAN_KEYS = true

[views_option]
MV_ADD = 1
SOURCE_KEY = param
REGEX = (\w+(?: \w+)*)="(?!host|source|sourcetype|index|splunk_server)(\w+)"
FORMAT = $1::$2
CLEAN_KEYS = true
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 05 Oct 2016 13:45:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-fields-from-XML-data-at-search-time/m-p/120566#M32422</guid>
      <dc:creator>landen99</dc:creator>
      <dc:date>2016-10-05T13:45:43Z</dc:date>
    </item>
  </channel>
</rss>

