<?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 can I extract these highlighted fields? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-extract-these-highlighted-fields/m-p/207221#M60428</link>
    <description>&lt;P&gt;In the original set of examples you posted in question you seemed to be interested in catching a mixed bag. Wherein in some of them interested piece was after first underscore and in one of the example &lt;CODE&gt;"VW_MCMM01_IvsHa"&lt;/CODE&gt; interested piece was after the second underscore i.e. &lt;CODE&gt;IvsHa&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;But based on recent comments If you want to capture everything after first underscore, try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your query to return events
|  rex "\"(?&amp;lt;ip&amp;gt;[^\"]+)\",\"(?&amp;lt;vm&amp;gt;[^\"]+)\",\"(?&amp;lt;question&amp;gt;[^\"]+)\",\"[^\_]+?\_(?&amp;lt;captured&amp;gt;[^\"]+)\""
| table captured
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;A href="https://regex101.com/r/QfoRa7/1"&gt;See extraction here&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 28 Dec 2016 02:17:22 GMT</pubDate>
    <dc:creator>gokadroid</dc:creator>
    <dc:date>2016-12-28T02:17:22Z</dc:date>
    <item>
      <title>How can I extract these highlighted fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-extract-these-highlighted-fields/m-p/207216#M60423</link>
      <description>&lt;P&gt;Hi all&lt;BR /&gt;
i want to get the below highlighted field.&lt;BR /&gt;
"10.123.123.123","VM","??????????","VW_MCMM01_&lt;STRONG&gt;IvsHa&lt;/STRONG&gt;","yellow","2016/12/27 04:49:16","False",,&lt;BR /&gt;
"10.123.123.123","VM","???????????","nap1_&lt;STRONG&gt;SeneChrt&lt;/STRONG&gt;","yellow","2016/12/26 16:59:20","False",,&lt;BR /&gt;
"10.123.123.123","VM","???????????","VM_search-4-169_&lt;STRONG&gt;Gaw1Hijdas&lt;/STRONG&gt;","yellow","2016/12/26 16:59:20","False",,&lt;/P&gt;

&lt;P&gt;thanks a lot.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 12:11:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-extract-these-highlighted-fields/m-p/207216#M60423</guid>
      <dc:creator>flora123</dc:creator>
      <dc:date>2020-09-29T12:11:57Z</dc:date>
    </item>
    <item>
      <title>Re: How can I extract these highlighted fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-extract-these-highlighted-fields/m-p/207217#M60424</link>
      <description>&lt;P&gt;please check this rex.. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your search | rex field=_raw "\_(?&amp;lt;vmRex&amp;gt;\w+)\"" | table vmRex _raw
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/2274i9032A780E2CB767F/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;BR /&gt;
as shown on this pic, its picking two texts, but one text contains extra words(the underscore was not proper i think). it may work properly on your system. please check it..&lt;/P&gt;</description>
      <pubDate>Tue, 27 Dec 2016 08:31:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-extract-these-highlighted-fields/m-p/207217#M60424</guid>
      <dc:creator>inventsekar</dc:creator>
      <dc:date>2016-12-27T08:31:52Z</dc:date>
    </item>
    <item>
      <title>Re: How can I extract these highlighted fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-extract-these-highlighted-fields/m-p/207218#M60425</link>
      <description>&lt;P&gt;Thanks a lot.&lt;BR /&gt;
but i still get some error values, like the below highlighted field.&lt;BR /&gt;
"10.123.123.123","VM","??????????","CM_&lt;STRONG&gt;NMCMSNM01_IvanHuang&lt;/STRONG&gt;","yellow","2016/12/27 08:39:59","False",,&lt;BR /&gt;
"10.123.123.123","VM","??????????","TACM_&lt;STRONG&gt;QA3_CharlesCheng&lt;/STRONG&gt;","yellow","2016/12/21 07:01:20","False",,&lt;BR /&gt;
"10.123.123.123","VM","GuestOS Shutdown or PowerOff","LucentNT_&lt;STRONG&gt;01_KaihongGuo&lt;/STRONG&gt;","red","2016/11/30 02:09:07","False",,&lt;BR /&gt;
"10.123.123.123","VM","GuestOS Shutdown or PowerOff","GISDEV_&lt;STRONG&gt;AP1_CasparChou&lt;/STRONG&gt;","red","2016/12/19 09:54:35","False",,&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 12:12:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-extract-these-highlighted-fields/m-p/207218#M60425</guid>
      <dc:creator>flora123</dc:creator>
      <dc:date>2020-09-29T12:12:00Z</dc:date>
    </item>
    <item>
      <title>Re: How can I extract these highlighted fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-extract-these-highlighted-fields/m-p/207219#M60426</link>
      <description>&lt;P&gt;Give this a try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search | rex "^(\"[^\"]+\",){3}\"([^_]+_){1,2}(?&amp;lt;error&amp;gt;\w+)\""
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 27 Dec 2016 15:45:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-extract-these-highlighted-fields/m-p/207219#M60426</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-12-27T15:45:53Z</dc:date>
    </item>
    <item>
      <title>Re: How can I extract these highlighted fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-extract-these-highlighted-fields/m-p/207220#M60427</link>
      <description>&lt;P&gt;This seems to be a CSV file, is there a file header? Have you tried loading  single file with Data Preview and sourcetype as csv?&lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;EDITED with an approach to the solution.&lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;If you add file as CSV sourcetype (rename as your own custom sourcetype name), fields should get automatically extracted. As per the details search time extracted field &lt;STRONG&gt;Entity&lt;/STRONG&gt; should have the value you want to extract. Since your data is CSV format it would be better to define the sourcetype properly so that you do not need to spend additional time during field extraction/mapping. Also, while rex will do the job for you, you should ideally move the same to &lt;STRONG&gt;Field extraction&lt;/STRONG&gt; &lt;STRONG&gt;Knowledge Object&lt;/STRONG&gt;, for simplification and easy maintenance of Splunk searches.&lt;/P&gt;

