<?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: need help with eval query in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/need-help-with-eval-query/m-p/452390#M128111</link>
    <description>&lt;P&gt;Try this for your regex:&lt;/P&gt;

&lt;P&gt;fw:\sorder\sinquiry&lt;/P&gt;</description>
    <pubDate>Fri, 20 Jul 2018 13:26:19 GMT</pubDate>
    <dc:creator>auraria1</dc:creator>
    <dc:date>2018-07-20T13:26:19Z</dc:date>
    <item>
      <title>need help with eval query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/need-help-with-eval-query/m-p/452383#M128104</link>
      <description>&lt;P&gt;hi want to compare the email header and count by dest_port =25. (Im trying to detect a phishing email via email title)&lt;BR /&gt;
if the email header has the same title appears twice, I will return the number of count by dest_port= 25&lt;/P&gt;

&lt;P&gt;source=* dest_port=25 &lt;BR /&gt;
| rex field=src_content max_match=0 "(?PSubject: Fw: Order Inquiry)" &lt;BR /&gt;
| eval count=mvcount(occurredSubject) &lt;BR /&gt;
|  stats sum(count) as totalOccurrence&lt;/P&gt;

&lt;P&gt;but it doesn't work. any help ?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 20:33:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/need-help-with-eval-query/m-p/452383#M128104</guid>
      <dc:creator>weicheng98</dc:creator>
      <dc:date>2020-09-29T20:33:38Z</dc:date>
    </item>
    <item>
      <title>Re: need help with eval query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/need-help-with-eval-query/m-p/452384#M128105</link>
      <description>&lt;P&gt;Wouldn't it be easier to just do a where modifier and by stats?&lt;/P&gt;

&lt;P&gt;Try the below, this will create a new field called subject, count based on the subject name, and show only results with more than 2 events.&lt;/P&gt;

&lt;P&gt;source=* dest_port=25&lt;BR /&gt;
| rex field=src_content max_match=0 "(?PSubject: Fw: Order Inquiry)" &lt;BR /&gt;
| stats count by Subject&lt;BR /&gt;
| where count &amp;gt; 2 &lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 20:31:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/need-help-with-eval-query/m-p/452384#M128105</guid>
      <dc:creator>auraria1</dc:creator>
      <dc:date>2020-09-29T20:31:51Z</dc:date>
    </item>
    <item>
      <title>Re: need help with eval query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/need-help-with-eval-query/m-p/452385#M128106</link>
      <description>&lt;P&gt;Hi @auraria1, thank you so much ! But how do I improve my query such that my rex isn't a hardcoded match ? for example I want to compare whether two events contains the same title in the src_content, then I return the result ?&lt;/P&gt;

&lt;P&gt;I really really appreciate your help as some of my previous questions posted online wasn't answered.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jul 2018 12:55:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/need-help-with-eval-query/m-p/452385#M128106</guid>
      <dc:creator>weicheng98</dc:creator>
      <dc:date>2018-07-20T12:55:01Z</dc:date>
    </item>
    <item>
      <title>Re: need help with eval query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/need-help-with-eval-query/m-p/452386#M128107</link>
      <description>&lt;P&gt;I also would like to point out that as you said, it will create a new field called subject. Although the number of occurence is correct, but why is it that when when I change the regex, it returned the regex results instead of the subject found in the src_content ?&lt;/P&gt;

&lt;P&gt;for example: if I just put:&lt;BR /&gt;
| rex field=src_content max_match=0 "(?PSubject: Fw: )"&lt;/P&gt;

&lt;P&gt;in splunk stream src_content: "Subject: Fw Order Inquiry"&lt;BR /&gt;
it will return me "Fw:" as the subject returned instead of the matched result in the src_content. Why is that so ?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 20:33:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/need-help-with-eval-query/m-p/452386#M128107</guid>
      <dc:creator>weicheng98</dc:creator>
      <dc:date>2020-09-29T20:33:48Z</dc:date>
    </item>
    <item>
      <title>Re: need help with eval query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/need-help-with-eval-query/m-p/452387#M128108</link>
      <description>&lt;P&gt;Hello @weicheng98,&lt;/P&gt;

