<?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: trouble creating query for single value chart with trend for the last 24 hs in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/trouble-creating-query-for-single-value-chart-with-trend-for-the/m-p/474158#M31135</link>
    <description>&lt;P&gt;So I ended up with the following query, which I believe is much simpler and I believe may be enough: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...base search | eval moment=now() - relative_time(now(), "@d") | eval _time = _time - moment | timechart span=1d  count| tail 3 | tail 2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;in which I did not worry about getting the resulting  timestamps to represent the correct times (I would need to add back in the relative time I subtracted earlier in that case), since I only really need to present the last count  and the comparison with the previous count (that is, a single chart visualization  with the trend value). &lt;/P&gt;

&lt;P&gt;NOTE: I am using also an earliest value of "-48h@h" and a latest value of 'now'&lt;/P&gt;</description>
    <pubDate>Mon, 13 Apr 2020 00:36:15 GMT</pubDate>
    <dc:creator>pgoldweic</dc:creator>
    <dc:date>2020-04-13T00:36:15Z</dc:date>
    <item>
      <title>trouble creating query for single value chart with trend for the last 24 hs</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/trouble-creating-query-for-single-value-chart-with-trend-for-the/m-p/474155#M31132</link>
      <description>&lt;P&gt;I've been trying to create query of the following type:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;… some base search... | timechart span=1d count 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;with the trending value comparing the count right now with the count 24 hours ago. Unfortunately this is not working, as the trend happens to compare a count for today's date (a partial day) with the count for the whole day yesterday.&lt;BR /&gt;
I read answers to similar questions:  1) &lt;A href="https://answers.splunk.com/answers/333319/how-to-create-a-search-to-show-a-trending-single-v.html" target="_blank"&gt;https://answers.splunk.com/answers/333319/how-to-create-a-search-to-show-a-trending-single-v.html&lt;/A&gt; and 2) &lt;A href="https://answers.splunk.com/answers/86659/timechart-day-offset.html" target="_blank"&gt;https://answers.splunk.com/answers/86659/timechart-day-offset.html&lt;/A&gt;, which led me to believe that I need to offset the time to get this working. So my current query looks like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;… base search | timechart span=1h count | addinfo | eval hour_of_time = strftime("%H",info_search_time), eval _time = _time - (hour_of_time * 3600) | timechart span=1d sum(count) as count 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;to which I believe I need to add an eventual _time = _time + (hour_of_time * 3600)  . Since the hour_of_time field is gone from the result of the query above, I tried appending the following to the query again:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  |addinfo |eval hour_of_time=strftime("%H",info_search_time)| eval _time = _time + (hour_of_time * 3600)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;However, the results:&lt;BR /&gt;
- include a _time column with no values in it&lt;BR /&gt;
- do not include the 'hour_of_time' field &lt;/P&gt;

&lt;P&gt;What am I missing? &lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 04:58:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/trouble-creating-query-for-single-value-chart-with-trend-for-the/m-p/474155#M31132</guid>
      <dc:creator>pgoldweic</dc:creator>
      <dc:date>2020-09-30T04:58:45Z</dc:date>
    </item>
    <item>
      <title>Re: trouble creating query for single value chart with trend for the last 24 hs</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/trouble-creating-query-for-single-value-chart-with-trend-for-the/m-p/474156#M31133</link>
      <description>&lt;P&gt;If you only want a single value and a trend, then you don't really need to deal with hours.&lt;/P&gt;

&lt;P&gt;Just throw away any records that are later than the same time yesterday, before you do the timechart.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; … base search earliest=1d@d
| eval Day=relative_time(_time,"@d")
| eval Moment=_time - Day

| addinfo 
| eval last_Moment=info_search_time -relative_time(info_search_time,"@d")
| where Moment &amp;lt;= last_Moment

| timechart span=1d sum(count) as count 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;There are other ways, but that should do.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Apr 2020 23:41:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/trouble-creating-query-for-single-value-chart-with-trend-for-the/m-p/474156#M31133</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2020-04-10T23:41:10Z</dc:date>
    </item>
    <item>
      <title>Re: trouble creating query for single value chart with trend for the last 24 hs</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/trouble-creating-query-for-single-value-chart-with-trend-for-the/m-p/474157#M31134</link>
      <description>&lt;P&gt;Thanks @DalJeanis although I'm a bit confused by your answer; perhaps I need to explain my needs better.  All the data I really need is the following:&lt;BR /&gt;
