<?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: Why is my eval search returning empty field results? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Why-is-my-eval-search-returning-empty-field-results/m-p/254280#M76139</link>
    <description>&lt;P&gt;What do you see if you leave off the eval and table commands? How about just leaving off the eval?  Sounds to me like the strptime function isn't matching the values in "Created", which should have strings looking like "24:01".  If this is true then the effect of the eval command would be to set the Created field null, which you are then putting into a table. Test this:&lt;BR /&gt;
...eval Created2=strptime(Created, "%d:%m") | eval Created2=coalesce(Created2,"FOOBAR!")|table Created Created2&lt;/P&gt;</description>
    <pubDate>Thu, 26 Jan 2017 14:37:14 GMT</pubDate>
    <dc:creator>GregZillgitt</dc:creator>
    <dc:date>2017-01-26T14:37:14Z</dc:date>
    <item>
      <title>Why is my eval search returning empty field results?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-my-eval-search-returning-empty-field-results/m-p/254279#M76138</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;I have searched some of the previous questions, but none seem to pertain to my problem. I am running the below search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | jirarest jqlsearch "type = *(typename)* AND \"Environment Type\" = *(environmenttype)* AND (\"Environment Name\" in (*(environmentname1)*, *(environmentname2)*, *(environmentname3)*) OR \"Environment Name\" is EMPTY) AND createdDate &amp;gt;= startOfMonth()" | eval Created=strptime(Created, "%d:%m") | table Created
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The search returns table rows as if it is finding results, but all of the rows are blank. The field I am evaluating is a date/time field, but it has more data than I need, and I am also trying to present it in a more easily readable format.&lt;/P&gt;

&lt;P&gt;Any insight anyone may have will be greatly appreciated. Thank You.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jan 2017 01:45:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-my-eval-search-returning-empty-field-results/m-p/254279#M76138</guid>
      <dc:creator>ryanmcdermott12</dc:creator>
      <dc:date>2017-01-26T01:45:34Z</dc:date>
    </item>
    <item>
      <title>Re: Why is my eval search returning empty field results?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-my-eval-search-returning-empty-field-results/m-p/254280#M76139</link>
      <description>&lt;P&gt;What do you see if you leave off the eval and table commands? How about just leaving off the eval?  Sounds to me like the strptime function isn't matching the values in "Created", which should have strings looking like "24:01".  If this is true then the effect of the eval command would be to set the Created field null, which you are then putting into a table. Test this:&lt;BR /&gt;
...eval Created2=strptime(Created, "%d:%m") | eval Created2=coalesce(Created2,"FOOBAR!")|table Created Created2&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jan 2017 14:37:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-my-eval-search-returning-empty-field-results/m-p/254280#M76139</guid>
      <dc:creator>GregZillgitt</dc:creator>
      <dc:date>2017-01-26T14:37:14Z</dc:date>
    </item>
    <item>
      <title>Re: Why is my eval search returning empty field results?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-my-eval-search-returning-empty-field-results/m-p/254281#M76140</link>
      <description>&lt;P&gt;Share some sample values that comes under field Created from below query.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | jirarest jqlsearch "type = *(typename)* AND \"Environment Type\" = *(environmenttype)* AND (\"Environment Name\" in (*(environmentname1)*, *(environmentname2)*, *(environmentname3)*) OR \"Environment Name\" is EMPTY) AND createdDate &amp;gt;= startOfMonth()" | table Created
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 26 Jan 2017 15:58:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-my-eval-search-returning-empty-field-results/m-p/254281#M76140</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-01-26T15:58:08Z</dc:date>
    </item>
    <item>
      <title>Re: Why is my eval search returning empty field results?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-my-eval-search-returning-empty-field-results/m-p/254282#M76141</link>
      <description>&lt;P&gt;Thank you Greg. I tried your suggestion, and here is a sample of the output:&lt;/P&gt;

&lt;P&gt;2017-01-03T13:01:03.000+0000    FOOBAR!&lt;BR /&gt;
2017-01-11T17:06:49.000+0000    FOOBAR!&lt;BR /&gt;
2017-01-12T00:51:57.000+0000    FOOBAR!&lt;BR /&gt;
2017-01-04T17:30:10.000+0000    FOOBAR!&lt;BR /&gt;
2017-01-03T17:43:37.000+0000    FOOBAR!&lt;BR /&gt;
2017-01-04T08:10:10.000+0000    FOOBAR!&lt;/P&gt;

&lt;P&gt;The problem is the format of "Created".  I'm trying to present the date in a format more like DD-MON-YYYY. The reasoning behind it is that; &lt;BR /&gt;
1. It would be easier for people to read.&lt;BR /&gt;
2. I plan to eventually display the output in a chart. &lt;/P&gt;

&lt;P&gt;The I cannot use the _time value from Splunk to build the chart, so I need to use the Created field as my X-axis.&lt;/P&gt;

