<?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: I have an event with status=0 status=0 status=0 .... I want if all status fields values are 0 then new_field value is &amp;quot;sucess &amp;quot;  else new_field=&amp;quot;failure&amp;quot; in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/I-have-an-event-with-status-0-status-0-status-0-I-want-if-all/m-p/336106#M99794</link>
    <description>&lt;P&gt;This might work. Use rex command to match status values and create a single multivalue field. Then use eventstats to sum the values of your multivalue field. If the sum of status = 0, set a new_field to "OK". Otherwise, set new_field to "FAILURE". In the search below you can disregard the 'makeresults' and 'eval _raw =' commands. I just add those to generate an example event like yours that I can use. You want REX &amp;amp; EVENTSTATS&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults | EVAL _raw = "status=0 status=0 status=0" | REX max_match=0 field=_raw "status=(?P&amp;lt;status&amp;gt;[0-9])" | EVENTSTATS sum(status) AS status_sum | EVAL new_field=IF(status_sum==0,"OK","FAILURE")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 29 Sep 2020 13:40:47 GMT</pubDate>
    <dc:creator>jpass</dc:creator>
    <dc:date>2020-09-29T13:40:47Z</dc:date>
    <item>
      <title>I have an event with status=0 status=0 status=0 .... I want if all status fields values are 0 then new_field value is "sucess "  else new_field="failure"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/I-have-an-event-with-status-0-status-0-status-0-I-want-if-all/m-p/336105#M99793</link>
      <description>&lt;P&gt;I have an event with status=0 status=0 status=0 .... I want if all status fields values are 0 then new_field value is "sucess "  else new_field="failure"&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 13:44:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/I-have-an-event-with-status-0-status-0-status-0-I-want-if-all/m-p/336105#M99793</guid>
      <dc:creator>nagarjuna280</dc:creator>
      <dc:date>2020-09-29T13:44:00Z</dc:date>
    </item>
    <item>
      <title>Re: I have an event with status=0 status=0 status=0 .... I want if all status fields values are 0 then new_field value is "sucess "  else new_field="failure"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/I-have-an-event-with-status-0-status-0-status-0-I-want-if-all/m-p/336106#M99794</link>
      <description>&lt;P&gt;This might work. Use rex command to match status values and create a single multivalue field. Then use eventstats to sum the values of your multivalue field. If the sum of status = 0, set a new_field to "OK". Otherwise, set new_field to "FAILURE". In the search below you can disregard the 'makeresults' and 'eval _raw =' commands. I just add those to generate an example event like yours that I can use. You want REX &amp;amp; EVENTSTATS&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults | EVAL _raw = "status=0 status=0 status=0" | REX max_match=0 field=_raw "status=(?P&amp;lt;status&amp;gt;[0-9])" | EVENTSTATS sum(status) AS status_sum | EVAL new_field=IF(status_sum==0,"OK","FAILURE")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Sep 2020 13:40:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/I-have-an-event-with-status-0-status-0-status-0-I-want-if-all/m-p/336106#M99794</guid>
      <dc:creator>jpass</dc:creator>
      <dc:date>2020-09-29T13:40:47Z</dc:date>
    </item>
    <item>
      <title>Re: I have an event with status=0 status=0 status=0 .... I want if all status fields values are 0 then new_field value is "sucess "  else new_field="failure"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/I-have-an-event-with-status-0-status-0-status-0-I-want-if-all/m-p/336107#M99795</link>
      <description>&lt;P&gt;Since there is no sample data given, assuming you have data as below where string &lt;CODE&gt;status=&amp;lt;singleDigit&amp;gt;&lt;/CODE&gt; can occur multiple times and this occurrence might also vary however many times within an event. (The query however works well for events where &lt;CODE&gt;status=&amp;lt;singleDigit&amp;gt;&lt;/CODE&gt; phrase occurs same number of times within each event):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;aa, status=0 status=0 status=0 status=0 status=0
bb, status=0 status=0 status=1
cc, status=1 status=1
dd, status=0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then how about trying this one:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your query to return raw events
| rex max_match=0 field=_raw "status=(?&amp;lt;myStatus&amp;gt;\d)\s*"
| mvexpand myStatus
| stats sum(myStatus) as Sum by _raw
| eval new_field=if(Sum=0, "success", "failure")
| table _raw, new_field
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;Sample snapshot:&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/2792iC852866FA9AFDAE8/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Apr 2017 06:57:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/I-have-an-event-with-status-0-status-0-status-0-I-want-if-all/m-p/336107#M99795</guid>
      <dc:creator>gokadroid</dc:creator>
      <dc:date>2017-04-17T06:57:26Z</dc:date>
    </item>
  </channel>
</rss>

