<?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 Searching a particular field and performing actions based on its presence and value in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Searching-a-particular-field-and-performing-actions-based-on-its/m-p/313675#M93886</link>
    <description>&lt;P&gt;My application logs will print each record with id. If the record has any error, it will display the Error field else it won't. I want to look for the error field in each record, if present I have to look for the values in Error field. If 'A', I have to increase the count for Error Code as 503 by 1, if 'B', I have to increase the count for Error Code as 504 by 1 and if Error field is not present in the record, I have to increase the count for response code of 200 by 1.&lt;/P&gt;</description>
    <pubDate>Wed, 30 Aug 2017 22:24:15 GMT</pubDate>
    <dc:creator>kdulhan</dc:creator>
    <dc:date>2017-08-30T22:24:15Z</dc:date>
    <item>
      <title>Searching a particular field and performing actions based on its presence and value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Searching-a-particular-field-and-performing-actions-based-on-its/m-p/313675#M93886</link>
      <description>&lt;P&gt;My application logs will print each record with id. If the record has any error, it will display the Error field else it won't. I want to look for the error field in each record, if present I have to look for the values in Error field. If 'A', I have to increase the count for Error Code as 503 by 1, if 'B', I have to increase the count for Error Code as 504 by 1 and if Error field is not present in the record, I have to increase the count for response code of 200 by 1.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Aug 2017 22:24:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Searching-a-particular-field-and-performing-actions-based-on-its/m-p/313675#M93886</guid>
      <dc:creator>kdulhan</dc:creator>
      <dc:date>2017-08-30T22:24:15Z</dc:date>
    </item>
    <item>
      <title>Re: Searching a particular field and performing actions based on its presence and value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Searching-a-particular-field-and-performing-actions-based-on-its/m-p/313676#M93887</link>
      <description>&lt;P&gt;I don't get it.  This kind of situation always benefits from sample event data and desired mockup of final output.&lt;/P&gt;</description>
      <pubDate>Thu, 31 Aug 2017 00:08:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Searching-a-particular-field-and-performing-actions-based-on-its/m-p/313676#M93887</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-08-31T00:08:37Z</dc:date>
    </item>
    <item>
      <title>Re: Searching a particular field and performing actions based on its presence and value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Searching-a-particular-field-and-performing-actions-based-on-its/m-p/313677#M93888</link>
      <description>&lt;P&gt;Examples of events:&lt;/P&gt;

&lt;P&gt;Without error:&lt;BR /&gt;
Timestamp: 2017-31-08 21:00:01 alpha-transform-id=random generated id, [Response] Service = alpha-transform, ResponseTime=200ms ....&lt;/P&gt;

&lt;P&gt;With error:&lt;BR /&gt;
Timestamp: 2017-31-08 21:00:03 alpha-transform-id=random generated id, [Error Response] Service = alpha-transform, ResponseTime=200ms, Error='A' ....&lt;/P&gt;

&lt;P&gt;Kindly let me know if I just put Index and Namespace in search bar and got above two records as an example. How can I search for Error field and then evaluate based on its value to assign a right error code. &lt;/P&gt;</description>
      <pubDate>Thu, 31 Aug 2017 00:16:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Searching-a-particular-field-and-performing-actions-based-on-its/m-p/313677#M93888</guid>
      <dc:creator>kdulhan</dc:creator>
      <dc:date>2017-08-31T00:16:22Z</dc:date>
    </item>
    <item>
      <title>Re: Searching a particular field and performing actions based on its presence and value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Searching-a-particular-field-and-performing-actions-based-on-its/m-p/313678#M93889</link>
      <description>&lt;P&gt;Do it like this (probably not, though, see other answer):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|makeresults
| eval raw="Timestamp: 2017-31-08 21:00:01 alpha-transform-id=random generated id, [Response] Service = alpha-transform, ResponseTime=200ms:::Timestamp: 2017-31-08 21:00:03 alpha-transform-id=random generated id, [Error Response] Service = alpha-transform, ResponseTime=200ms, Error='A'"
| makemv delim=":::" raw
| mvexpand raw
| rename raw AS _raw
| kv

| rename COMMENT AS "Everything above generates sample event data; everything below is your solution."

| eval fieldToInc=case(Error="'A'", "503",
                       Error="'B'", "504",
                       true(),      "200")
