<?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 create a search with conditional field extraction logic? If sourcetype=x, use rex extraction 1, but if source=y, use rex extraction 2 in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-search-with-conditional-field-extraction-logic/m-p/240605#M71525</link>
    <description>&lt;P&gt;rex field=message_text "UCE-(?&amp;lt; UCE_Code &amp;gt;[^\s:;]+)" index=wls sourcetype=wls_managedserver events&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;&lt;/CODE&gt;&lt;/P&gt;

&lt;H4&gt;&amp;lt; Aug 18, 2016 5:05:20 PM CDT &amp;gt; &amp;lt; Warning &amp;gt; &amp;lt; ucontrol &amp;gt; &amp;lt; betamax-cpe2 &amp;gt; &amp;lt;  managedServer2 &amp;gt; &amp;lt; pool-5-thread-4 &amp;gt; &amp;lt;&amp;lt; anonymous &amp;gt;&amp;gt; &amp;lt; &amp;gt; &amp;lt; &amp;gt; &amp;lt; 1471557920294 &amp;gt; &amp;lt; BEA-000000 &amp;gt; &amp;lt; fn.xmpp.v2.IQSMAPHandler  - UCE-24100 - Server exception while processing SMAP message '/event/lighting' from '1000275@xmpp/9c972687947f'&lt;/H4&gt;

&lt;P&gt;rex "UCE-(?&amp;lt; UCE_Code1 &amp;gt;[^\"]+)"  index=main source="/etc/httpd/logs/portal-access*log*" events&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;"beta.icontrol.com" 99.98.192.121 "99.98.192.121" - - [18/Aug/2016:17:07:22 -0500] "GET /rest/icontrol/sites/1001226/network/instances/1004a1514a4f98.0/functions/getUserCodes HTTP/1.1" 404 43 0 10418 "-" "Mozilla/5.0 (Linux; Android 6.0.1; SAMSUNG-SM-G930A Build/MMB29M; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/52.0.2743.98 Mobile Safari/537.36" "UCE-16001"&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;"beta.icontrol.com" 54.174.106.18 "54.174.106.18" - - [18/Aug/2016:17:13:28 -0500] "GET /rest/icontrol/users/1000251/preferences/scenes HTTP/1.1" 404 46 0 22809 "-" "Apache-HttpClient/4.3.6 (java 1.5)" "UCE-16000"&lt;/CODE&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 10:42:01 GMT</pubDate>
    <dc:creator>dbcase</dc:creator>
    <dc:date>2020-09-29T10:42:01Z</dc:date>
    <item>
      <title>How to create a search with conditional field extraction logic? If sourcetype=x, use rex extraction 1, but if source=y, use rex extraction 2</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-search-with-conditional-field-extraction-logic/m-p/240599#M71519</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I have the following search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host="*beta*" index=wls OR index=main sourcetype=wls_managedserver OR source="/etc/httpd/logs/portal-access_log*" |rex field=message_text "UCE-(?&amp;lt; UCE_Code &amp;gt;[^\s\:;]+)"|rex "UCE-(?&amp;lt; UCE_Code1 &amp;gt;[^\"]+)"|table UCE_Code UCE_Code1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The search works if I break it apart, meaning using:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Index=wls and sourcetype=wls_managedserver with rex UCE-(?&amp;lt; UCE_Code &amp;gt;[^\s\:;]+)" as query1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;index=main source="/etc/httpd/logs/portal-access_log*" with rex "UCE-(?&amp;lt; UCE_Code1 &amp;gt;[^\"]+)" as query2&lt;BR /&gt;
but of course I'd like to combine the two searches.  How can I have the rex definitions associate to a sourcetype/index/source?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 10:41:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-search-with-conditional-field-extraction-logic/m-p/240599#M71519</guid>
      <dc:creator>dbcase</dc:creator>
      <dc:date>2020-09-29T10:41:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a search with conditional field extraction logic? If sourcetype=x, use rex extraction 1, but if source=y, use rex extraction 2</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-search-with-conditional-field-extraction-logic/m-p/240600#M71520</link>
      <description>&lt;P&gt;How about something like this.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host="*beta*" index=wls OR index=main sourcetype=wls_managedserver OR source="/etc/httpd/logs/portal-access_log*" | rex field=message_text "UCE-(?&amp;lt; UCE_Code &amp;gt;[^\s\:;]+)"| rex "UCE-(?&amp;lt; UCE_Code1 &amp;gt;[^\"]+)" | eval UCE_Code=if(source="/etc/httpd/logs/portal-access_log*", UCE_CODE1, UCE_CODE) | table UCE_Code
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 18 Aug 2016 21:45:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-search-with-conditional-field-extraction-logic/m-p/240600#M71520</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-08-18T21:45:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a search with conditional field extraction logic? If sourcetype=x, use rex extraction 1, but if source=y, use rex extraction 2</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-search-with-conditional-field-extraction-logic/m-p/240601#M71521</link>
      <description>&lt;P&gt;Hi sundareshr,  thats close!   One problem though, the rex extraction for UCE_code1 is pulling the wrong data because it is looking at a different log than intended.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Aug 2016 21:55:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-search-with-conditional-field-extraction-logic/m-p/240601#M71521</guid>
      <dc:creator>dbcase</dc:creator>
      <dc:date>2016-08-18T21:55:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a search with conditional field extraction logic? If sourcetype=x, use rex extraction 1, but if source=y, use rex extraction 2</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-search-with-conditional-field-extraction-logic/m-p/240602#M71522</link>
      <description>&lt;P&gt;can you share a sample for each type (source="/etc/httpd/logs/portal-access_log*" AND the other)&lt;/P&gt;</description>
      <pubDate>Thu, 18 Aug 2016 21:59:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-search-with-conditional-field-extraction-logic/m-p/240602#M71522</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-08-18T21:59:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a search with conditional field extraction logic? If sourcetype=x, use rex extraction 1, but if source=y, use rex extraction 2</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-search-with-conditional-field-extraction-logic/m-p/240603#M71523</link>
      <description>&lt;P&gt;a bit more detail.....&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt; rex field=message_text "UCE-(?&amp;lt; UCE_Code &amp;gt;[^\s:;]+)"&lt;/CODE&gt; gets the right UCE Code if it is looking at index=wls sourcetype=wls_managedserver events&lt;/P&gt;

