<?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 How to create a time chart using multiple custom time fields, not _time? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-time-chart-using-multiple-custom-time-fields-not/m-p/255110#M76387</link>
    <description>&lt;P&gt;I'm trying to chart two different things in the same graph using two different custom time fields.&lt;BR /&gt;
It almost works (the graph shows up), however, the time range picker seems to be mangling things a bit. Even though eval is overwriting _time for the timechart function, the initial search is still searching based on initial _time value, and is therefore not returning accurate results. Needless to say, when I try to timechart this, it's a bit of a mess. No matter what I do, it seems that the search returns data from as far back as a year (possibly the entire data set).&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=*  | eval CloseTime=strptime('Closed Date Time',"%d/%m/%Y %I:%M:%S %p") | where CloseTime&amp;gt;relative_time(CloseTime, "$timepicker.earliest$") | eval _time=CloseTime | timechart count AS Closed span=1d | appendcols [ search index=* | eval CreateTime=strptime('Created Date Time',"%d/%m/%Y %I:%M:%S %p") |  where CreateTime&amp;gt;relative_time(CreateTime, "$timepicker.earliest$") | eval _time=CreateTime  |  timechart count AS Created span=1d  ]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 05 Dec 2016 06:00:26 GMT</pubDate>
    <dc:creator>abake</dc:creator>
    <dc:date>2016-12-05T06:00:26Z</dc:date>
    <item>
      <title>How to create a time chart using multiple custom time fields, not _time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-time-chart-using-multiple-custom-time-fields-not/m-p/255110#M76387</link>
      <description>&lt;P&gt;I'm trying to chart two different things in the same graph using two different custom time fields.&lt;BR /&gt;
It almost works (the graph shows up), however, the time range picker seems to be mangling things a bit. Even though eval is overwriting _time for the timechart function, the initial search is still searching based on initial _time value, and is therefore not returning accurate results. Needless to say, when I try to timechart this, it's a bit of a mess. No matter what I do, it seems that the search returns data from as far back as a year (possibly the entire data set).&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=*  | eval CloseTime=strptime('Closed Date Time',"%d/%m/%Y %I:%M:%S %p") | where CloseTime&amp;gt;relative_time(CloseTime, "$timepicker.earliest$") | eval _time=CloseTime | timechart count AS Closed span=1d | appendcols [ search index=* | eval CreateTime=strptime('Created Date Time',"%d/%m/%Y %I:%M:%S %p") |  where CreateTime&amp;gt;relative_time(CreateTime, "$timepicker.earliest$") | eval _time=CreateTime  |  timechart count AS Created span=1d  ]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 05 Dec 2016 06:00:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-time-chart-using-multiple-custom-time-fields-not/m-p/255110#M76387</guid>
      <dc:creator>abake</dc:creator>
      <dc:date>2016-12-05T06:00:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a time chart using multiple custom time fields, not _time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-time-chart-using-multiple-custom-time-fields-not/m-p/255111#M76388</link>
      <description>&lt;P&gt;In your timepicker tag, add this (only the change part)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;input type="time"&amp;gt;
...
&amp;lt;change&amp;gt;
   &amp;lt;eval token="t"&amp;gt;if(isnum($timepicker.earliest$), $timepicker.earliest$, relative_time(now(), $timepicker.earliest$)&amp;lt;/eval&amp;gt;
&amp;lt;/change&amp;gt;
&amp;lt;/input&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And try this for you query&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=* 
| eval CreateTime=strptime('Created Date Time',"%d/%m/%Y %I:%M:%S %p") 
| eval CloseTime=strptime('Closed Date Time',"%d/%m/%Y %I:%M:%S %p") 
| where CreateTime&amp;gt;$t$ OR CloseTime&amp;gt;$t$
| eval closed=if(CloseTime&amp;gt;$t$, 1, 0)
| eval opened=if(CreateTime&amp;gt;$t$, 1 0) 
| bin span=1d CreateTime
| stats sum(opened) as Opened sum(closed) as Closed by CreateTime
| eval CreateTime=strftime(CreateTime,"%d/%m/%Y %I:%M:%S %p") 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 05 Dec 2016 15:20:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-time-chart-using-multiple-custom-time-fields-not/m-p/255111#M76388</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-12-05T15:20:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a time chart using multiple custom time fields, not _time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-time-chart-using-multiple-custom-time-fields-not/m-p/255112#M76389</link>
      <description>&lt;P&gt;Thanks for your help. Unfortunately using this query I still get results arbitrarily out of the date range. Regardless of what the picker is set to I get results as far back as December in the chart.&lt;BR /&gt;
However, I've amended by original search to include the new tokens. This seems to work - mostly. The only issue I'm having now is that the tokens don't seem to update correctly - the search seems to use whatever the picker was last set to.&lt;/P&gt;</description>
      <pubDate>Mon, 05 Dec 2016 22:28:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-time-chart-using-multiple-custom-time-fields-not/m-p/255112#M76389</guid>
      <dc:creator>abake</dc:creator>
      <dc:date>2016-12-05T22:28:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a time chart using multiple custom time fields, not _time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-time-chart-using-multiple-custom-time-fields-not/m-p/255113#M76390</link>
      <description>&lt;P&gt;In your events, how is &lt;CODE&gt;_time&lt;/CODE&gt; set?&lt;/P&gt;</description>
      <pubDate>Thu, 08 Dec 2016 14:18:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-time-chart-using-multiple-custom-time-fields-not/m-p/255113#M76390</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-12-08T14:18:36Z</dc:date>
    </item>
  </channel>
</rss>

