<?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 from a value from XML and include it in the search? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-from-a-value-from-XML-and-include-it-in-the/m-p/230854#M68468</link>
    <description>&lt;P&gt;your base search | fields employee.id&lt;/P&gt;</description>
    <pubDate>Thu, 18 Aug 2016 06:32:15 GMT</pubDate>
    <dc:creator>pasokkum</dc:creator>
    <dc:date>2016-08-18T06:32:15Z</dc:date>
    <item>
      <title>How to extract from a value from XML and include it in the search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-from-a-value-from-XML-and-include-it-in-the/m-p/230846#M68460</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I would like to extract the XML field value from an XML string from the log and include it in the search. What is the best way to do that?&lt;/P&gt;

&lt;P&gt;Currently, whenever a request is posted, I am searching with the id, but I want to create a dynamic search such that whenever a new employee is added, I can see it in the Splunk search.&lt;/P&gt;

&lt;P&gt;I tried the field extractor regex &lt;CODE&gt;(^(?:[^&amp;gt;\n]*&amp;gt;){4}(?P\w+))&lt;/CODE&gt;, but not sure how I can use this regex in the search box.&lt;/P&gt;

&lt;P&gt;Sample XML: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;employee&amp;gt;
    &amp;lt;id&amp;gt;TEST001&amp;lt;/id&amp;gt;
&amp;lt;/employee&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 16 Aug 2016 19:33:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-from-a-value-from-XML-and-include-it-in-the/m-p/230846#M68460</guid>
      <dc:creator>friscos</dc:creator>
      <dc:date>2016-08-16T19:33:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract from a value from XML and include it in the search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-from-a-value-from-XML-and-include-it-in-the/m-p/230847#M68461</link>
      <description>&lt;P&gt;You could do like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search | rex "(^(?:[^&amp;gt;\n]*&amp;gt;){4}(?P&amp;lt;employeeId&amp;gt;\w+))"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;OR&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search | rex "\&amp;lt;id\&amp;gt;(?P&amp;lt;EmployeeId&amp;gt;[^\&amp;lt;]+)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You can also save this regex in props.conf/field extraction to extract this automatically.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Aug 2016 19:54:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-from-a-value-from-XML-and-include-it-in-the/m-p/230847#M68461</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-08-16T19:54:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract from a value from XML and include it in the search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-from-a-value-from-XML-and-include-it-in-the/m-p/230848#M68462</link>
      <description>&lt;P&gt;Thanks Somesoni for your response.&lt;/P&gt;

&lt;P&gt;my base search is this:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;host="myserverhostname"  rex "(^(?:[^&amp;gt;\n]*&amp;gt;){4}(?P&amp;lt;employee&amp;gt;\w+))"&lt;/CODE&gt;  - This returns 'no results found'&lt;/P&gt;

&lt;P&gt;I want to search for  TEST001 in all the log files, how do i dynamically pass TEST001 in the search box?&lt;/P&gt;

&lt;P&gt;I also tried this: &lt;CODE&gt;host="myserverhostname"  rex "\&amp;lt;id\&amp;gt;(?P&amp;lt;employee&amp;gt;[^\&amp;lt;]+)"&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;If i search with &lt;CODE&gt;host="myserverhostname" |  rex "(^(?:[^&amp;gt;\n]*&amp;gt;){4}(?P&amp;lt;employee&amp;gt;\w+))"&lt;/CODE&gt; , this returns all the logging and doesn't filter by id.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Aug 2016 20:29:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-from-a-value-from-XML-and-include-it-in-the/m-p/230848#M68462</guid>
      <dc:creator>friscos</dc:creator>
      <dc:date>2016-08-16T20:29:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract from a value from XML and include it in the search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-from-a-value-from-XML-and-include-it-in-the/m-p/230849#M68463</link>
      <description>&lt;P&gt;The above regex is only for extracting the id from the raw xml into a field. To filter the data using your filter TEST001, you can try any of these method&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host="myserverhostname" "TEST001"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;OR&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host="myserverhostname" | regex _raw=".*\&amp;lt;id\&amp;gt;TEST001.*"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 16 Aug 2016 20:48:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-from-a-value-from-XML-and-include-it-in-the/m-p/230849#M68463</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-08-16T20:48:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract from a value from XML and include it in the search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-from-a-value-from-XML-and-include-it-in-the/m-p/230850#M68464</link>
      <description>&lt;P&gt;So, there is no way to extract the value of id and include it in the search field? &lt;/P&gt;

&lt;P&gt;I do not want to put TEST001 in the search as the value changes every time a new id is created. I want to monitor the logs based on the value of id that gets created and written to the log.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Aug 2016 13:29:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-from-a-value-from-XML-and-include-it-in-the/m-p/230850#M68464</guid>
      <dc:creator>friscos</dc:creator>
      <dc:date>2016-08-17T13:29:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract from a value from XML and include it in the search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-from-a-value-from-XML-and-include-it-in-the/m-p/230851#M68465</link>
      <description>&lt;P&gt;Create props.conf in $SplunkHome$/etc/system/local of both search head and indexer with the following stanza&lt;BR /&gt;
