title: mongodb aggregate average of array elements
body: <p>I have collection of documents in mongodb 2.6.11 where 'cpu' is array showing [cpu0,cpu1], see example below</p>
  
  <pre><code>{ cpu: [ '100','20' ], hostname: 'host1',_id: 1 },
  { cpu: [ '40','30' ], hostname: 'host1',_id: 2 }, etc
  </code></pre>
  
  <p>I'm looking for average cpu on 'host1' which is ['70','25'] ( because '100'+'40'/2='70' and '20'+'30'='25' ). I am trying aggregate for cpu1 but it is not giving me right result</p>
  
  <pre><code>db.collection.aggregate(
      [
          {
              $group:
              {
                  _id:"hostname",
                  avgCPU: {$avg: "$cpu.1"}
              }
          }
      ]
  );
  </code></pre>