<?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: Eval function weird return in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Eval-function-weird-return/m-p/224019#M188262</link>
    <description>&lt;PRE&gt;&lt;CODE&gt;  index=gamification AND sourcetype = stash   | eval isFailure!=if(searchmatch("gamification"),1,0) | table isFailure
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Why table isFailure never show any results?&lt;/P&gt;

&lt;P&gt;because you're != instead of = .  Eval is a generating command... in this case your logic is saying... dont generate anything.&lt;/P&gt;

&lt;P&gt;You want something like this instead:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  index=gamification AND sourcetype = stash   | eval isFailure=if(searchmatch("gamification"),1,0) | table isFailure
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This one fails because of spacing:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=gamification  |  spath 
                     | rename gamification.action.name as actionId,
                               gamification.user.id as playerId, 
                               _indextime as date,
                               gamification.origin.name as origin 
                      | where origin="sparxea" 
                      | eval updated=[
                             search index=gamification AND sourcetype = stash 
                             | eval isFailure=if(searchmatch("gamification"),1,0) 
                             | eval updated=if(isFailure =="0",now(),_indextime) 
                             | return $updated ] 
                      | eval updated = strftime(updated,"%Y.%m.%d %H:%M.%S") 
                      | where date &amp;gt; updated                     
                      | table updated,date,playerId,actionId 
                      |  script python gamification -t playlyfe -c action -m p 
                      | collect index="gamification"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Should be like this instead:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=gamification  |  spath 
                     | rename gamification.action.name as actionId,
                               gamification.user.id as playerId, 
                               _indextime as date,
                               gamification.origin.name as origin 
                      | where origin="sparxea" 
                      | eval updated=[
                             search index=gamification AND sourcetype=stash 
                             | eval isFailure=if(searchmatch("gamification"),1,0) 
                             | eval updated=if(isFailure=="0",now(),_indextime) 
                             | return $updated ] 
                      | eval updated=strftime(updated,"%Y.%m.%d %H:%M.%S") 
                      | where date &amp;gt; updated                     
                      | table updated,date,playerId,actionId 
                      | script python gamification -t playlyfe -c action -m p 
                      | collect index="gamification"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I fixed spacing here:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;                             search index=gamification AND sourcetype=stash 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And here:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;                             | eval updated=if(isFailure=="0",now(),_indextime) 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And here:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;                      | eval updated=strftime(updated,"%Y.%m.%d %H:%M.%S") 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Same with this one:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  | eval updated=[ search index=gamification AND sourcetype=stash 
                              | eval updated=if(isnotnull(extractfield),_indextime,now())
                              | return $updated ] 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 12 Aug 2016 16:52:18 GMT</pubDate>
    <dc:creator>jkat54</dc:creator>
    <dc:date>2016-08-12T16:52:18Z</dc:date>
    <item>
      <title>Eval function weird return</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Eval-function-weird-return/m-p/224018#M188261</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;I am doing a search and i know sometimes it will return no results.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=gamification AND sourcetype = stash   | eval isFailure!=if(searchmatch("gamification"),1,0) | table isFailure
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Why table isFailure never show any results?&lt;/P&gt;

&lt;P&gt;Another exemple is my concrete query :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=gamification  |  spath 
                    | rename gamification.action.name as actionId,
                              gamification.user.id as playerId, 
                              _indextime as date,
                              gamification.origin.name as origin 
                     | where origin="sparxea" 
                     | eval updated=[
                            search index=gamification AND sourcetype = stash 
                            | eval isFailure=if(searchmatch("gamification"),1,0) 
                            | eval updated=if(isFailure =="0",now(),_indextime) 
                            | return $updated ] 
                     | eval updated = strftime(updated,"%Y.%m.%d %H:%M.%S") 
                     | where date &amp;gt; updated                     
                     | table updated,date,playerId,actionId 
                     |  script python gamification -t playlyfe -c action -m p 
                     | collect index="gamification"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Here i am testing if i have event results in a subsearch, if i have, i take the indextime of the first result, if not, the actual time.&lt;BR /&gt;
With this search, i got an error : eval dest_key = expression&lt;/P&gt;

&lt;P&gt;Here is why i am testing the result count : &lt;A href="https://answers.splunk.com/answers/176466/how-to-use-eval-if-there-is-no-result-from-the-bas-1.html"&gt;https://answers.splunk.com/answers/176466/how-to-use-eval-if-there-is-no-result-from-the-bas-1.html&lt;/A&gt;. This link seemed to be a possible solution to my problem.&lt;/P&gt;

&lt;P&gt;At begining, i was doing the subsearsh like this, But it gives me the same error : eval dest_key = expression&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | eval updated=[ search index=gamification AND sourcetype = stash 
                             | eval updated=if( isnotnull( extractfield ),_indextime,now())
                             | return $updated ] 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I really need help please. Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 12 Aug 2016 16:30:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Eval-function-weird-return/m-p/224018#M188261</guid>
      <dc:creator>gamification</dc:creator>
      <dc:date>2016-08-12T16:30:56Z</dc:date>
    </item>
    <item>
      <title>Re: Eval function weird return</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Eval-function-weird-return/m-p/224019#M188262</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;  index=gamification AND sourcetype = stash   | eval isFailure!=if(searchmatch("gamification"),1,0) | table isFailure
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Why table isFailure never show any results?&lt;/P&gt;

&lt;P&gt;because you're != instead of = .  Eval is a generating command... in this case your logic is saying... dont generate anything.&lt;/P&gt;

