title: KairoDB metric names or tags for IoT
body: <p>We have a lot of sensors like energymeters and want to store the data using kairosdb. Before we used a simple SQL store, where each sensor has it's own table where each measurement is one row.</p>
  
  <p>a measturement is published to the system from the sensor via a JSON object:</p>
  
  <pre><code>{
      time: 12363453,
      volt: 238.33,
      ampere: 9.3,
      watts: 29.0,
  }
  </code></pre>
  
  <p>So, for example for two sensors on two devices, we have this in our DB:</p>
  
  <p>Sensor A1234:</p>
  
  <pre><code>id, time, volt, ampere, watts
  12, &lt;unix-ts&gt;, 238.33, 9.3, 29.0
  13, &lt;unix-ts&gt;, 238.21, 9.1, 23.8
  ...
  </code></pre>
  
  <p>Sensor B5678:</p>
  
  <pre><code>id, time, volt, ampere, watts
  75, &lt;unix-ts&gt;, 230.12, 3.9, 19.5
  76, &lt;unix-ts&gt;, 234.65, 2.8, 24.5
  ...
  </code></pre>
  
  <p>Now, we're investigating what's the best solution to store the same information but using KairosDB instead.</p>
  
  <p>Our goal is to answser some "questions" like: 
  - the latest volt, watt, ampere 
  - what was the average ampere between x (start timestamp) and y (end timestamp)
  - what was the sum watts over all (or a subset) sensors between two dates</p>
  
  <p>and so on.</p>
  
  <p>So, what would be the best approach for choosing metric names and/or tags?</p>
  
  <p>Should we use the sensor-names for the metric names (without tags):</p>
  
  <pre><code>sensors.energy.a1234.volt=238.33
  sensors.energy.a1234.ampere=9.3
  sensors.energy.a1234.watts=29.0
  
  sensors.energy.b5678.volt=230.12
  sensors.energy.b5678.ampere=3.9
  sensors.energy.b5678.watts=19.5
  </code></pre>
  
  <p>Or should we use tags on the same metrics for all sensors:</p>
  
  <pre><code>sensors.energy.volt=238.33, tag: sensor=a1234
  sensors.energy.ampere=9.3, tag: sensor=a1234
  sensors.energy.watts=29.0, tag: sensor=a1234
  
  sensors.energy.volt=230.12, tag: sensor=b5678
  sensors.energy.ampere=3.9, tag: sensor=b5678
  sensors.energy.watts=19.5, tag: sensor=b5678
  </code></pre>
  
  <p>or, are we totally on the wrong way?</p>
  
  <p>Is there a difference regarding the query performance?</p>