- a count of the events for the last 24 hours (starting the count now)&lt;BR /&gt;
- a count of the events for the previous 24 hours&lt;BR /&gt;
So, for example, if it is 3 pm now, then I'd want as #1 the count of events from 3 pm yesterday till now, and so forth. By having the two values, the trend value would represent the difference between them, which is what I need.&lt;BR /&gt;
 It would seem that your query above is not giving me that (or I'm misunderstanding it), but it is gathering all the events that happened since the beginning of the earlier day until 24 hours ago.&lt;BR /&gt;&lt;BR /&gt;
Am I reading this correctly? I'm really trying to find the simplest query that can represent what I need.&lt;/P&gt;</description>
      <pubDate>Sun, 12 Apr 2020 22:35:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/trouble-creating-query-for-single-value-chart-with-trend-for-the/m-p/474157#M31134</guid>
      <dc:creator>pgoldweic</dc:creator>
      <dc:date>2020-04-12T22:35:04Z</dc:date>
    </item>
    <item>
      <title>Re: trouble creating query for single value chart with trend for the last 24 hs</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/trouble-creating-query-for-single-value-chart-with-trend-for-the/m-p/474158#M31135</link>
      <description>&lt;P&gt;So I ended up with the following query, which I believe is much simpler and I believe may be enough: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...base search | eval moment=now() - relative_time(now(), "@d") | eval _time = _time - moment | timechart span=1d  count| tail 3 | tail 2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;in which I did not worry about getting the resulting  timestamps to represent the correct times (I would need to add back in the relative time I subtracted earlier in that case), since I only really need to present the last count  and the comparison with the previous count (that is, a single chart visualization  with the trend value). &lt;/P&gt;

&lt;P&gt;NOTE: I am using also an earliest value of "-48h@h" and a latest value of 'now'&lt;/P&gt;</description>
      <pubDate>Mon, 13 Apr 2020 00:36:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/trouble-creating-query-for-single-value-chart-with-trend-for-the/m-p/474158#M31135</guid>
      <dc:creator>pgoldweic</dc:creator>
      <dc:date>2020-04-13T00:36:15Z</dc:date>
    </item>
    <item>
      <title>Re: trouble creating query for single value chart with trend for the last 24 hs</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/trouble-creating-query-for-single-value-chart-with-trend-for-the/m-p/474159#M31136</link>
      <description>&lt;P&gt;If you are using &lt;CODE&gt;earliest=-48h@h&lt;/CODE&gt;, then use &lt;CODE&gt;latest =@h&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Do this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; … base search earliest=48h@h latest=@h
 | addinfo 
 | eval Midpoint=(info_min_time+info_max_time)/2
 | eval _time = if(_time&amp;lt;=Midpoint,MidPoint,info_max_time)
 | timechart span=1d sum(count) as count  
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This will give the date of the endpoint of the search as the date of the current point, and 24 hours prior as the data of the prior point.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Apr 2020 18:13:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/trouble-creating-query-for-single-value-chart-with-trend-for-the/m-p/474159#M31136</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2020-04-14T18:13:02Z</dc:date>
    </item>
    <item>
      <title>Re: trouble creating query for single value chart with trend for the last 24 hs</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/trouble-creating-query-for-single-value-chart-with-trend-for-the/m-p/474160#M31137</link>
      <description>&lt;P&gt;That seems useful. Thanks @DalJeanis ! I'll be accepting your answer to the post. &lt;/P&gt;</description>
      <pubDate>Tue, 14 Apr 2020 18:32:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/trouble-creating-query-for-single-value-chart-with-trend-for-the/m-p/474160#M31137</guid>
      <dc:creator>pgoldweic</dc:creator>
      <dc:date>2020-04-14T18:32:43Z</dc:date>
    </item>
  </channel>
</rss>