&lt;P&gt;Thank you for your help.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jan 2017 16:21:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-my-eval-search-returning-empty-field-results/m-p/254282#M76141</guid>
      <dc:creator>ryanmcdermott12</dc:creator>
      <dc:date>2017-01-26T16:21:07Z</dc:date>
    </item>
    <item>
      <title>Re: Why is my eval search returning empty field results?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-my-eval-search-returning-empty-field-results/m-p/254283#M76142</link>
      <description>&lt;P&gt;Thank you for your reply. Here is an example of some of the output of the Created Field:&lt;/P&gt;

&lt;P&gt;2017-01-03T13:01:03.000+0000&lt;BR /&gt;
2017-01-11T17:06:49.000+0000&lt;BR /&gt;
2017-01-12T00:51:57.000+0000&lt;BR /&gt;
2017-01-04T17:30:10.000+0000&lt;BR /&gt;
2017-01-03T17:43:37.000+0000&lt;BR /&gt;
2017-01-04T08:10:10.000+0000&lt;/P&gt;

&lt;P&gt;I am trying to reformat this field to show something like DD-MON-YYYY or DD-MM-YYYY.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jan 2017 16:22:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-my-eval-search-returning-empty-field-results/m-p/254283#M76142</guid>
      <dc:creator>ryanmcdermott12</dc:creator>
      <dc:date>2017-01-26T16:22:40Z</dc:date>
    </item>
    <item>
      <title>Re: Why is my eval search returning empty field results?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-my-eval-search-returning-empty-field-results/m-p/254284#M76143</link>
      <description>&lt;P&gt;Try this: &lt;/P&gt;

&lt;P&gt;| jirarest jqlsearch "type = &lt;EM&gt;(typename)&lt;/EM&gt; AND \"Environment Type\" = &lt;EM&gt;(environmenttype)&lt;/EM&gt; AND (\"Environment Name\" in (&lt;EM&gt;(environmentname1)&lt;/EM&gt;, &lt;EM&gt;(environmentname2)&lt;/EM&gt;, &lt;EM&gt;(environmentname3)&lt;/EM&gt;) OR \"Environment Name\" is EMPTY) AND createdDate &amp;gt;= startOfMonth()" | eval Created=strptime(Created,"%Y-%m-%dT%H:%M:%S.%3N%z") | eval _time=Created &lt;/P&gt;

&lt;P&gt;That'll take care of charting. To get from _time to your preferred display format: &lt;/P&gt;

&lt;P&gt;strftime(_time,"%d-%b-%Y")&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jan 2017 17:32:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-my-eval-search-returning-empty-field-results/m-p/254284#M76143</guid>
      <dc:creator>GregZillgitt</dc:creator>
      <dc:date>2017-01-26T17:32:04Z</dc:date>
    </item>
    <item>
      <title>Re: Why is my eval search returning empty field results?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-my-eval-search-returning-empty-field-results/m-p/254285#M76144</link>
      <description>&lt;P&gt;Ahhhhh. You're awesome! That worked! Thank you so much for the help. &lt;/P&gt;

&lt;P&gt;I'm curious, what is causing the field not to be directly formatted with just the strptime command?&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jan 2017 18:59:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-my-eval-search-returning-empty-field-results/m-p/254285#M76144</guid>
      <dc:creator>ryanmcdermott12</dc:creator>
      <dc:date>2017-01-26T18:59:56Z</dc:date>
    </item>
    <item>
      <title>Re: Why is my eval search returning empty field results?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-my-eval-search-returning-empty-field-results/m-p/254286#M76145</link>
      <description>&lt;P&gt;If I understand your question:&lt;/P&gt;

&lt;P&gt;strptime() creates a &lt;EM&gt;time object&lt;/EM&gt; from a string. For output or string conversion, you format time objects  via strftime() or the convert command. So...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Created=strptime(Created,"%Y-%m-%dT%H:%M:%S.%3N%z")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;... basically takes the current value of "Created", which is a string, and replaces that field with a time object. The time object doesn't have a "format" per se.&lt;/P&gt;

&lt;P&gt;Here are a few example conversions:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;eval dayofweek=strftime(_time,"%w")
eval hour=strftime(_time,"%H") 
eval yymmdd=strftime(tstamp,"%y%m%d")
eval minute=strftime(_time,"%y%m%d%h%M")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;truncate time to the current minute, then convert to epoch format string:&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;eval trunc_minute=strftime(strptime(strftime(_time,"%y%m%d%H%M"),"%y%m%d%H%M"),"%s")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;the more succinct way:&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;eval trunc_minute=strftime(relative_time(_time, "@m"),"%s")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 26 Jan 2017 20:41:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-my-eval-search-returning-empty-field-results/m-p/254286#M76145</guid>
      <dc:creator>GregZillgitt</dc:creator>
      <dc:date>2017-01-26T20:41:57Z</dc:date>
    </item>
  </channel>
</rss>