&lt;P&gt;similarly &lt;CODE&gt; rex "UCE-(?&amp;lt; UCE_Code1 &amp;gt;[^\"]+)"&lt;/CODE&gt; gets the right UCE Code if it is looking at index=main source="/etc/httpd/logs/portal-access*log*" events&lt;/P&gt;

&lt;P&gt;but when the sourcetype/index/sources are cobbled together the rex gets confused because the formats don't match if you switch them.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 10:41:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-search-with-conditional-field-extraction-logic/m-p/240603#M71523</guid>
      <dc:creator>dbcase</dc:creator>
      <dc:date>2020-09-29T10:41:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a search with conditional field extraction logic? If sourcetype=x, use rex extraction 1, but if source=y, use rex extraction 2</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-search-with-conditional-field-extraction-logic/m-p/240604#M71524</link>
      <description>&lt;P&gt;I understand. I am wondering if there is a different rex that could be applied to make this work without two searches. Can you share couple of samples, you can obfuscate any sensitive info.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Aug 2016 22:03:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-search-with-conditional-field-extraction-logic/m-p/240604#M71524</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-08-18T22:03:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a search with conditional field extraction logic? If sourcetype=x, use rex extraction 1, but if source=y, use rex extraction 2</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-search-with-conditional-field-extraction-logic/m-p/240605#M71525</link>
      <description>&lt;P&gt;rex field=message_text "UCE-(?&amp;lt; UCE_Code &amp;gt;[^\s:;]+)" index=wls sourcetype=wls_managedserver events&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;&lt;/CODE&gt;&lt;/P&gt;

&lt;H4&gt;&amp;lt; Aug 18, 2016 5:05:20 PM CDT &amp;gt; &amp;lt; Warning &amp;gt; &amp;lt; ucontrol &amp;gt; &amp;lt; betamax-cpe2 &amp;gt; &amp;lt;  managedServer2 &amp;gt; &amp;lt; pool-5-thread-4 &amp;gt; &amp;lt;&amp;lt; anonymous &amp;gt;&amp;gt; &amp;lt; &amp;gt; &amp;lt; &amp;gt; &amp;lt; 1471557920294 &amp;gt; &amp;lt; BEA-000000 &amp;gt; &amp;lt; fn.xmpp.v2.IQSMAPHandler  - UCE-24100 - Server exception while processing SMAP message '/event/lighting' from '1000275@xmpp/9c972687947f'&lt;/H4&gt;