&lt;P&gt;You want something like this instead:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  index=gamification AND sourcetype = stash   | eval isFailure=if(searchmatch("gamification"),1,0) | table isFailure
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This one fails because of spacing:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=gamification  |  spath 
                     | rename gamification.action.name as actionId,
                               gamification.user.id as playerId, 
                               _indextime as date,
                               gamification.origin.name as origin 
                      | where origin="sparxea" 
                      | eval updated=[
                             search index=gamification AND sourcetype = stash 
                             | eval isFailure=if(searchmatch("gamification"),1,0) 
                             | eval updated=if(isFailure =="0",now(),_indextime) 
                             | return $updated ] 
                      | eval updated = strftime(updated,"%Y.%m.%d %H:%M.%S") 
                      | where date &amp;gt; updated                     
                      | table updated,date,playerId,actionId 
                      |  script python gamification -t playlyfe -c action -m p 
                      | collect index="gamification"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Should be like this instead:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=gamification  |  spath 
                     | rename gamification.action.name as actionId,
                               gamification.user.id as playerId, 
                               _indextime as date,
                               gamification.origin.name as origin 
                      | where origin="sparxea" 
                      | eval updated=[
                             search index=gamification AND sourcetype=stash 
                             | eval isFailure=if(searchmatch("gamification"),1,0) 
                             | eval updated=if(isFailure=="0",now(),_indextime) 
                             | return $updated ] 
                      | eval updated=strftime(updated,"%Y.%m.%d %H:%M.%S") 
                      | where date &amp;gt; updated                     
                      | table updated,date,playerId,actionId 
                      | script python gamification -t playlyfe -c action -m p 
                      | collect index="gamification"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I fixed spacing here:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;                             search index=gamification AND sourcetype=stash 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And here:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;                             | eval updated=if(isFailure=="0",now(),_indextime) 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And here:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;                      | eval updated=strftime(updated,"%Y.%m.%d %H:%M.%S") 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Same with this one:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  | eval updated=[ search index=gamification AND sourcetype=stash 
                              | eval updated=if(isnotnull(extractfield),_indextime,now())
                              | return $updated ] 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 12 Aug 2016 16:52:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Eval-function-weird-return/m-p/224019#M188262</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2016-08-12T16:52:18Z</dc:date>
    </item>
    <item>
      <title>Re: Eval function weird return</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Eval-function-weird-return/m-p/224020#M188263</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;Thanks for you answer.&lt;BR /&gt;
I try it soon and give a reply !&lt;/P&gt;</description>
      <pubDate>Fri, 12 Aug 2016 19:55:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Eval-function-weird-return/m-p/224020#M188263</guid>
      <dc:creator>gamification</dc:creator>
      <dc:date>2016-08-12T19:55:06Z</dc:date>
    </item>
    <item>
      <title>Re: Eval function weird return</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Eval-function-weird-return/m-p/224021#M188264</link>
      <description>&lt;P&gt;Hello ,&lt;/P&gt;

&lt;P&gt;I tried your solutions.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=gamification AND sourcetype = stash   | eval isFailure=if(searchmatch("gamification"),1,0) | table isFailure
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;It gives me no result found.&lt;/P&gt;

&lt;P&gt;The main query with your spacing fixes still give me the same error : eval dest_key = expression&lt;/P&gt;</description>
      <pubDate>Mon, 15 Aug 2016 11:29:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Eval-function-weird-return/m-p/224021#M188264</guid>
      <dc:creator>gamification</dc:creator>
      <dc:date>2016-08-15T11:29:16Z</dc:date>
    </item>
    <item>
      <title>Re: Eval function weird return</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Eval-function-weird-return/m-p/224022#M188265</link>
      <description>&lt;P&gt;I see a space on both sides of  your equals ( = ) still.  Did you try without that?&lt;/P&gt;

&lt;P&gt;I think this is the problem:&lt;/P&gt;

&lt;P&gt;| eval isFailure=if(search match("gamification"),1,0) &lt;/P&gt;

&lt;P&gt;Should be this instead&lt;/P&gt;

&lt;P&gt;| eval isFailure=if(match(gasification,"REGEX"),1,0) &lt;/P&gt;

&lt;P&gt;And I don't know your regex.  What if you just remove this one eval?&lt;/P&gt;</description>
      <pubDate>Mon, 15 Aug 2016 12:03:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Eval-function-weird-return/m-p/224022#M188265</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2016-08-15T12:03:08Z</dc:date>
    </item>
    <item>
      <title>Re: Eval function weird return</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Eval-function-weird-return/m-p/224023#M188266</link>
      <description>&lt;P&gt;Actually the problem is in my main query, &lt;BR /&gt;
sometimes the subsearch return events, sometimes not. &lt;BR /&gt;
What i want to achieve is depending if i find result or not, it gives me different date.&lt;BR /&gt;
Here the change i did in the subsearch ( it's what i want to achieve since the begining).&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;search index=gamification AND sourcetype= stash
                              | eval origin=originUpdate
                              | where origin="sparxea"
                              | eval time = _indextime
                              | eval updated=if(isnull(time),now(),_indextime) 
                              | return $updated
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Even if i should always return a date because of this line &lt;CODE&gt;| eval updated=if(isnull(time),now(),_indextime)&lt;/CODE&gt;&lt;BR /&gt;
eval function give me error  eval dest_key = expression because when no events are found, eval is unable to generate values to return. I can't figure how to do it.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Aug 2016 12:06:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Eval-function-weird-return/m-p/224023#M188266</guid>
      <dc:creator>gamification</dc:creator>
      <dc:date>2016-08-16T12:06:15Z</dc:date>
    </item>
  </channel>
</rss>