&lt;P&gt;Is it possible to provide some sample events. I think there might be a mistake in your rex statement. &lt;/P&gt;</description>
      <pubDate>Fri, 20 Jul 2018 13:17:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/need-help-with-eval-query/m-p/452387#M128108</guid>
      <dc:creator>sudosplunk</dc:creator>
      <dc:date>2018-07-20T13:17:21Z</dc:date>
    </item>
    <item>
      <title>Re: need help with eval query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/need-help-with-eval-query/m-p/452388#M128109</link>
      <description>&lt;P&gt;Wait I think I misunderstood the original question, is the issue that the regex isn't matching properly?&lt;/P&gt;

&lt;P&gt;Is that why you're having issues with the hardcoded regex?&lt;/P&gt;

&lt;P&gt;Can you provide 2-3 example email subjects so I can take a look and see why it isn't working?&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jul 2018 13:21:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/need-help-with-eval-query/m-p/452388#M128109</guid>
      <dc:creator>auraria1</dc:creator>
      <dc:date>2018-07-20T13:21:57Z</dc:date>
    </item>
    <item>
      <title>Re: need help with eval query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/need-help-with-eval-query/m-p/452389#M128110</link>
      <description>&lt;P&gt;sample event from src_content:&lt;/P&gt;

&lt;P&gt;MAIL FROM: &lt;BR /&gt;
RCPT TO:&lt;BR /&gt;
DATA&lt;/P&gt;

&lt;P&gt;Date: Mon, 12 Mar 2018 15:47:20&lt;BR /&gt;
From: Alice&lt;BR /&gt;
User-Agent: Mozilla/5.0 &lt;/P&gt;

&lt;P&gt;To:&lt;A href="mailto:Bob.@here.com"&gt;Bob.@here.com&lt;/A&gt;&lt;BR /&gt;
Subject: Fw: Order Inquiry&lt;BR /&gt;
Content-Type: multipart/mixed;&lt;BR /&gt;
 Dear Alice&lt;/P&gt;

&lt;P&gt;blah blah blah&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jul 2018 13:22:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/need-help-with-eval-query/m-p/452389#M128110</guid>
      <dc:creator>weicheng98</dc:creator>
      <dc:date>2018-07-20T13:22:37Z</dc:date>
    </item>
    <item>
      <title>Re: need help with eval query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/need-help-with-eval-query/m-p/452390#M128111</link>
      <description>&lt;P&gt;Try this for your regex:&lt;/P&gt;

&lt;P&gt;fw:\sorder\sinquiry&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jul 2018 13:26:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/need-help-with-eval-query/m-p/452390#M128111</guid>
      <dc:creator>auraria1</dc:creator>
      <dc:date>2018-07-20T13:26:19Z</dc:date>
    </item>
    <item>
      <title>Re: need help with eval query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/need-help-with-eval-query/m-p/452391#M128112</link>
      <description>&lt;P&gt;Another sample event&lt;/P&gt;

&lt;P&gt;MAIL FROM:&amp;lt;&amp;gt;&lt;BR /&gt;
RCPT TO:&lt;BR /&gt;
DATA&lt;BR /&gt;
Received: from htgz ([131.131.131.131])&lt;/P&gt;

&lt;P&gt;Message-ID: &lt;A href="mailto:20081229155033.5070401@rllss.com"&gt;20081229155033.5070401@rllss.com&lt;/A&gt;&lt;BR /&gt;
Date: Mon, 29 Dec 2008 15:50:33 -0500&lt;BR /&gt;
From: "Alice" &lt;BR /&gt;
User-Agent: Thunderbird&lt;/P&gt;

&lt;P&gt;To: &lt;A href="mailto:chapman@progress1.com"&gt;chapman@progress1.com&lt;/A&gt;&lt;BR /&gt;
Subject: Xmas of pleasure for your couple!&lt;BR /&gt;
Content-Type: text/plain; charset=ISO-8859-1; format=flowed&lt;BR /&gt;
Content-Transfer-Encoding: 7bit&lt;/P&gt;