&lt;P&gt;rex "UCE-(?&amp;lt; UCE_Code1 &amp;gt;[^\"]+)"  index=main source="/etc/httpd/logs/portal-access*log*" events&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;"beta.icontrol.com" 99.98.192.121 "99.98.192.121" - - [18/Aug/2016:17:07:22 -0500] "GET /rest/icontrol/sites/1001226/network/instances/1004a1514a4f98.0/functions/getUserCodes HTTP/1.1" 404 43 0 10418 "-" "Mozilla/5.0 (Linux; Android 6.0.1; SAMSUNG-SM-G930A Build/MMB29M; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/52.0.2743.98 Mobile Safari/537.36" "UCE-16001"&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;"beta.icontrol.com" 54.174.106.18 "54.174.106.18" - - [18/Aug/2016:17:13:28 -0500] "GET /rest/icontrol/users/1000251/preferences/scenes HTTP/1.1" 404 46 0 22809 "-" "Apache-HttpClient/4.3.6 (java 1.5)" "UCE-16000"&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 10:42:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-search-with-conditional-field-extraction-logic/m-p/240605#M71525</guid>
      <dc:creator>dbcase</dc:creator>
      <dc:date>2020-09-29T10:42:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a search with conditional field extraction logic? If sourcetype=x, use rex extraction 1, but if source=y, use rex extraction 2</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-search-with-conditional-field-extraction-logic/m-p/240606#M71526</link>
      <description>&lt;P&gt;Try this regex `"UCE-(?&lt;CODE&gt;(\d+\")|(\d+\s.*))"&lt;BR /&gt;
&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Aug 2016 22:35:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-search-with-conditional-field-extraction-logic/m-p/240606#M71526</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-08-18T22:35:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a search with conditional field extraction logic? If sourcetype=x, use rex extraction 1, but if source=y, use rex extraction 2</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-search-with-conditional-field-extraction-logic/m-p/240607#M71527</link>
      <description>&lt;P&gt;Try this run-anywhere sample. (use everything after the &lt;CODE&gt;| table x&lt;/CODE&gt; segment)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| gentimes start=-1 | eval x="&amp;lt; Warning &amp;gt; &amp;lt; ucontrol &amp;gt; &amp;lt; betamax-cpe2 &amp;gt; &amp;lt; managedServer2 &amp;gt; &amp;lt; pool-5-thread-4 &amp;gt; &amp;lt;&amp;lt; anonymous &amp;gt;&amp;gt; &amp;lt; &amp;gt; &amp;lt; &amp;gt; &amp;lt; 1471557920294 &amp;gt; &amp;lt; BEA-000000 &amp;gt; &amp;lt; fn.xmpp.v2.IQSMAPHandler - UCE-24100 - Server exception while processing SMAP message '/event/lighting' from '1000275@xmpp/9c972687947f'|

 - - [18/Aug/2016:17:07:22 -0500] \"GET /rest/icontrol/sites/1001226/network/instances/1004a1514a4f98.0/functions/getUserCodes HTTP/1.1\" 404 43 0 10418 \"-\" \"Mozilla/5.0 (Linux; Android 6.0.1; SAMSUNG-SM-G930A Build/MMB29M; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/52.0.2743.98 Mobile Safari/537.36\" \"UCE-16001\"|

 - - [18/Aug/2016:17:13:28 -0500] \"GET /rest/icontrol/users/1000251/preferences/scenes HTTP/1.1\" 404 46 0 22809 \"-\" \"Apache-HttpClient/4.3.6 (java 1.5)\" \"UCE-16000\""| makemv x delim="|" | mvexpand x | table x | rex field=x "UCE-(?&amp;lt;code&amp;gt;(\d+\")|(\d+\s.*))" | table x code | rex mode=sed field=code "s/(\d+)\"/\1/g"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 18 Aug 2016 22:57:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-search-with-conditional-field-extraction-logic/m-p/240607#M71527</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-08-18T22:57:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a search with conditional field extraction logic? If sourcetype=x, use rex extraction 1, but if source=y, use rex extraction 2</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-search-with-conditional-field-extraction-logic/m-p/240608#M71528</link>
      <description>&lt;P&gt;Hi Sundareshr,&lt;/P&gt;

&lt;P&gt;I think you are very close.  The table does have the UCE code (numeric digits) but it also has the error description which is pretty technical and won't be understood by the users.  I've made a lookup table that replaces the description with a more user friendly one.  How can the rex be modified so the UCE code is only the digits?&lt;/P&gt;</description>
      <pubDate>Fri, 19 Aug 2016 14:32:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-search-with-conditional-field-extraction-logic/m-p/240608#M71528</guid>
      <dc:creator>dbcase</dc:creator>
      <dc:date>2016-08-19T14:32:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a search with conditional field extraction logic? If sourcetype=x, use rex extraction 1, but if source=y, use rex extraction 2</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-search-with-conditional-field-extraction-logic/m-p/240609#M71529</link>
      <description>&lt;P&gt;Think I figured it out   UCE-(?&amp;lt; code &amp;gt;(\d+))&lt;/P&gt;</description>
      <pubDate>Fri, 19 Aug 2016 14:41:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-search-with-conditional-field-extraction-logic/m-p/240609#M71529</guid>
      <dc:creator>dbcase</dc:creator>
      <dc:date>2016-08-19T14:41:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a search with conditional field extraction logic? If sourcetype=x, use rex extraction 1, but if source=y, use rex extraction 2</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-search-with-conditional-field-extraction-logic/m-p/240610#M71530</link>
      <description>&lt;P&gt;If all you need is the numbers, you just need this. You don't need the &lt;CODE&gt;sed&lt;/CODE&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | rex field=x "UCE-(?&amp;lt;code&amp;gt;\d+) | ...
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 19 Aug 2016 14:49:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-search-with-conditional-field-extraction-logic/m-p/240610#M71530</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-08-19T14:49:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a search with conditional field extraction logic? If sourcetype=x, use rex extraction 1, but if source=y, use rex extraction 2</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-search-with-conditional-field-extraction-logic/m-p/240611#M71531</link>
      <description>&lt;P&gt;Thanks (again) Sundareshr!!&lt;/P&gt;</description>
      <pubDate>Fri, 19 Aug 2016 14:59:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-search-with-conditional-field-extraction-logic/m-p/240611#M71531</guid>
      <dc:creator>dbcase</dc:creator>
      <dc:date>2016-08-19T14:59:24Z</dc:date>
    </item>
  </channel>
</rss>

