<?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: dbxquery eval _time as column in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/dbxquery-eval-time-as-column/m-p/375757#M110404</link>
    <description>&lt;P&gt;I just edited my answer.&lt;/P&gt;

&lt;P&gt;You don't need to do strftime if your value is already in epoch format.  I'm sorry I missed this earlier, I was responding from my phone and didn't realize it was strftime instead of strptime to convert &lt;EM&gt;to&lt;/EM&gt; epoch.&lt;/P&gt;</description>
    <pubDate>Thu, 15 Feb 2018 18:34:55 GMT</pubDate>
    <dc:creator>micahkemp</dc:creator>
    <dc:date>2018-02-15T18:34:55Z</dc:date>
    <item>
      <title>dbxquery eval _time as column</title>
      <link>https://community.splunk.com/t5/Splunk-Search/dbxquery-eval-time-as-column/m-p/375754#M110401</link>
      <description>&lt;P&gt;Hi all, &lt;/P&gt;

&lt;P&gt;I am trying to set the values in column &lt;CODE&gt;insertepoch&lt;/CODE&gt; in a mysql database to be the new &lt;CODE&gt;_time&lt;/CODE&gt; index in splunk to be able to &lt;CODE&gt;timechart&lt;/CODE&gt;. The following search is returning with 0 results. In fact, when I take the timechart off, the query runs, however, I don't see it working and I'm not able to find anything in the way of a solution to this. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| dbxquery shortnames=1 connection="myconn" query="SELECT * FROM `mydb`.`mytable` ORDER BY Id DESC Limit 200" |
eval insertepoch=strftime(insertepoch, "%Y-%m-%d %H:%M:%S.%N") |
eval _time=insertepoch | timechart span=1h count(_raw)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Please help! Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 14 Feb 2018 23:32:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/dbxquery-eval-time-as-column/m-p/375754#M110401</guid>
      <dc:creator>zhatsispgx</dc:creator>
      <dc:date>2018-02-14T23:32:37Z</dc:date>
    </item>
    <item>
      <title>Re: dbxquery eval _time as column</title>
      <link>https://community.splunk.com/t5/Splunk-Search/dbxquery-eval-time-as-column/m-p/375755#M110402</link>
      <description>&lt;P&gt;Disclaimer: I can’t test this right now&lt;/P&gt;

&lt;P&gt;Try explicitly defining your needed fieldnames in your query, including &lt;CODE&gt;insertedtime&lt;/CODE&gt; (which seems to be all that is needed for your example).&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | dbxquery shortnames=1 connection="myconn" query="SELECT insertepoch FROM `mydb`.`mytable` ORDER BY Id DESC Limit 200"
 | eval _time=insertepoch
 | timechart span=1h count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If that doesn’t work, please add the output of:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | dbxquery shortnames=1 connection="myconn" query="SELECT insertepoch FROM `mydb`.`mytable` ORDER BY Id DESC Limit 200" |
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 15 Feb 2018 02:00:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/dbxquery-eval-time-as-column/m-p/375755#M110402</guid>
      <dc:creator>micahkemp</dc:creator>
      <dc:date>2018-02-15T02:00:59Z</dc:date>
    </item>
    <item>
      <title>Re: dbxquery eval _time as column</title>
      <link>https://community.splunk.com/t5/Splunk-Search/dbxquery-eval-time-as-column/m-p/375756#M110403</link>
      <description>&lt;P&gt;Tested explicitly defining the fieldnames in the query and it didn't work.   The output of &lt;CODE&gt;| dbxquery shortnames=1 connection="myconn" query="SELECT insertepoch FROM mydb.mytable ORDER BY Id DESC Limit 200" |&lt;/CODE&gt;   is an epoch timeformat which gets converted  with  &lt;CODE&gt;eval insertepoch=strftime(insertepoch, "%Y-%m-%d %H:%M:%S.%N") |&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;sample output before eval:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;1518714601
1518711331
1518710573
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;sample output after eval:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;2018-02-15 11:15:02.000000000
2018-02-15 10:10:01.000000000
2018-02-15 09:15:31.000000000
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I am guessing this has something to do with the data not being indexed. &lt;/P&gt;</description>
      <pubDate>Thu, 15 Feb 2018 18:18:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/dbxquery-eval-time-as-column/m-p/375756#M110403</guid>
      <dc:creator>zhatsispgx</dc:creator>
      <dc:date>2018-02-15T18:18:05Z</dc:date>
    </item>
    <item>
      <title>Re: dbxquery eval _time as column</title>
      <link>https://community.splunk.com/t5/Splunk-Search/dbxquery-eval-time-as-column/m-p/375757#M110404</link>
      <description>&lt;P&gt;I just edited my answer.&lt;/P&gt;

&lt;P&gt;You don't need to do strftime if your value is already in epoch format.  I'm sorry I missed this earlier, I was responding from my phone and didn't realize it was strftime instead of strptime to convert &lt;EM&gt;to&lt;/EM&gt; epoch.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Feb 2018 18:34:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/dbxquery-eval-time-as-column/m-p/375757#M110404</guid>
      <dc:creator>micahkemp</dc:creator>
      <dc:date>2018-02-15T18:34:55Z</dc:date>
    </item>
  </channel>
</rss>