| eval {fieldToInc}_T3mP = 1
| foreach *_T3mP [eval "&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;" = if(isnotnull($&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;$), if(isnull($&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;$), 1, $&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;$ + 1), null()) ]
| fields - fieldToInc *_T3mP
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 31 Aug 2017 01:19:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Searching-a-particular-field-and-performing-actions-based-on-its/m-p/313678#M93889</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-08-31T01:19:20Z</dc:date>
    </item>
    <item>
      <title>Re: Searching a particular field and performing actions based on its presence and value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Searching-a-particular-field-and-performing-actions-based-on-its/m-p/313679#M93890</link>
      <description>&lt;P&gt;Actually, I think that I took you too literally in the other answer.  I think that what you are really needing is aggregation counts like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; |makeresults | eval raw="Timestamp: 2017-31-08 21:00:01 alpha-transform-id=random generated id, [Response] Service = alpha-transform, ResponseTime=200ms:::Timestamp: 2017-31-08 21:00:03 alpha-transform-id=random generated id, [Error Response] Service = alpha-transform, ResponseTime=200ms, Error='A'"
 | makemv delim=":::" raw
 | mvexpand raw
 | rename raw AS _raw
 | kv

 | rename COMMENT AS "Everything above generates sample event data; everything below is your solution."

 | eval returnCode=case(Error="'A'", "503",
                        Error="'B'", "504",
                        true(),      "200")
 | stats count by returnCode
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 31 Aug 2017 02:10:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Searching-a-particular-field-and-performing-actions-based-on-its/m-p/313679#M93890</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-08-31T02:10:43Z</dc:date>
    </item>
    <item>
      <title>Re: Searching a particular field and performing actions based on its presence and value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Searching-a-particular-field-and-performing-actions-based-on-its/m-p/313680#M93891</link>
      <description>&lt;P&gt;My Initial search condition is =&amp;gt;&lt;BR /&gt;
ndex=ltm1_idx ns=app1 Service='trigger1' Id!='temp-12' | Search ErrorResponse&lt;/P&gt;

&lt;P&gt;This will result in the event where I will get the Id's other then temp-12 e.g. 100, 123, 124, etc. Now I need to search using that Id value e.g. Id=100 and get an ActNo field value.&lt;/P&gt;

&lt;P&gt;e.g. Event =&amp;gt; ndex=ltm1_idx ns=app1 Service='trigger1' Id='100' ActNo=A123.&lt;/P&gt;

&lt;P&gt;Now get this Account No field and check for its value either A123 or Not A123. If A123, add a counter to field1 and if not A123, add a counter to field2. And displaying the values of field 1 and field 2 for all the events found in Initial search above over a period of time.&lt;/P&gt;</description>
      <pubDate>Thu, 31 Aug 2017 19:34:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Searching-a-particular-field-and-performing-actions-based-on-its/m-p/313680#M93891</guid>
      <dc:creator>kdulhan</dc:creator>
      <dc:date>2017-08-31T19:34:29Z</dc:date>
    </item>
    <item>
      <title>Re: Searching a particular field and performing actions based on its presence and value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Searching-a-particular-field-and-performing-actions-based-on-its/m-p/313681#M93892</link>
      <description>&lt;P&gt;In order to search for the error records, I use :&lt;BR /&gt;
ns=app1 Service='trigger1' Id!='temp-100' | Search ErrorResponse&lt;/P&gt;

&lt;P&gt;Here I get an event like:&lt;BR /&gt;
timestamp ns=app1 [ErrorResponse] Service='trigger1' id=105 ActNo=1234&lt;/P&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 10:27:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Searching-a-particular-field-and-performing-actions-based-on-its/m-p/313681#M93892</guid>
      <dc:creator>kdulhan</dc:creator>
      <dc:date>2017-09-01T10:27:25Z</dc:date>
    </item>
    <item>
      <title>Re: Searching a particular field and performing actions based on its presence and value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Searching-a-particular-field-and-performing-actions-based-on-its/m-p/313682#M93893</link>
      <description>&lt;P&gt;I believe you started over in another Question on answers that is better formulated, right?&lt;/P&gt;</description>
      <pubDate>Sat, 02 Sep 2017 16:32:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Searching-a-particular-field-and-performing-actions-based-on-its/m-p/313682#M93893</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-09-02T16:32:17Z</dc:date>
    </item>
    <item>
      <title>Re: Searching a particular field and performing actions based on its presence and value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Searching-a-particular-field-and-performing-actions-based-on-its/m-p/313683#M93894</link>
      <description>&lt;P&gt;Yes. And apologies for changing the contents as I was also not sure on the pattern of events I was getting. Thank you!&lt;/P&gt;</description>
      <pubDate>Sat, 02 Sep 2017 18:44:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Searching-a-particular-field-and-performing-actions-based-on-its/m-p/313683#M93894</guid>
      <dc:creator>kdulhan</dc:creator>
      <dc:date>2017-09-02T18:44:49Z</dc:date>
    </item>
    <item>
      <title>Re: Searching a particular field and performing actions based on its presence and value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Searching-a-particular-field-and-performing-actions-based-on-its/m-p/313684#M93895</link>
      <description>&lt;P&gt;No problem; it just means that this Q&amp;amp;A are dead.  Nothing to see.  Move along.&lt;/P&gt;</description>
      <pubDate>Sat, 02 Sep 2017 19:39:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Searching-a-particular-field-and-performing-actions-based-on-its/m-p/313684#M93895</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-09-02T19:39:44Z</dc:date>
    </item>
  </channel>
</rss>

