<?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: Use the same search for mutiple fields and events? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Use-the-same-search-for-mutiple-fields-and-events/m-p/312706#M58604</link>
    <description>&lt;P&gt;Thanks.&lt;/P&gt;

&lt;P&gt;I get the account no and two counters as counter and bothcounters. But for every account no, it is only bothcounters having value as 1 while counter is always 0 which is not the case with respect to events as they got the some of the AcctNo has the appId as New1 and other's don't.&lt;/P&gt;</description>
    <pubDate>Fri, 01 Sep 2017 20:43:30 GMT</pubDate>
    <dc:creator>kdulhan</dc:creator>
    <dc:date>2017-09-01T20:43:30Z</dc:date>
    <item>
      <title>Use the same search for mutiple fields and events?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Use-the-same-search-for-mutiple-fields-and-events/m-p/312701#M58599</link>
      <description>&lt;P&gt;In order to search for the error records, I use :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;ns=app1 Service='trigger1' Id!='temp-100' | Search ErrorResponse
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Here I get an event like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;timestamp ns=app1 [ErrorResponse] Service='trigger1' id=105 ActNo=1234
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now I have to fetch this ActNo field and search with only ActNo=1234. It will list many events and in those I have to look for a field appId = 'New1'. If New1, I have to add it to a counter1 else counter2.&lt;/P&gt;

