<?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: what is wrong with these evals.... in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/what-is-wrong-with-these-evals/m-p/747894#M241909</link>
    <description>&lt;P&gt;sometimes in this field i get an extra space (bold) so we had to add this line and an extra space in the calculated field also - i have to take 2 scenarios and for that we added this line&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;| rex mode=sed field=ClintReqRcvdTime "s/: /:/"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Wed 4 Jun 2025 17:16:02&amp;nbsp; &lt;STRONG&gt;:161&lt;/STRONG&gt; EDT&lt;BR /&gt;Mon 2 Jun 2025 02:52:50&amp;nbsp; &lt;STRONG&gt;:298&lt;/STRONG&gt; EDT&lt;BR /&gt;Mon 9 Jun 2025 16:11:05&amp;nbsp; &lt;STRONG&gt;:860&lt;/STRONG&gt; EDT&lt;/P&gt;&lt;P&gt;Tue 10 Jun 2025 14:32:26:243 EDT&lt;BR /&gt;Wed 11 Jun 2025 13:10:32:515 EDT&lt;BR /&gt;Wed 11 Jun 2025 17:37:10:008 EDT&lt;/P&gt;&lt;P&gt;in the calc field when i use the format - do i have to specify the space for&amp;nbsp; &lt;STRONG&gt;:161 like&lt;BR /&gt;&lt;/STRONG&gt;eval date_only=strftime(strptime(ClintReqRcvdTime, "%a %d %b %Y %H:%M:%S&amp;nbsp; &lt;STRONG&gt;:%3N&lt;/STRONG&gt; %Z"), "%m/%d/%Y")&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 12 Jun 2025 17:37:18 GMT</pubDate>
    <dc:creator>Raj_Splunk_Ing</dc:creator>
    <dc:date>2025-06-12T17:37:18Z</dc:date>
    <item>
      <title>what is wrong with these evals....</title>
      <link>https://community.splunk.com/t5/Splunk-Search/what-is-wrong-with-these-evals/m-p/747893#M241908</link>
      <description>&lt;P&gt;Hi, I have this search query where i aggregate using the stats and sum by few fields...&lt;/P&gt;&lt;P&gt;When I run the query in splunk portal i see the data in the events tab but not in the stats tab. So I used the &lt;STRONG&gt;fillnull&amp;nbsp;&lt;/STRONG&gt;to see which fields are causing the problem. I noticed that these fields where i am using eval are causing the issue as i see 0 inside these columns after using fillnull&lt;/P&gt;&lt;P&gt;| eval status_codes_only=if( (status_code&amp;gt;=200 and status_code&amp;lt;300) or status_code&amp;gt;=400,1,0)&lt;BR /&gt;| search status_codes_only=1&lt;BR /&gt;| rex mode=sed field=ClintReqRcvdTime "s/: /:/"&lt;BR /&gt;| eval date_only=strftime(strptime(ClintReqRcvdTime, "%a %d %b %Y %H:%M:%S :%3N %Z"), "%m/%d/%Y")&lt;BR /&gt;| eval year_only=strftime(strptime(ClintReqRcvdTime, "%a %d %b %Y %H:%M:%S :%3N %Z"), "%Y")&lt;BR /&gt;| eval month_only=strftime(strptime(ClintReqRcvdTime, "%a %d %b %Y %H:%M:%S :%3N %Z"), "%b")&lt;BR /&gt;| eval week_only=floor(tonumber(strftime(strptime(ClintReqRcvdTime, "%a %d %b %Y %H:%M:%S :%3N %Z"), "%d"))/7+1)&lt;BR /&gt;| eval TwoXXonly=if(status_code&amp;gt;=200 and status_code &amp;lt;300,1,0)&lt;BR /&gt;| eval FourXXonly=if(status_code&amp;gt;=400 and status_code &amp;lt;500,1,0)&lt;BR /&gt;| eval FiveXXonly=if(status_code&amp;gt;=500 and status_code &amp;lt;600,1,0)&lt;BR /&gt;| fillnull date_only,year_only,month_only,week_only,organization,clientId,proxyBasePath,api_name,environment,Total_2xx,Total_4xx,Total_5xx&lt;BR /&gt;| stats sum(TwoXXonly) as Total_2xx,sum(FourXXonly) as Total_4xx,sum(FiveXXonly) as Total_5xx by date_only,year_only,month_only,week_only,organization,clientId,proxyBasePath,api_name,environment&lt;BR /&gt;| table date_only,year_only,month_only,week_only,organization,clientId,proxyBasePath,api_name,environment,Total_2xx,Total_4xx,Total_5xx&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Raj_Splunk_Ing_0-1749744902983.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/39362i4813632F9C19EC6E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Raj_Splunk_Ing_0-1749744902983.png" alt="Raj_Splunk_Ing_0-1749744902983.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;when i look at the field that i used to get the date_only, year_only, week_only column - i see data something like this in the events&lt;BR /&gt;Wed 11 Jun 2025 22:57:34:396 EDT&lt;BR /&gt;Wed 11 Jun 2025 22:56:43:254 EDT&lt;BR /&gt;Wed 11 Jun 2025 22:56:34:466 EDT&lt;BR /&gt;Wed 11 Jun 2025 22:56:28:404 EDT&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Jun 2025 16:23:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/what-is-wrong-with-these-evals/m-p/747893#M241908</guid>
      <dc:creator>Raj_Splunk_Ing</dc:creator>
      <dc:date>2025-06-12T16:23:58Z</dc:date>
    </item>
    <item>
      <title>Re: what is wrong with these evals....</title>
      <link>https://community.splunk.com/t5/Splunk-Search/what-is-wrong-with-these-evals/m-p/747894#M241909</link>
      <description>&lt;P&gt;sometimes in this field i get an extra space (bold) so we had to add this line and an extra space in the calculated field also - i have to take 2 scenarios and for that we added this line&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;| rex mode=sed field=ClintReqRcvdTime "s/: /:/"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Wed 4 Jun 2025 17:16:02&amp;nbsp; &lt;STRONG&gt;:161&lt;/STRONG&gt; EDT&lt;BR /&gt;Mon 2 Jun 2025 02:52:50&amp;nbsp; &lt;STRONG&gt;:298&lt;/STRONG&gt; EDT&lt;BR /&gt;Mon 9 Jun 2025 16:11:05&amp;nbsp; &lt;STRONG&gt;:860&lt;/STRONG&gt; EDT&lt;/P&gt;&lt;P&gt;Tue 10 Jun 2025 14:32:26:243 EDT&lt;BR /&gt;Wed 11 Jun 2025 13:10:32:515 EDT&lt;BR /&gt;Wed 11 Jun 2025 17:37:10:008 EDT&lt;/P&gt;&lt;P&gt;in the calc field when i use the format - do i have to specify the space for&amp;nbsp; &lt;STRONG&gt;:161 like&lt;BR /&gt;&lt;/STRONG&gt;eval date_only=strftime(strptime(ClintReqRcvdTime, "%a %d %b %Y %H:%M:%S&amp;nbsp; &lt;STRONG&gt;:%3N&lt;/STRONG&gt; %Z"), "%m/%d/%Y")&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Jun 2025 17:37:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/what-is-wrong-with-these-evals/m-p/747894#M241909</guid>
      <dc:creator>Raj_Splunk_Ing</dc:creator>
      <dc:date>2025-06-12T17:37:18Z</dc:date>
    </item>
    <item>
      <title>Re: what is wrong with these evals....</title>
      <link>https://community.splunk.com/t5/Splunk-Search/what-is-wrong-with-these-evals/m-p/747896#M241910</link>
      <description>&lt;P&gt;The &lt;FONT face="courier new,courier"&gt;strptime&lt;/FONT&gt; function will return &lt;FONT face="courier new,courier"&gt;null&lt;/FONT&gt; when the format string does not match the value in the field.&amp;nbsp; Other than meta-characters ('%a', etc.) the format string must match *exactly*, including spaces.&amp;nbsp; That means including spaces in the format string if they are expected in the data.&lt;/P&gt;&lt;P&gt;That said, the &lt;FONT face="courier new,courier"&gt;sed&lt;/FONT&gt; command should be removing the extra spaces so no accommodation in &lt;FONT face="courier new,courier"&gt;strptime&lt;/FONT&gt; should be needed.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Jun 2025 17:49:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/what-is-wrong-with-these-evals/m-p/747896#M241910</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2025-06-12T17:49:27Z</dc:date>
    </item>
    <item>
      <title>Re: what is wrong with these evals....</title>
      <link>https://community.splunk.com/t5/Splunk-Search/what-is-wrong-with-these-evals/m-p/747897#M241911</link>
      <description>&lt;P&gt;Thank you Rich, If i just remove the extra space that is in the strp function i should be ok&lt;BR /&gt;&lt;SPAN&gt;eval date_only=strftime(strptime(ClintReqRcvdTime, "%a %d %b %Y %H:%M:%S&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;:%3N&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;%Z"), "%m/%d/%Y")&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;let me test this - thanks alot&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Jun 2025 17:55:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/what-is-wrong-with-these-evals/m-p/747897#M241911</guid>
      <dc:creator>Raj_Splunk_Ing</dc:creator>
      <dc:date>2025-06-12T17:55:29Z</dc:date>
    </item>
    <item>
      <title>Re: what is wrong with these evals....</title>
      <link>https://community.splunk.com/t5/Splunk-Search/what-is-wrong-with-these-evals/m-p/747918#M241917</link>
      <description>&lt;P&gt;Your sed command is wrong for your example data. The space is&amp;nbsp;&lt;STRONG&gt;before&lt;/STRONG&gt; the colon in your example. but your sed is replacing the space&amp;nbsp;&lt;STRONG&gt;after&lt;/STRONG&gt; the colon.&lt;/P&gt;&lt;P&gt;Your example data as posted seems to have two spaces before the colon, at least if I copy/paste your data there are two spaces.&lt;/P&gt;&lt;P&gt;Note also that you could do the fixup and strptime once, e.g.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults format=csv data="ClintReqRcvdTime
