title: Working around derivative(sum(value)) limitations in InfluxDB
body: <p>I have read &amp; write byte counters from an object store going into InfluxDB 0.8.8 (Happy to take a working answer for 0.9. Just waiting for a different storage engine before upgrading)</p>
  
  <p>The data is collected by server, and by device, so for example a data point might have:</p>
  
  <pre><code>timestamp: ...
  server: abc1-oss1
  disk: disk_id1
  read_bytes: a counter
  </code></pre>
  
  <p>There are a range of IDs in abc\d+ and -oss\d+ such that, for example, abc14-oss5, abc1-oss1, abc8-oss12 are all valid hostnames.</p>
  
  <p>What I'd like to do is provide an overview for all of the different abc\d+-* groups. A viewer would select, say 'abc2' and get the derivative (because it's an ever increasing counter) of the sum of all disks on all hosts that match abc2-*.</p>
  
  <p>While I could put the sum for a specific host in with the initial data insert, I can't do that for a dozen or so hosts that are in abc2-oss*</p>
  
  <p>In grafana I can do a template variable with a regexp to extract the possible abc\d+ values into a variable called $Area, and then:</p>
  
  <pre><code>select sum(value) from "read_bytes" where $timeFilter and hostname =~ /$Area.*/ group by time($interval) order asc
  </code></pre>
  
  <p>This gives me the per area read sums, but I can't call derivative() on that, as derivative(sum(value)) is invalid in InfluxDB:</p>
  
  <pre><code>select derivative(sum(value)) from ... 
  </code></pre>
  
  <p>"Value cannot be evaluated for type &amp;{sum 10 [oxc21648f220] false}"</p>
  
  <p>I'm assuming this means I need a continuous query in InfluxDB to calculate the sum, and then put the derivative() call on the resultant measurement. How would I do that for a partial column value, so that I'm summing all values for <code>hostname =~ /abc1-.*/</code>, <code>hostname =~ /abc2-.*/</code>, and so on?</p>