&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Fri, 01 Sep 2017 16:51:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Use-the-same-search-for-mutiple-fields-and-events/m-p/312701#M58599</guid>
      <dc:creator>kdulhan</dc:creator>
      <dc:date>2017-09-01T16:51:17Z</dc:date>
    </item>
    <item>
      <title>Re: Use the same search for mutiple fields and events?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Use-the-same-search-for-mutiple-fields-and-events/m-p/312702#M58600</link>
      <description>&lt;P&gt;If I've read you right, it would be something like this...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; timestamp ns=app1 [ErrorResponse] Service='trigger1' id=105 
     [ns=app1 Service='trigger1' Id!='temp-100' | Search ErrorResponse | table ActNo]
 | stats count(eval(appId="New1")) as counter count as bothcounters by ActNo  
 | eval counter2 = bothcounters-counter1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This part ...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;         [ns=app1 Service='trigger1' Id!='temp-100' | Search ErrorResponse | table ActNo]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;...returns a list of ActNo values in this format...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; ( ( ActNo="firstvalue" ) OR ( ActNo="secondvalue" ) OR ... OR ( ActNo="lastvalue" ) ) 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;then this part &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; timestamp ns=app1 [ErrorResponse] Service='trigger1' id=105  ( ( Actno=... )
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;... brings back the records, and this part counts them up ...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | stats count(eval(appId="New1")) as counter count as bothcounters by ActNo  
 | eval counter2 = bothcounters-counter1
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 01 Sep 2017 17:54:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Use-the-same-search-for-mutiple-fields-and-events/m-p/312702#M58600</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-09-01T17:54:12Z</dc:date>
    </item>
    <item>
      <title>Re: Use the same search for mutiple fields and events?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Use-the-same-search-for-mutiple-fields-and-events/m-p/312703#M58601</link>
      <description>&lt;P&gt;You could try something like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=whatever [ search ns=app1 Service=trigger1 Id!="temp-100" ErrorResponse | fields ActNo ]
| eval counter1 = if(appId=="New1",1,0)
| eval counter2 = if(appId=="New1",0,1)
| stats sum(counter1) as counter1 sum(counter2) as counter2 by ActNo 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;A few tips:&lt;/P&gt;

&lt;P&gt;A search like this &lt;CODE&gt;ns=app1 Service=trigger1 Id!="temp-100" | Search ErrorResponse&lt;/CODE&gt; should always be rewritten as&lt;BR /&gt;
&lt;CODE&gt;ns=app1 Service=trigger1 Id!="temp-100" ErrorResponse&lt;/CODE&gt;. Combine as much as possible into a single search.&lt;BR /&gt;
Splunk uses double-quotes for strings, but even that is not required in the search command if the string has no spaces or special characters.&lt;BR /&gt;
The search within brackets is called a subsearch. The list of ActNo's from the subsearch will be inserted into the outer search.&lt;BR /&gt;
Here is more information about &lt;A href="https://docs.splunk.com/Documentation/SplunkCloud/6.6.1/SearchTutorial/Useasubsearch"&gt;subsearches&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Sep 2017 17:55:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Use-the-same-search-for-mutiple-fields-and-events/m-p/312703#M58601</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2017-09-01T17:55:23Z</dc:date>
    </item>
    <item>
      <title>Re: Use the same search for mutiple fields and events?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Use-the-same-search-for-mutiple-fields-and-events/m-p/312704#M58602</link>
      <description>&lt;P&gt;oh, nice answer by @Daleanis as well. I could re-write my search as:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=whatever [ search ns=app1 Service=trigger1 Id!="temp-100" ErrorResponse | fields ActNo ]
 | stats sum(eval(appId=="New1")) as counter1 sum(eval(appId!="New1")) as counter2 by ActNo 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 01 Sep 2017 17:57:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Use-the-same-search-for-mutiple-fields-and-events/m-p/312704#M58602</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2017-09-01T17:57:55Z</dc:date>
    </item>
    <item>
      <title>Re: Use the same search for mutiple fields and events?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Use-the-same-search-for-mutiple-fields-and-events/m-p/312705#M58603</link>
      <description>&lt;P&gt;index=l2_idx ns=app1 Service='trigger1' Id!='temp-100 ErrorResponse | fields ActNo | stats sum(eval(appId=="New1")) as counter1 sum(eval(appId!=="New1")) as counter2 by ActNo&lt;/P&gt;

&lt;P&gt;Getting error as:&lt;BR /&gt;
Error in 'stats' command: The eval expression for dynamic field 'eval(appId!=="New1")' is invalid. Error='The expression is malformed. An unexpected character is reached at '="New1"'.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Sep 2017 20:36:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Use-the-same-search-for-mutiple-fields-and-events/m-p/312705#M58603</guid>
      <dc:creator>kdulhan</dc:creator>
      <dc:date>2017-09-01T20:36:53Z</dc:date>
    </item>
    <item>
      <title>Re: Use the same search for mutiple fields and events?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Use-the-same-search-for-mutiple-fields-and-events/m-p/312706#M58604</link>
      <description>&lt;P&gt;Thanks.&lt;/P&gt;

&lt;P&gt;I get the account no and two counters as counter and bothcounters. But for every account no, it is only bothcounters having value as 1 while counter is always 0 which is not the case with respect to events as they got the some of the AcctNo has the appId as New1 and other's don't.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Sep 2017 20:43:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Use-the-same-search-for-mutiple-fields-and-events/m-p/312706#M58604</guid>
      <dc:creator>kdulhan</dc:creator>
      <dc:date>2017-09-01T20:43:30Z</dc:date>
    </item>
    <item>
      <title>Re: Use the same search for mutiple fields and events?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Use-the-same-search-for-mutiple-fields-and-events/m-p/312707#M58605</link>
      <description>&lt;P&gt;appId in the event is displayed as appId=='New1'&lt;/P&gt;</description>
      <pubDate>Fri, 01 Sep 2017 20:50:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Use-the-same-search-for-mutiple-fields-and-events/m-p/312707#M58605</guid>
      <dc:creator>kdulhan</dc:creator>
      <dc:date>2017-09-01T20:50:55Z</dc:date>
    </item>
    <item>
      <title>Re: Use the same search for mutiple fields and events?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Use-the-same-search-for-mutiple-fields-and-events/m-p/312708#M58606</link>
      <description>&lt;P&gt;appId in the event is displayed as appId=='New1'&lt;/P&gt;</description>
      <pubDate>Fri, 01 Sep 2017 20:51:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Use-the-same-search-for-mutiple-fields-and-events/m-p/312708#M58606</guid>
      <dc:creator>kdulhan</dc:creator>
      <dc:date>2017-09-01T20:51:16Z</dc:date>
    </item>
    <item>
      <title>Re: Use the same search for mutiple fields and events?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Use-the-same-search-for-mutiple-fields-and-events/m-p/312709#M58607</link>
      <description>&lt;P&gt;Sorry it is displayed in event with single quotes as appId='New1'&lt;/P&gt;</description>
      <pubDate>Fri, 01 Sep 2017 20:51:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Use-the-same-search-for-mutiple-fields-and-events/m-p/312709#M58607</guid>
      <dc:creator>kdulhan</dc:creator>
      <dc:date>2017-09-01T20:51:50Z</dc:date>
    </item>
    <item>
      <title>Re: Use the same search for mutiple fields and events?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Use-the-same-search-for-mutiple-fields-and-events/m-p/312710#M58608</link>
      <description>&lt;P&gt;AppId in the events is displayed with single quotes as appId='New1'&lt;/P&gt;</description>
      <pubDate>Fri, 01 Sep 2017 20:52:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Use-the-same-search-for-mutiple-fields-and-events/m-p/312710#M58608</guid>
      <dc:creator>kdulhan</dc:creator>
      <dc:date>2017-09-01T20:52:19Z</dc:date>
    </item>
    <item>
      <title>Re: Use the same search for mutiple fields and events?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Use-the-same-search-for-mutiple-fields-and-events/m-p/312711#M58609</link>
      <description>&lt;P&gt;Can I have eval and stats count after ActNo as&lt;BR /&gt;
timestamp ns=app1 [ErrorResponse] Service='trigger1' id=105 [ns=app1 Service='trigger1' Id!='temp-100' | Search ErrorResponse | table ActNo | eval  | stats count as "Count1"]&lt;/P&gt;

&lt;P&gt;Also I want to check if there are records with that ActNo in the outer search or not. If not, I want to write that ActNo.&lt;/P&gt;

&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Mon, 04 Sep 2017 20:33:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Use-the-same-search-for-mutiple-fields-and-events/m-p/312711#M58609</guid>
      <dc:creator>kdulhan</dc:creator>
      <dc:date>2017-09-04T20:33:13Z</dc:date>
    </item>
  </channel>
</rss>