[sourcetype]&lt;BR /&gt;
KV_MODE=xml&lt;BR /&gt;
After making the changes restart search heads and indexers&lt;/P&gt;</description>
      <pubDate>Wed, 17 Aug 2016 13:57:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-from-a-value-from-XML-and-include-it-in-the/m-p/230851#M68465</guid>
      <dc:creator>pasokkum</dc:creator>
      <dc:date>2016-08-17T13:57:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract from a value from XML and include it in the search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-from-a-value-from-XML-and-include-it-in-the/m-p/230852#M68466</link>
      <description>&lt;P&gt;I added KV_MODE=xml in the prop.xml and restarted the server. &lt;/P&gt;

&lt;P&gt;How do i now extract the of value of an xml from log file and include it in the search?&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 17 Aug 2016 18:09:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-from-a-value-from-XML-and-include-it-in-the/m-p/230852#M68466</guid>
      <dc:creator>friscos</dc:creator>
      <dc:date>2016-08-17T18:09:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract from a value from XML and include it in the search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-from-a-value-from-XML-and-include-it-in-the/m-p/230853#M68467</link>
      <description>&lt;P&gt;Give this a shot&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host="myserverhostname" [ search host="myserverhostname" | rex "(^(?:[^&amp;gt;\n]*&amp;gt;){4}(?P&amp;lt;employee&amp;gt;\w+))" | stats count by employee | table employee | rename employee as search ] 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 17 Aug 2016 18:26:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-from-a-value-from-XML-and-include-it-in-the/m-p/230853#M68467</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-08-17T18:26:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract from a value from XML and include it in the search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-from-a-value-from-XML-and-include-it-in-the/m-p/230854#M68468</link>
      <description>&lt;P&gt;your base search | fields employee.id&lt;/P&gt;</description>
      <pubDate>Thu, 18 Aug 2016 06:32:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-from-a-value-from-XML-and-include-it-in-the/m-p/230854#M68468</guid>
      <dc:creator>pasokkum</dc:creator>
      <dc:date>2016-08-18T06:32:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract from a value from XML and include it in the search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-from-a-value-from-XML-and-include-it-in-the/m-p/230855#M68469</link>
      <description>&lt;P&gt;no luck..doesn't fetch anything. thanks for your time.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Aug 2016 18:07:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-from-a-value-from-XML-and-include-it-in-the/m-p/230855#M68469</guid>
      <dc:creator>friscos</dc:creator>
      <dc:date>2016-08-18T18:07:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract from a value from XML and include it in the search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-from-a-value-from-XML-and-include-it-in-the/m-p/230856#M68470</link>
      <description>&lt;P&gt;host=myhostname | fields employee.id returns no results unfortunately. &lt;/P&gt;</description>
      <pubDate>Thu, 18 Aug 2016 18:11:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-from-a-value-from-XML-and-include-it-in-the/m-p/230856#M68470</guid>
      <dc:creator>friscos</dc:creator>
      <dc:date>2016-08-18T18:11:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract from a value from XML and include it in the search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-from-a-value-from-XML-and-include-it-in-the/m-p/230857#M68471</link>
      <description>&lt;P&gt;on running host=myhostname sourcetype=mysourcetype.. are you able to see the interesting fields in the left side of the pane in search head? &lt;/P&gt;</description>
      <pubDate>Fri, 19 Aug 2016 05:54:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-from-a-value-from-XML-and-include-it-in-the/m-p/230857#M68471</guid>
      <dc:creator>pasokkum</dc:creator>
      <dc:date>2016-08-19T05:54:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract from a value from XML and include it in the search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-from-a-value-from-XML-and-include-it-in-the/m-p/230858#M68472</link>
      <description>&lt;P&gt;Yes, I see the selected fields and interesting fields. I did try extract the id field from the event xml (using regex) but not able to include that regex in the search.  &lt;/P&gt;</description>
      <pubDate>Fri, 19 Aug 2016 12:54:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-from-a-value-from-XML-and-include-it-in-the/m-p/230858#M68472</guid>
      <dc:creator>friscos</dc:creator>
      <dc:date>2016-08-19T12:54:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract from a value from XML and include it in the search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-from-a-value-from-XML-and-include-it-in-the/m-p/230859#M68473</link>
      <description>&lt;P&gt;are you loading .xml files to indexer?&lt;/P&gt;</description>
      <pubDate>Mon, 22 Aug 2016 06:40:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-from-a-value-from-XML-and-include-it-in-the/m-p/230859#M68473</guid>
      <dc:creator>pasokkum</dc:creator>
      <dc:date>2016-08-22T06:40:11Z</dc:date>
    </item>
  </channel>
</rss>

