<?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: Take multiple regex in single search string in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Take-multiple-regex-in-single-search-string/m-p/418801#M120410</link>
    <description>&lt;P&gt;Agreed, I find it very hard to follow what exactly you are trying to achieve and without something that looks like the actual data it's even harder to make sense of this.&lt;/P&gt;</description>
    <pubDate>Tue, 11 Jun 2019 15:08:23 GMT</pubDate>
    <dc:creator>FrankVl</dc:creator>
    <dc:date>2019-06-11T15:08:23Z</dc:date>
    <item>
      <title>Take multiple regex in single search string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Take-multiple-regex-in-single-search-string/m-p/418798#M120407</link>
      <description>&lt;P&gt;I have to extract the same features from two sets of logs with very different formats and need to take the additional features into account to shortlist the logs. Let me explain the case with an example,&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;LOG_TYPE_1 || field_1 || field_2 || field_3............. || field_9
LOG_TYPE_2 || field_a || field_1 || field_2 || field_b || field_c || field_3...........|| field_9
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I have to filter &lt;CODE&gt;LOG_TYPE_2 | where field_a="type_a"&lt;/CODE&gt;&lt;BR /&gt;
Now for both these &lt;STRONG&gt;I have to take Log_type, field_1, field_2, field_3, field_9 from both and then continue with the rest of the query in common.&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;For above case how can I create &lt;STRONG&gt;two rex/regex and do above Splunk query in a single search string (or most efficient manner)&lt;/STRONG&gt; rather than the time consuming lengthy JOIN otherwise.&lt;/P&gt;

&lt;P&gt;P.s. There are many other types of logs in the data. I only need to use the above 2 for the purpose.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 00:52:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Take-multiple-regex-in-single-search-string/m-p/418798#M120407</guid>
      <dc:creator>AshimaE</dc:creator>
      <dc:date>2020-09-30T00:52:46Z</dc:date>
    </item>
    <item>
      <title>Re: Take multiple regex in single search string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Take-multiple-regex-in-single-search-string/m-p/418799#M120408</link>
      <description>&lt;P&gt;I believe it'll be helpful for us to have some real data and corresponding sample search (if you'd extract fields from one log type only).&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jun 2019 13:30:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Take-multiple-regex-in-single-search-string/m-p/418799#M120408</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2019-06-11T13:30:30Z</dc:date>
    </item>
    <item>
      <title>Re: Take multiple regex in single search string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Take-multiple-regex-in-single-search-string/m-p/418800#M120409</link>
      <description>&lt;P&gt;Hi AshimaE,&lt;BR /&gt;
if the different logs are related to different sourcetypes, you could try to extract a field for each sourcetype (also using the same name) but using different regexes.&lt;BR /&gt;
If instead all the logs have the same sourcetype (not a good configuration!): you could extract two fields with different regexes and then merge them using the coalesce function, something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval my_field=coalesce(my_field1,my_field2)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jun 2019 13:36:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Take-multiple-regex-in-single-search-string/m-p/418800#M120409</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2019-06-11T13:36:26Z</dc:date>
    </item>
    <item>
      <title>Re: Take multiple regex in single search string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Take-multiple-regex-in-single-search-string/m-p/418801#M120410</link>
      <description>&lt;P&gt;Agreed, I find it very hard to follow what exactly you are trying to achieve and without something that looks like the actual data it's even harder to make sense of this.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jun 2019 15:08:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Take-multiple-regex-in-single-search-string/m-p/418801#M120410</guid>
      <dc:creator>FrankVl</dc:creator>
      <dc:date>2019-06-11T15:08:23Z</dc:date>
    </item>
    <item>
      <title>Re: Take multiple regex in single search string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Take-multiple-regex-in-single-search-string/m-p/418802#M120411</link>
      <description>&lt;P&gt;Individual rex are as follows&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=* host=* "LOG_RESPONSE" | rex ".*LOG_RESPONSE \|\| (?&amp;lt;id&amp;gt;.+) \|\| (?&amp;lt;sequence&amp;gt;.+) \|\| (?&amp;lt;field1&amp;gt;.+) \|\| (?&amp;lt;field2&amp;gt;.+) \|\| (?&amp;lt;field3&amp;gt;.+) \|\| (?&amp;lt;field4&amp;gt;.+) \|\| (?&amp;lt;result&amp;gt;.+).*"

index=* host=* "LOG_QUERY" | rex ".*QUERY \|\| (?&amp;lt;id&amp;gt;.+) \|\| (?&amp;lt;sequence&amp;gt;.+) \|\| (?&amp;lt;field1&amp;gt;.+) \|\| (?&amp;lt;field2&amp;gt;.+) \|\| (?&amp;lt;field3&amp;gt;.+) \|\| (?&amp;lt;field4&amp;gt;.+) \|\| (?&amp;lt;field5&amp;gt;.+) \|\| (?&amp;lt;field6&amp;gt;.+)\|\| (?&amp;lt;result&amp;gt;.+).*" | where field6 = "direct"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and I had done the rest of the processing individually thereafter which is common for both.&lt;BR /&gt;
Is it possible to combine the above two rex in some manner in a single query without using JOIN.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jun 2019 16:34:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Take-multiple-regex-in-single-search-string/m-p/418802#M120411</guid>
      <dc:creator>AshimaE</dc:creator>
      <dc:date>2019-06-11T16:34:34Z</dc:date>
    </item>
    <item>
      <title>Re: Take multiple regex in single search string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Take-multiple-regex-in-single-search-string/m-p/418803#M120412</link>
      <description>&lt;P&gt;Below should work. It pulls in both data sets by putting an &lt;CODE&gt;OR&lt;/CODE&gt; between the two strings to search for. Then performs the 2 &lt;CODE&gt;rex&lt;/CODE&gt; commands, either of which only applies to the event type it matches. Then we want to take all the events from the first log type plus the events from the second type that match &lt;CODE&gt;field6 = "direct"&lt;/CODE&gt;.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=* host=* "LOG_RESPONSE" OR "LOG_QUERY"
| rex ".*LOG_RESPONSE \|\| (?&amp;lt;id&amp;gt;.+) \|\| (?&amp;lt;sequence&amp;gt;.+) \|\| (?&amp;lt;field1&amp;gt;.+) \|\| (?&amp;lt;field2&amp;gt;.+) \|\| (?&amp;lt;field3&amp;gt;.+) \|\| (?&amp;lt;field4&amp;gt;.+) \|\| (?&amp;lt;result&amp;gt;.+).*"
| rex ".*QUERY \|\| (?&amp;lt;id&amp;gt;.+) \|\| (?&amp;lt;sequence&amp;gt;.+) \|\| (?&amp;lt;field1&amp;gt;.+) \|\| (?&amp;lt;field2&amp;gt;.+) \|\| (?&amp;lt;field3&amp;gt;.+) \|\| (?&amp;lt;field4&amp;gt;.+) \|\| (?&amp;lt;field5&amp;gt;.+) \|\| (?&amp;lt;field6&amp;gt;.+)\|\| (?&amp;lt;result&amp;gt;.+).*"
| search "LOG_RESPONSE" OR field6 = "direct"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If there are nicer ways to recognize the "LOG_RESPONSE" events, rather than from that string, you can change the &lt;CODE&gt;| search ...&lt;/CODE&gt; part accordingly.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jun 2019 07:23:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Take-multiple-regex-in-single-search-string/m-p/418803#M120412</guid>
      <dc:creator>FrankVl</dc:creator>
      <dc:date>2019-06-12T07:23:14Z</dc:date>
    </item>
  </channel>
</rss>

