<?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: How do you use a calculated &amp;quot;_time&amp;quot; field for a timechart query in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-use-a-calculated-quot-time-quot-field-for-a-timechart/m-p/582107#M202772</link>
    <description>&lt;P&gt;Hi Jonathan,&lt;/P&gt;&lt;P&gt;As richgalloway stated _time is and epoch that splunk automagicly convert to the format you see in the GUI. Also the _time you see in the GUI is based on your regional settings (e.g your events could be GMT+0 and _time shows the GMT+5 conversion). You can check there "real" _time value when you do something like "| eval my_time = _time", the my_time will show the epoch time (which is based on UTC).&lt;BR /&gt;&lt;BR /&gt;As for your case, if your time field is a calculated one that is not in epoch format and want to use that in a time chart you can use this:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval my_time = strptime(_time,"%Y-%m-%d %H:%M:%S,%3N")
| eval _time = my_time
| timechart span=1h count by STORE_ID&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp; You can change the span to size the time bucket you want to use.&lt;/P&gt;</description>
    <pubDate>Sat, 22 Jan 2022 01:25:40 GMT</pubDate>
    <dc:creator>diogofgm</dc:creator>
    <dc:date>2022-01-22T01:25:40Z</dc:date>
    <item>
      <title>How do you use a calculated "_time" field for a timechart query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-use-a-calculated-quot-time-quot-field-for-a-timechart/m-p/582094#M202765</link>
      <description>&lt;P&gt;I have a Splunk query that does a lot of computation and eventually returns only two calculated fields:&amp;nbsp; &lt;STRONG&gt;_time&lt;/STRONG&gt; and &lt;STRONG&gt;STORE_ID &lt;/STRONG&gt;via the &lt;STRONG&gt;table&lt;/STRONG&gt; command.&lt;/P&gt;&lt;P&gt;The&lt;STRONG&gt; _time&lt;/STRONG&gt;&amp;nbsp;field is formatted exactly like the the built-in _time field (e.g., "&lt;SPAN&gt;2022-01-17 23:50:25,897").&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I want to do a timechart showing the count of how many times each unique STORE_ID appears in a given time bucket, using my calculated &lt;STRONG&gt;_time&lt;/STRONG&gt; variable to fill the buckets.&amp;nbsp; What do I put in the &lt;STRONG&gt;timechart&lt;/STRONG&gt; clause to accomplish this?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks! Jonathan&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jan 2022 21:29:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-use-a-calculated-quot-time-quot-field-for-a-timechart/m-p/582094#M202765</guid>
      <dc:creator>jbrenner</dc:creator>
      <dc:date>2022-01-21T21:29:48Z</dc:date>
    </item>
    <item>
      <title>Re: How do you use a calculated "_time" field for a timechart query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-use-a-calculated-quot-time-quot-field-for-a-timechart/m-p/582104#M202770</link>
      <description>&lt;P&gt;The timechart command needs only the _time and one other field (STORE_ID in this case).&amp;nbsp; The catch, however, is _time must be in epoch (integer) format.&amp;nbsp; It won't work if you format it like it appears in the UI.&amp;nbsp; FTR, the built-in _time field always is in epoch form, but the UI automatically converts it to text when displayed.&lt;/P&gt;</description>
      <pubDate>Sat, 22 Jan 2022 00:59:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-use-a-calculated-quot-time-quot-field-for-a-timechart/m-p/582104#M202770</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2022-01-22T00:59:16Z</dc:date>
    </item>
    <item>
      <title>Re: How do you use a calculated "_time" field for a timechart query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-use-a-calculated-quot-time-quot-field-for-a-timechart/m-p/582107#M202772</link>
      <description>&lt;P&gt;Hi Jonathan,&lt;/P&gt;&lt;P&gt;As richgalloway stated _time is and epoch that splunk automagicly convert to the format you see in the GUI. Also the _time you see in the GUI is based on your regional settings (e.g your events could be GMT+0 and _time shows the GMT+5 conversion). You can check there "real" _time value when you do something like "| eval my_time = _time", the my_time will show the epoch time (which is based on UTC).&lt;BR /&gt;&lt;BR /&gt;As for your case, if your time field is a calculated one that is not in epoch format and want to use that in a time chart you can use this:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval my_time = strptime(_time,"%Y-%m-%d %H:%M:%S,%3N")
| eval _time = my_time
| timechart span=1h count by STORE_ID&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp; You can change the span to size the time bucket you want to use.&lt;/P&gt;</description>
      <pubDate>Sat, 22 Jan 2022 01:25:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-use-a-calculated-quot-time-quot-field-for-a-timechart/m-p/582107#M202772</guid>
      <dc:creator>diogofgm</dc:creator>
      <dc:date>2022-01-22T01:25:40Z</dc:date>
    </item>
    <item>
      <title>Re: How do you use a calculated "_time" field for a timechart query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-use-a-calculated-quot-time-quot-field-for-a-timechart/m-p/582151#M202788</link>
      <description>&lt;P&gt;One more thing - it's a UI feature - if a nummerical field is called _time, even if it's not a field from your event but a calculated one, it'll be displayed as a date string.&lt;/P&gt;&lt;P&gt;See for yourself&lt;/P&gt;&lt;PRE&gt;| makeresults&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;This will show you _time as a current timestamp (formatted as datetime string)&lt;/P&gt;&lt;PRE&gt;| makeresults&lt;BR /&gt;| eval time2=_time-86400&lt;/PRE&gt;&lt;P&gt;This will show you current timestamp in _time (again - formatted) as well as time2 which will hold a nummerical timestamp of exactly one day ago.&lt;/P&gt;&lt;P&gt;If you then forget the old _time and rename your new field back to _time&lt;/P&gt;&lt;PRE&gt;| makeresults&lt;BR /&gt;| eval time2=_time-86400&lt;BR /&gt;| fields - _time&lt;BR /&gt;| rename time2 as _time&lt;/PRE&gt;&lt;P&gt;You'll see _time again formatted as a datetime string but with the value of "a day ago".&lt;/P&gt;&lt;P&gt;It's still a nummerical value internally and you can do normal arithmetics on it (contrary to string dates which you have to parse first with strptime if you want to modify it in any way) but if the field is called _time, splunk's webui automatically displays it as if you called fieldformat on it with strftime().&lt;/P&gt;&lt;P&gt;So the question is whether your calculated _time is indeed a string date with the format it shows or is it just a nummerical field which is conveniently displayed by webui.&lt;/P&gt;&lt;P&gt;Try renaming the field and see&amp;nbsp; if the shown value changes to a number.&lt;/P&gt;</description>
      <pubDate>Sat, 22 Jan 2022 21:14:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-use-a-calculated-quot-time-quot-field-for-a-timechart/m-p/582151#M202788</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2022-01-22T21:14:19Z</dc:date>
    </item>
  </channel>
</rss>