&lt;P&gt;Following is an example of using split command to split the Entity field into parts using underscore as the delimiter, mvcount is used to get the total split fields and finally mvindex to extract the last split field that contains the data you need.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;Your Base Search&amp;gt; 
| eval SplitFields=split(Entity,"_") 
| eval len=mvcount(SplitFields) 
| eval MyField=mvindex(SplitFields,len-1) 
| table Entity SplitFields len MyField
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You can also apply rex on Entity field, however it would be better to move the field extraction to props.conf for the CSV sourcetype that you create.&lt;/P&gt;

&lt;P&gt;Following is an example to test above code:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval Entity="TACM_QA3_CharlesCheng" 
| eval SplitFields=split(Entity,"_") 
| eval len=mvcount(SplitFields) 
| eval MyField=mvindex(SplitFields,len-1) 
| table Entity SplitFields len MyField
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 27 Dec 2016 16:45:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-extract-these-highlighted-fields/m-p/207220#M60427</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2016-12-27T16:45:56Z</dc:date>
    </item>
    <item>
      <title>Re: How can I extract these highlighted fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-extract-these-highlighted-fields/m-p/207221#M60428</link>
      <description>&lt;P&gt;In the original set of examples you posted in question you seemed to be interested in catching a mixed bag. Wherein in some of them interested piece was after first underscore and in one of the example &lt;CODE&gt;"VW_MCMM01_IvsHa"&lt;/CODE&gt; interested piece was after the second underscore i.e. &lt;CODE&gt;IvsHa&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;But based on recent comments If you want to capture everything after first underscore, try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your query to return events
|  rex "\"(?&amp;lt;ip&amp;gt;[^\"]+)\",\"(?&amp;lt;vm&amp;gt;[^\"]+)\",\"(?&amp;lt;question&amp;gt;[^\"]+)\",\"[^\_]+?\_(?&amp;lt;captured&amp;gt;[^\"]+)\""
| table captured
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;A href="https://regex101.com/r/QfoRa7/1"&gt;See extraction here&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Dec 2016 02:17:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-extract-these-highlighted-fields/m-p/207221#M60428</guid>
      <dc:creator>gokadroid</dc:creator>
      <dc:date>2016-12-28T02:17:22Z</dc:date>
    </item>
    <item>
      <title>Re: How can I extract these highlighted fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-extract-these-highlighted-fields/m-p/207222#M60429</link>
      <description>&lt;P&gt;great!thanks a lot&lt;/P&gt;</description>
      <pubDate>Wed, 28 Dec 2016 07:14:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-extract-these-highlighted-fields/m-p/207222#M60429</guid>
      <dc:creator>flora123</dc:creator>
      <dc:date>2016-12-28T07:14:28Z</dc:date>
    </item>
    <item>
      <title>Re: How can I extract these highlighted fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-extract-these-highlighted-fields/m-p/207223#M60430</link>
      <description>&lt;P&gt;yes,it's a CSV file.&lt;BR /&gt;
the file header is:&lt;/P&gt;

&lt;H1&gt;TYPE Selected.System.String&lt;/H1&gt;

&lt;P&gt;"VC","EntityType","Alarm","Entity","Status","Time","Acknowledged","AckBy","AckTime"&lt;BR /&gt;
i'll try load single file with Data Preview and sourcetype as csv.&lt;BR /&gt;
thanks a lot.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Dec 2016 07:18:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-extract-these-highlighted-fields/m-p/207223#M60430</guid>
      <dc:creator>flora123</dc:creator>
      <dc:date>2016-12-28T07:18:37Z</dc:date>
    </item>
  </channel>
</rss>

