<?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 write a search where if a certain string is found in a log, set Status=1, else Status=0? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-where-if-a-certain-string-is-found-in-a/m-p/136688#M37428</link>
    <description>&lt;P&gt;Be sure to &lt;CODE&gt;UpVote&lt;/CODE&gt;!&lt;/P&gt;</description>
    <pubDate>Sat, 12 Jan 2019 01:12:55 GMT</pubDate>
    <dc:creator>woodcock</dc:creator>
    <dc:date>2019-01-12T01:12:55Z</dc:date>
    <item>
      <title>How to write a search where if a certain string is found in a log, set Status=1, otherwise Status=0?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-where-if-a-certain-string-is-found-in-a/m-p/136680#M37420</link>
      <description>&lt;P&gt;I need to find a string in a log and set/unset a field depending on this.&lt;BR /&gt;Ex: field Status = 1 or 0.&lt;BR /&gt;I should say if(a_log_event contains "connected") then Status=1, otherwise 0&lt;/P&gt;
&lt;P&gt;Please help me with this&lt;/P&gt;
&lt;P&gt;THanks&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jan 2021 22:12:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-where-if-a-certain-string-is-found-in-a/m-p/136680#M37420</guid>
      <dc:creator>svivekananda007</dc:creator>
      <dc:date>2021-01-11T22:12:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a search where if a certain string is found in a log, set Status=1, else Status=0?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-where-if-a-certain-string-is-found-in-a/m-p/136681#M37421</link>
      <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eval Status=if(like(_raw, "%connected%"), 1, 0)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 04 Jun 2015 22:40:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-where-if-a-certain-string-is-found-in-a/m-p/136681#M37421</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-06-04T22:40:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a search where if a certain string is found in a log, set Status=1, else Status=0?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-where-if-a-certain-string-is-found-in-a/m-p/136682#M37422</link>
      <description>&lt;P&gt;THis worked. thanks. can you suggest me a way to keep Status=1 until "disconnected" is encountered in a log.&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jun 2015 22:46:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-where-if-a-certain-string-is-found-in-a/m-p/136682#M37422</guid>
      <dc:creator>svivekananda007</dc:creator>
      <dc:date>2015-06-04T22:46:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a search where if a certain string is found in a log, set Status=1, else Status=0?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-where-if-a-certain-string-is-found-in-a/m-p/136683#M37423</link>
      <description>&lt;P&gt;Define what you mean by "keep"? This evaluation creates a new field on a per-event basis. It is not keeping a state. Remember that a log searching tool is not necessarily the best way for finding out a state, because for whatever timerange you search, you might always miss that important piece of state information that was logged 5 minutes before your search time span...&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jun 2015 09:47:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-where-if-a-certain-string-is-found-in-a/m-p/136683#M37423</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2015-06-05T09:47:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a search where if a certain string is found in a log, set Status=1, else Status=0?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-where-if-a-certain-string-is-found-in-a/m-p/136684#M37424</link>
      <description>&lt;P&gt;This definitely works. It's good to know that % acts like a wildcard for eval statements in Splunk.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Mar 2018 08:42:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-where-if-a-certain-string-is-found-in-a/m-p/136684#M37424</guid>
      <dc:creator>Nextbeat</dc:creator>
      <dc:date>2018-03-27T08:42:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a search where if a certain string is found in a log, set Status=1, else Status=0?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-where-if-a-certain-string-is-found-in-a/m-p/136685#M37425</link>
      <description>&lt;P&gt;Say suppose, I get those logs every minute. Is there a way where I can create a field where if I get successive '0' in status(More than once), the field would display the status as error?&lt;/P&gt;</description>
      <pubDate>Fri, 06 Apr 2018 10:38:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-where-if-a-certain-string-is-found-in-a/m-p/136685#M37425</guid>
      <dc:creator>timmag</dc:creator>
      <dc:date>2018-04-06T10:38:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a search where if a certain string is found in a log, set Status=1, else Status=0?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-where-if-a-certain-string-is-found-in-a/m-p/136686#M37426</link>
      <description>&lt;P&gt;&lt;CODE&gt;| bucket _time span=1m | stats count(eval(like(&amp;lt;field&amp;gt;, "&amp;lt;status%&amp;gt;"))) AS count BY _time | eval &amp;lt;new_field&amp;gt;=if(count &amp;gt; 1, "error", "")&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Use the bucket function to view events per minute.  Then use stats to count a desired field by a value using the percent sign as a wildcard.  The second eval statement creates a new field and looks for counts greater than one.  If there are any counts greater than one, "error" will be displayed for that event within the new field.  Otherwise, nothing will be displayed for the new field. &lt;/P&gt;</description>
      <pubDate>Mon, 09 Apr 2018 06:15:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-where-if-a-certain-string-is-found-in-a/m-p/136686#M37426</guid>
      <dc:creator>Nextbeat</dc:creator>
      <dc:date>2018-04-09T06:15:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a search where if a certain string is found in a log, set Status=1, else Status=0?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-where-if-a-certain-string-is-found-in-a/m-p/136687#M37427</link>
      <description>&lt;P&gt;Thanks for this! I've been trying to figure this out for about an hour and tried a bunch of other stuff.&lt;/P&gt;</description>
      <pubDate>Fri, 11 Jan 2019 21:59:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-where-if-a-certain-string-is-found-in-a/m-p/136687#M37427</guid>
      <dc:creator>garigis</dc:creator>
      <dc:date>2019-01-11T21:59:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a search where if a certain string is found in a log, set Status=1, else Status=0?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-where-if-a-certain-string-is-found-in-a/m-p/136688#M37428</link>
      <description>&lt;P&gt;Be sure to &lt;CODE&gt;UpVote&lt;/CODE&gt;!&lt;/P&gt;</description>
      <pubDate>Sat, 12 Jan 2019 01:12:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-where-if-a-certain-string-is-found-in-a/m-p/136688#M37428</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-01-12T01:12:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a search where if a certain string is found in a log, set Status=1, else Status=0?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-where-if-a-certain-string-is-found-in-a/m-p/136689#M37429</link>
      <description>&lt;P&gt;If you are more used to Splunk SPL search syntax, you could do it like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; ... | eval Status=if(searchmatch("*connected*"), 1, 0)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 18 Jun 2019 16:43:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-where-if-a-certain-string-is-found-in-a/m-p/136689#M37429</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-06-18T16:43:21Z</dc:date>
    </item>
  </channel>
</rss>

