<?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: Error in 'eval' command: The expression is malformed. Expected AND. in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Error-in-eval-command-The-expression-is-malformed-Expected-AND/m-p/576262#M200844</link>
    <description>&lt;P&gt;First you use ctime() to render timestamp to string then you're trying to divide the string by number. It doesn't work that way.&lt;/P&gt;&lt;P&gt;BTW, why do you want to divide by 60000?&amp;nbsp; Timestamps are in seconds.&lt;/P&gt;</description>
    <pubDate>Wed, 24 Nov 2021 22:37:19 GMT</pubDate>
    <dc:creator>PickleRick</dc:creator>
    <dc:date>2021-11-24T22:37:19Z</dc:date>
    <item>
      <title>Error in 'eval' command: The expression is malformed. Expected AND.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Error-in-eval-command-The-expression-is-malformed-Expected-AND/m-p/576244#M200832</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am trying to execute the following query but keep getting...&amp;nbsp;&lt;SPAN&gt;Error in 'eval' command: The expression is malformed. Expected AND.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;. . .&amp;nbsp;| streamstats current=f last(_time) as last_time by host | eval gap = last_time - _time | where gap &amp;gt; 50 | convert ctime(last_time) as last_time | eval refresh_seconds = (avg(last_time) / 1000) as refresh_minutes&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;What am I doing wrong?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Nov 2021 20:18:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Error-in-eval-command-The-expression-is-malformed-Expected-AND/m-p/576244#M200832</guid>
      <dc:creator>woodencraft</dc:creator>
      <dc:date>2021-11-24T20:18:45Z</dc:date>
    </item>
    <item>
      <title>Re: Error in 'eval' command: The expression is malformed. Expected AND.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Error-in-eval-command-The-expression-is-malformed-Expected-AND/m-p/576246#M200834</link>
      <description>&lt;P&gt;What are you trying to accomplish?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Nov 2021 20:47:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Error-in-eval-command-The-expression-is-malformed-Expected-AND/m-p/576246#M200834</guid>
      <dc:creator>johnhuang</dc:creator>
      <dc:date>2021-11-24T20:47:32Z</dc:date>
    </item>
    <item>
      <title>Re: Error in 'eval' command: The expression is malformed. Expected AND.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Error-in-eval-command-The-expression-is-malformed-Expected-AND/m-p/576253#M200839</link>
      <description>&lt;P&gt;avg() is a stat function, not eval one.&lt;/P&gt;&lt;P&gt;And judging by your use of "as" clause, you wanted to use stats indeed.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Nov 2021 21:26:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Error-in-eval-command-The-expression-is-malformed-Expected-AND/m-p/576253#M200839</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2021-11-24T21:26:11Z</dc:date>
    </item>
    <item>
      <title>Re: Error in 'eval' command: The expression is malformed. Expected AND.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Error-in-eval-command-The-expression-is-malformed-Expected-AND/m-p/576256#M200841</link>
      <description>&lt;P&gt;I did figure out the problem is I did not need the '&lt;SPAN&gt;as refresh_minutes' in for the eval&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Ultimately I want a table that shows time gaps &amp;gt; 50 between 2 events. I am refreshing a token every 50 minutes and I need to see those gaps in a table&lt;/P&gt;&lt;P&gt;I've changed it to this but I get no data in the time_in_minutes column.&lt;/P&gt;&lt;P&gt;. . .&amp;nbsp;| streamstats current=f last(_time) as last_time by host | eval gap = last_time - _time | where gap &amp;gt; 50 | convert ctime(last_time) as last_time | eval time_in_minutes = last_time / 60000 | table LocalTranId time_in_minutes&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="woodencraft_0-1637790336096.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/16997iEEF3DC1EE1438448/image-size/medium?v=v2&amp;amp;px=400" role="button" title="woodencraft_0-1637790336096.png" alt="woodencraft_0-1637790336096.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Nov 2021 21:48:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Error-in-eval-command-The-expression-is-malformed-Expected-AND/m-p/576256#M200841</guid>
      <dc:creator>woodencraft</dc:creator>
      <dc:date>2021-11-24T21:48:13Z</dc:date>
    </item>
    <item>
      <title>Re: Error in 'eval' command: The expression is malformed. Expected AND.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Error-in-eval-command-The-expression-is-malformed-Expected-AND/m-p/576262#M200844</link>
      <description>&lt;P&gt;First you use ctime() to render timestamp to string then you're trying to divide the string by number. It doesn't work that way.&lt;/P&gt;&lt;P&gt;BTW, why do you want to divide by 60000?&amp;nbsp; Timestamps are in seconds.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Nov 2021 22:37:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Error-in-eval-command-The-expression-is-malformed-Expected-AND/m-p/576262#M200844</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2021-11-24T22:37:19Z</dc:date>
    </item>
    <item>
      <title>Re: Error in 'eval' command: The expression is malformed. Expected AND.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Error-in-eval-command-The-expression-is-malformed-Expected-AND/m-p/576265#M200846</link>
      <description>&lt;P&gt;I figured out about not dividing by 60000. I changed to 60 and then round(time_in_minutes, 0) to get rid of the decimal places. I also took out the ctime()&lt;/P&gt;&lt;P&gt;This is what I have now:&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;. . .&amp;nbsp;| streamstats window=2 range(_time) as timediff | eval time_in_minutes = timediff / 60 | eval time_in_minutes = round(time_in_minutes, 0) | table _time LocalTranId time_in_minutes&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;Based on how I described what I want is the 'window=2' giving me what I am looking for? I scanned through events around the time of the 51 shown in the table below and I can't find any 2 events &amp;gt; 50 minutes&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="woodencraft_0-1637796499771.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/17000i524EF18837D69D25/image-size/medium?v=v2&amp;amp;px=400" role="button" title="woodencraft_0-1637796499771.png" alt="woodencraft_0-1637796499771.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It's clear I'm new at this. I've only been creating simple queries which I'm sure this is probably very simple to you and I appreciate you helping me. I've just&amp;nbsp; now realized I need to do more to get what I really need.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Nov 2021 23:39:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Error-in-eval-command-The-expression-is-malformed-Expected-AND/m-p/576265#M200846</guid>
      <dc:creator>woodencraft</dc:creator>
      <dc:date>2021-11-24T23:39:38Z</dc:date>
    </item>
    <item>
      <title>Re: Error in 'eval' command: The expression is malformed. Expected AND.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Error-in-eval-command-The-expression-is-malformed-Expected-AND/m-p/576293#M200856</link>
      <description>&lt;P&gt;You have the event immediately after, that's 51 minutes later.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PickleRick_0-1637830388179.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/17005iAACC6D665F0BCDFB/image-size/medium?v=v2&amp;amp;px=400" role="button" title="PickleRick_0-1637830388179.png" alt="PickleRick_0-1637830388179.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Remember that splunk generally* returns search events in reverse chronological order (from most recent to oldest), so - unless you resort them - you're calculating streamstats from the most recent events. Which means that it's the difference from the previous event _in the event list_, not chronologically. So - in your case - you're calculating the difference from the event that happened immediately _after_ the one you're analysing.&lt;/P&gt;&lt;P&gt;*There are some additional factors affecting event order if you're using commands like append or multisearch.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Nov 2021 08:56:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Error-in-eval-command-The-expression-is-malformed-Expected-AND/m-p/576293#M200856</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2021-11-25T08:56:29Z</dc:date>
    </item>
  </channel>
</rss>