Wed 4 Jun 2025 17:16:02  :161 EDT
Mon 2 Jun 2025 02:52:50  :298 EDT
Mon 9 Jun 2025 16:11:05  :860 EDT"

```  This is what you want - above is just constructing an example dataset ```

| eval t=strptime(replace(ClintReqRcvdTime, "\s*:\s*", ":"), "%a %d %b %Y %H:%M:%S:%Q %Z")
| eval date_only=strftime(t, "%m/%d/%Y")
| eval year_only=strftime(t, "%Y")
| eval month_only=strftime(t, "%b")
| eval week_only=floor(tonumber(strftime(t, "%d"))/7+1)&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 13 Jun 2025 04:50:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/what-is-wrong-with-these-evals/m-p/747918#M241917</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2025-06-13T04:50:27Z</dc:date>
    </item>
    <item>
      <title>Re: what is wrong with these evals....</title>
      <link>https://community.splunk.com/t5/Splunk-Search/what-is-wrong-with-these-evals/m-p/747943#M241928</link>
      <description>&lt;P&gt;as an example&amp;nbsp; - there is only 1 space - it might be copy paste error that has 2 spaces - but it is only 1 space&amp;nbsp; in it. Its only some times i get this extra space&lt;/P&gt;&lt;P&gt;this is how i get the values in it&lt;/P&gt;&lt;P&gt;Wed 4 Jun 2025 17:16:02&amp;nbsp; &lt;STRONG&gt;:161&lt;/STRONG&gt; EDT&amp;nbsp; - sometimes extra space&lt;/P&gt;&lt;P&gt;Wed 4 Jun 2025 17:16:02&amp;nbsp;&lt;STRONG&gt;:161&lt;/STRONG&gt; EDT&amp;nbsp; - sometimes extra &lt;STRONG&gt;No&lt;/STRONG&gt; extra space&lt;/P&gt;&lt;P&gt;why do we have 2 \s*: and \s*&amp;nbsp; - i think we just need 1 \s*:&lt;/P&gt;&lt;P&gt;t=strptime(replace(ClintReqRcvdTime, "\s*:\s*", ":"), "%a %d %b %Y %H:%M:%S:%Q %Z")&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jun 2025 14:29:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/what-is-wrong-with-these-evals/m-p/747943#M241928</guid>
      <dc:creator>Raj_Splunk_Ing</dc:creator>
      <dc:date>2025-06-13T14:29:59Z</dc:date>
    </item>
    <item>
      <title>Re: what is wrong with these evals....</title>
      <link>https://community.splunk.com/t5/Splunk-Search/what-is-wrong-with-these-evals/m-p/747976#M241931</link>
      <description>&lt;P&gt;I put a \s before and after the : because your example showed the space before, but your sed was replacing a space after.&lt;/P&gt;&lt;P&gt;Put the \s* where the space can be.&lt;/P&gt;&lt;P&gt;If you want to post examples, use the code tag option in the editor &amp;lt;/&amp;gt; so you can see exactly what you are posting.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Like this...&lt;/LI-CODE&gt;</description>
      <pubDate>Sun, 15 Jun 2025 23:01:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/what-is-wrong-with-these-evals/m-p/747976#M241931</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2025-06-15T23:01:09Z</dc:date>
    </item>
  </channel>
</rss>

