title: Average values on group items using Mongo Aggregation Framework
body: <p>I want to group a collection and then compute the average on one field of the groups.</p>
  
  <p>I setup my db and contents like this:</p>
  
  <pre><code>use testdb
  db.bla.insert({"service": "A", "tet": "1"})
  db.bla.insert({"service": "A", "tet": "100"})
  db.bla.insert({"service": "A", "tet": "150"})
  db.bla.insert({"service": "B", "tet": "10"})
  db.bla.insert({"service": "B", "tet": "20"})
  db.bla.insert({"service": "B", "tet": "25"})
  </code></pre>
  
  <p>Now I want the number of all services "A" and "B" and the average tet for all services "A" and "B".
  I tried this:</p>
  
  <pre><code>db.bla.aggregate( { "$group": { _id: "$service", requests: { $sum:1}, averagetet: { $avg: "$tet"}}})
  </code></pre>
  
  <p>But that always gives me "0" for the average values.
  What am I missing here?</p>