<?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 count events from a same file with having two different raw text  ? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-count-events-from-a-same-file-with-having-two-different/m-p/297684#M89825</link>
    <description>&lt;P&gt;Give this a try.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=Only_prod host=winter-p*-1 sourcetype="Season.log"
(Incoming OR Outgoing) 
(NOT ("Some String One" ) ("Some String Two" OR "Some String Three" OR "Some String Four")) OR NOT ("Some String Five" ) ("Some String Seven" OR "Some String Six" OR "Some String Eight")
| eval Success=if(searchmatch("NOT (\"Some String One\" ) (\"Some String Two\" OR \"Some String Three\" OR \"Some String Four\""),1,0) | eval Error=abs(Success-1)
|stats sum(Error) as Errors sum(Success) as Successes
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 08 Jan 2018 15:50:59 GMT</pubDate>
    <dc:creator>somesoni2</dc:creator>
    <dc:date>2018-01-08T15:50:59Z</dc:date>
    <item>
      <title>How to count events from a same file with having two different raw text  ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-count-events-from-a-same-file-with-having-two-different/m-p/297683#M89824</link>
      <description>&lt;P&gt;Hi Splunker,&lt;/P&gt;

&lt;P&gt;I have to count success and failure count from the same index and sourcetype on the basis of raw text in an event.&lt;BR /&gt;
Only difference is that for success raw text is different and for failure raw text is different.&lt;/P&gt;

&lt;P&gt;I have used below logic to find count of success and failure but this query is taking loads of time to execute.&lt;/P&gt;

&lt;P&gt;Please remember these strings present below are not any field in Splunk it's a simple text on the basis of that i need to filter and count.&lt;/P&gt;

&lt;P&gt;Could you please suggest me some other way by which i can execute this query faster.&lt;/P&gt;

&lt;P&gt;index=Only_prod host=winter-p*-1  sourcetype="Season.log"&lt;BR /&gt;
(Incoming OR Outgoing) &lt;BR /&gt;
NOT ("Some String One" )  ("Some String Two" OR "Some String Three" OR "Some String Four")&lt;BR /&gt;
|stats count as Error &lt;/P&gt;

&lt;P&gt;|Join serviceName type=outer [&lt;BR /&gt;
search index=Only_prod host=winter-p*-1  sourcetype="Season.log"&lt;BR /&gt;
(Incoming OR Outgoing) &lt;BR /&gt;
NOT ("Some String Five" )  ("Some String Seven" OR "Some String Six" OR "Some String Eight")&lt;BR /&gt;
| stats count as Successes ]&lt;/P&gt;

&lt;P&gt;Thanks in Advance&lt;BR /&gt;
Regards,&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jan 2018 15:43:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-count-events-from-a-same-file-with-having-two-different/m-p/297683#M89824</guid>
      <dc:creator>m7787580</dc:creator>
      <dc:date>2018-01-08T15:43:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to count events from a same file with having two different raw text  ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-count-events-from-a-same-file-with-having-two-different/m-p/297684#M89825</link>
      <description>&lt;P&gt;Give this a try.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=Only_prod host=winter-p*-1 sourcetype="Season.log"
(Incoming OR Outgoing) 
(NOT ("Some String One" ) ("Some String Two" OR "Some String Three" OR "Some String Four")) OR NOT ("Some String Five" ) ("Some String Seven" OR "Some String Six" OR "Some String Eight")
| eval Success=if(searchmatch("NOT (\"Some String One\" ) (\"Some String Two\" OR \"Some String Three\" OR \"Some String Four\""),1,0) | eval Error=abs(Success-1)
|stats sum(Error) as Errors sum(Success) as Successes
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 08 Jan 2018 15:50:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-count-events-from-a-same-file-with-having-two-different/m-p/297684#M89825</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2018-01-08T15:50:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to count events from a same file with having two different raw text  ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-count-events-from-a-same-file-with-having-two-different/m-p/297685#M89826</link>
      <description>&lt;P&gt;Hi m7787580,&lt;BR /&gt;
try something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(index=Only_prod host=winter-p*-1 sourcetype="Season.log" (Incoming OR Outgoing) NOT ("Some String One" ) ("Some String Two" OR "Some String Three" OR "Some String Four")) OR (index=Only_prod host=winter-p*-1 sourcetype="Season.log" (Incoming OR Outgoing) NOT ("Some String Five" ) ("Some String Seven" OR "Some String Six" OR "Some String Eight"))
| eval status=case(searchmatch("Some String Two"),"Error",searchmatch("Some String Three"),"Error",searchmatch("Some String Four"),"Error",searchmatch("Some String Seven"),"Success",searchmatch("Some String Six"),"Success",searchmatch("Some String Eight"),"Success")
| stats count BY status
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;In few words: put in OR both your searches and, using eval, give a status to each event, then you can use stats command.&lt;/P&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jan 2018 15:57:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-count-events-from-a-same-file-with-having-two-different/m-p/297685#M89826</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2018-01-08T15:57:38Z</dc:date>
    </item>
  </channel>
</rss>

