title: How do I get consistent values with influxdb non_negative_derivative?
body: <p>Using grafana with influxdb, I am trying to show the per-second rate of some value that is a counter.  If I use the <code>non_negative_derivative(1s)</code> function, the value of the rate seems to change dramatically depending on the time width of the grafana view.  I'm using the <code>last</code> selector (but could also use <code>max</code> which is the same value since it is a counter).</p>
  
  <p>Specifically, I'm using:</p>
  
  <p><code>SELECT non_negative_derivative(last("my_counter"), 1s) FROM ...</code></p>
  
  <p>According to the <a href="https://docs.influxdata.com/influxdb/v0.13/query_language/functions/#non-negative-derivative" rel="noreferrer">influxdb docs non-negative-derivative</a>:</p>
  
  <blockquote>
    <p>InfluxDB calculates the difference between chronological field values and converts those results into the rate of change per unit.</p>
  </blockquote>
  
  <p>So to me, that means that the value at a given point should not change that much when expanding the time view, since the value should be <em>rate of change per unit</em> (1s in my example query above).</p>
  
  <p>In graphite, they have the specific <code>perSecond</code> function, which works much better:</p>
  
  <p><code>perSecond(consolidateBy(my_counter, 'max'))</code></p>
  
  <p>Any ideas on what I'm doing wrong with the influx query above?</p>