&lt;P&gt;you have problems with your account&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jul 2018 13:29:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/need-help-with-eval-query/m-p/452391#M128112</guid>
      <dc:creator>weicheng98</dc:creator>
      <dc:date>2018-07-20T13:29:33Z</dc:date>
    </item>
    <item>
      <title>Re: need help with eval query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/need-help-with-eval-query/m-p/452392#M128113</link>
      <description>&lt;P&gt;Thank for the events. Give this a try. The rex here creates a new field called "new_subject".&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source=* dest_port=25
| rex field=_raw "Subject\:\s(?&amp;lt;new_subject&amp;gt;.+)"
| eval count=mvcount(new_subject)
| stats sum(count) as totalOccurrence
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 20 Jul 2018 13:33:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/need-help-with-eval-query/m-p/452392#M128113</guid>
      <dc:creator>sudosplunk</dc:creator>
      <dc:date>2018-07-20T13:33:40Z</dc:date>
    </item>
    <item>
      <title>Re: need help with eval query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/need-help-with-eval-query/m-p/452393#M128114</link>
      <description>&lt;P&gt;Is subject in it's own field? if not this makes it a bit more difficult.&lt;/P&gt;

&lt;P&gt;You can create a subject field using the following:&lt;/P&gt;

&lt;P&gt;| rex field=_raw "Subject:\s(?.*)Content-Type" | stats count by Subject | sort - count&lt;/P&gt;

&lt;P&gt;If so it'll make searching wayyyyyy easier, you can add this to a field extraction so this is done by splunk.&lt;/P&gt;

&lt;P&gt;In regards to your other question, are you specifically looking for only emails with fw: Order Inquiry as a subject to compare number of emails coming in? Or all subjects?&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jul 2018 13:37:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/need-help-with-eval-query/m-p/452393#M128114</guid>
      <dc:creator>auraria1</dc:creator>
      <dc:date>2018-07-20T13:37:56Z</dc:date>
    </item>
    <item>
      <title>Re: need help with eval query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/need-help-with-eval-query/m-p/452394#M128115</link>
      <description>&lt;P&gt;Hi,as you can see from my sample events, the src content contains these stream of data so that’s why I have to use regex. &lt;/P&gt;

&lt;P&gt;I’m trying to compare all subjects where those subjects appear more than once and it will return me the occurrence.&lt;/P&gt;

&lt;P&gt;The hard coded Regex is just to show check if I can match that subject in my stream of events.&lt;/P&gt;

&lt;P&gt;Is there anyway where I can compare events where the subject appears more than once ?&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jul 2018 14:21:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/need-help-with-eval-query/m-p/452394#M128115</guid>
      <dc:creator>weicheng98</dc:creator>
      <dc:date>2018-07-20T14:21:07Z</dc:date>
    </item>
    <item>
      <title>Re: need help with eval query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/need-help-with-eval-query/m-p/452395#M128116</link>
      <description>&lt;P&gt;Assuming you have 1 email message per event:&lt;/P&gt;

&lt;P&gt;Extract the subject, as already demonstrated by @auraria1 and do a count by subject and then filter for counts bigger than 1.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; source=* dest_port=25
 | rex field=_raw "Subject\:\s(?&amp;lt;subject&amp;gt;.+)"
 | stats count by subject
 | where count&amp;gt;1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If you want to retrieve the entire event, for those events that have subjects occuring more than once, then use eventstats instead of stats:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; source=* dest_port=25
 | rex field=_raw "Subject\:\s(?&amp;lt;subject&amp;gt;.+)"
 | eventstats count by subject
 | where count&amp;gt;1
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 20 Jul 2018 14:28:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/need-help-with-eval-query/m-p/452395#M128116</guid>
      <dc:creator>FrankVl</dc:creator>
      <dc:date>2018-07-20T14:28:19Z</dc:date>
    </item>
    <item>
      <title>Re: need help with eval query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/need-help-with-eval-query/m-p/452396#M128117</link>
      <description>&lt;P&gt;@FrankVI @auraria1 @nittala_surya, Thank you so much for the answer !! I really appreciate it ! It worked !&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jul 2018 17:16:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/need-help-with-eval-query/m-p/452396#M128117</guid>
      <dc:creator>weicheng98</dc:creator>
      <dc:date>2018-07-20T17:16:20Z</dc:date>
    </item>
  </channel>
</rss>

