<?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 use rex to parse Select Query in a log? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-rex-to-parse-Select-Query-in-a-log/m-p/447397#M126824</link>
    <description>&lt;P&gt;I think you have it worked out for the most part. not seeing an actual example leaves a lot of possible incorrectness, but here is what I think you are after.&lt;BR /&gt;
&lt;CODE&gt;| rex "\"\d+\",\"select\s+(.*)\s+from\s+(.*)\s*where\s(?&amp;lt;WHERECAPTURE&amp;gt;.*)\s+group by\s+(.*)\s*\",(.*)\s*,(.*)"&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Let us know if you need more.&lt;/P&gt;</description>
    <pubDate>Wed, 06 Jun 2018 13:19:05 GMT</pubDate>
    <dc:creator>jodyfsu</dc:creator>
    <dc:date>2018-06-06T13:19:05Z</dc:date>
    <item>
      <title>How to use rex to parse Select Query in a log?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-rex-to-parse-Select-Query-in-a-log/m-p/447396#M126823</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I have a log like below &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;"12","select a.a,b.b,c from a,b where a.a = b.a group by xxxx","impala",2017-06-30T00:59:40
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I am trying to parse this to extract where condition for some performance analysis. &lt;/P&gt;

&lt;P&gt;I tried this in regex101 and got the below regex &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;\"\d+\",\"select\s+(.\*)\s+from\s+(.\*)\s*where\s(.\*)\s+group by\s+(.\*)\s*\",(.\*)\s*,(.\*)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Help me to implement it in SPL.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Jun 2018 11:00:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-rex-to-parse-Select-Query-in-a-log/m-p/447396#M126823</guid>
      <dc:creator>dkarthik16</dc:creator>
      <dc:date>2018-06-06T11:00:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to use rex to parse Select Query in a log?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-rex-to-parse-Select-Query-in-a-log/m-p/447397#M126824</link>
      <description>&lt;P&gt;I think you have it worked out for the most part. not seeing an actual example leaves a lot of possible incorrectness, but here is what I think you are after.&lt;BR /&gt;
&lt;CODE&gt;| rex "\"\d+\",\"select\s+(.*)\s+from\s+(.*)\s*where\s(?&amp;lt;WHERECAPTURE&amp;gt;.*)\s+group by\s+(.*)\s*\",(.*)\s*,(.*)"&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Let us know if you need more.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Jun 2018 13:19:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-rex-to-parse-Select-Query-in-a-log/m-p/447397#M126824</guid>
      <dc:creator>jodyfsu</dc:creator>
      <dc:date>2018-06-06T13:19:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to use rex to parse Select Query in a log?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-rex-to-parse-Select-Query-in-a-log/m-p/447398#M126825</link>
      <description>&lt;P&gt;And, if you are only trying to capture the WHERE:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex "where\s(?&amp;lt;WHERECAPTURE&amp;gt;.*)\s"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 06 Jun 2018 13:22:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-rex-to-parse-Select-Query-in-a-log/m-p/447398#M126825</guid>
      <dc:creator>jodyfsu</dc:creator>
      <dc:date>2018-06-06T13:22:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to use rex to parse Select Query in a log?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-rex-to-parse-Select-Query-in-a-log/m-p/447399#M126826</link>
      <description>&lt;P&gt;Thanks ...  And as you mentioned there are some mismatches in actual logs and Since the query was written by Humans which doesn't follow any meaningful pattern. Actually I extended my analysis to extract JOINS also.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jun 2018 06:37:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-rex-to-parse-Select-Query-in-a-log/m-p/447399#M126826</guid>
      <dc:creator>dkarthik16</dc:creator>
      <dc:date>2018-06-07T06:37:43Z</dc:date>
    </item>
  </channel>
</rss>

