<?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: Need assistance creating a timechart using a calculated value in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Need-assistance-creating-a-timechart-using-a-calculated-value/m-p/114588#M30314</link>
    <description>&lt;P&gt;5.0.1.  Thanks.&lt;/P&gt;</description>
    <pubDate>Fri, 25 Oct 2013 02:39:22 GMT</pubDate>
    <dc:creator>john_byun</dc:creator>
    <dc:date>2013-10-25T02:39:22Z</dc:date>
    <item>
      <title>Need assistance creating a timechart using a calculated value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-assistance-creating-a-timechart-using-a-calculated-value/m-p/114586#M30312</link>
      <description>&lt;P&gt;I have the following search that gives me the ratio between the values from 2 separate searches.  I'm sure it's pretty simple, but I'm struggling with putting this is a simple timechart.  I want to see a line graph for the last 30 days plotting the 'ratio' value in 1 day increments.  Also, how do I format the graph to only show tickmarks and labels for a each week instead of each day?&lt;/P&gt;

&lt;P&gt;sourcetype=production eventtype="completedTransaction" tag=pilot | stats count as transactions| join [search sourcetype=production eventtype="totalErrors" tag=pilot | transaction host maxspan=3m | stats count as errors] | eval ratio=(errors/transactions)*100 | fieldformat ratio=tostring(round(ratio,1))+"%"&lt;/P&gt;</description>
      <pubDate>Thu, 24 Oct 2013 23:45:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-assistance-creating-a-timechart-using-a-calculated-value/m-p/114586#M30312</guid>
      <dc:creator>john_byun</dc:creator>
      <dc:date>2013-10-24T23:45:34Z</dc:date>
    </item>
    <item>
      <title>Re: Need assistance creating a timechart using a calculated value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-assistance-creating-a-timechart-using-a-calculated-value/m-p/114587#M30313</link>
      <description>&lt;P&gt;What version of Splunk are you using?&lt;/P&gt;</description>
      <pubDate>Fri, 25 Oct 2013 02:30:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-assistance-creating-a-timechart-using-a-calculated-value/m-p/114587#M30313</guid>
      <dc:creator>ShaneNewman</dc:creator>
      <dc:date>2013-10-25T02:30:55Z</dc:date>
    </item>
    <item>
      <title>Re: Need assistance creating a timechart using a calculated value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-assistance-creating-a-timechart-using-a-calculated-value/m-p/114588#M30314</link>
      <description>&lt;P&gt;5.0.1.  Thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 25 Oct 2013 02:39:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-assistance-creating-a-timechart-using-a-calculated-value/m-p/114588#M30314</guid>
      <dc:creator>john_byun</dc:creator>
      <dc:date>2013-10-25T02:39:22Z</dc:date>
    </item>
    <item>
      <title>Re: Need assistance creating a timechart using a calculated value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-assistance-creating-a-timechart-using-a-calculated-value/m-p/114589#M30315</link>
      <description>&lt;P&gt;There are two ways I see you can do this depending on what kind of results you want. If you want to plot &lt;EM&gt;each and every&lt;/EM&gt; data point over time, it's as simple as adding this at the end of the search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| table _time ratio
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Because a line chart (or area, or similar) works by taking the first column of its input as the X axis value and the rest of the columns to be the value that should be plotted on the Y axis, it doesn't matter if these columns were generated by a &lt;CODE&gt;chart&lt;/CODE&gt; command or not.&lt;/P&gt;

&lt;P&gt;One problem you will run into is that if you do this over a result set that includes many data points, your graph will take a long time to load or even drop data past a certain point - iirc the new JSChart module takes more datapoints than the FlashChart module that was previously used by default, but there's still a limit and there will still be performance issues even before you approach that limit. Because of this, &lt;CODE&gt;timechart&lt;/CODE&gt; automatically divides the input into buckets of time and will output only one value per bucket. By default &lt;CODE&gt;timechart&lt;/CODE&gt; will create a maximum of 100 buckets, which means that if you search the past 5 hours, each bucket will be 3 minutes long (300 minutes divided by 100 buckets = 3 minutes per bucket).&lt;/P&gt;

&lt;P&gt;Now, because &lt;CODE&gt;timechart&lt;/CODE&gt; divides the events into buckets based on time, several events might end up in the same bucket, and &lt;CODE&gt;timechart&lt;/CODE&gt; somehow needs to find a way of still representing only one value out of that. This is why you can't just simply do &lt;CODE&gt;timechart ratio&lt;/CODE&gt; - you need to specify a statistical function that tells &lt;CODE&gt;timechart&lt;/CODE&gt; what to do with its input. You could do &lt;CODE&gt;timechart first(ratio) as ratio&lt;/CODE&gt; which unsurprisingly grabs the first value in each span and outputs that. You could use &lt;CODE&gt;last&lt;/CODE&gt;, or &lt;CODE&gt;avg&lt;/CODE&gt; to take an average, or &lt;CODE&gt;max&lt;/CODE&gt;, or, or...&lt;/P&gt;

&lt;P&gt;tl;dr: For the &lt;CODE&gt;timechart&lt;/CODE&gt; option, do something like&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=production eventtype="completedTransaction" tag=pilot | stats count as transactions| join [search sourcetype=production eventtype="totalErrors" tag=pilot | transaction host maxspan=3m | stats count as errors] | eval ratio=(errors/transactions)*100 | fieldformat ratio=tostring(round(ratio,1))+"%" | timechart first(ratio) as ratio
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 25 Oct 2013 06:44:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-assistance-creating-a-timechart-using-a-calculated-value/m-p/114589#M30315</guid>
      <dc:creator>Ayn</dc:creator>
      <dc:date>2013-10-25T06:44:55Z</dc:date>
    </item>
    <item>
      <title>Re: Need assistance creating a timechart using a calculated value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-assistance-creating-a-timechart-using-a-calculated-value/m-p/114590#M30316</link>
      <description>&lt;P&gt;Sorry for taking so long to get back to you.  I've tried both options and neither are working for me.  Adding&lt;BR /&gt;
| table _time ratio&lt;BR /&gt;
shows me a blank line graph.&lt;BR /&gt;
The timechart query shows no results found.  Thoughts?&lt;/P&gt;</description>
      <pubDate>Mon, 28 Oct 2013 22:33:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-assistance-creating-a-timechart-using-a-calculated-value/m-p/114590#M30316</guid>
      <dc:creator>john_byun</dc:creator>
      <dc:date>2013-10-28T22:33:28Z</dc:date>
    </item>
    <item>
      <title>Re: Need assistance creating a timechart using a calculated value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-assistance-creating-a-timechart-using-a-calculated-value/m-p/114591#M30317</link>
      <description>&lt;P&gt;Ah, I see now that you're doing a &lt;CODE&gt;stats&lt;/CODE&gt; early in your search. After that stats command, the &lt;CODE&gt;_time&lt;/CODE&gt; field will no longer be available. I don't know enough about your data to say how you would switch away from &lt;CODE&gt;stats&lt;/CODE&gt;, but generally if you want to run stats against your events but without having it consume all fields, leaving only the aggregated results, switch to using &lt;CODE&gt;eventstats&lt;/CODE&gt; instead. It will write its results as field values in the original events instead.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Oct 2013 05:51:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-assistance-creating-a-timechart-using-a-calculated-value/m-p/114591#M30317</guid>
      <dc:creator>Ayn</dc:creator>
      <dc:date>2013-10-29T05:51:08Z</dc:date>
    </item>
  </channel>
</rss>

