title: Spring Cloud Stream - How to calculate average of metrics' values
body: <p>question from a Spring Cloud Stream rookie w/ little Kafka streams knowledge.
  I need to produce a stream of time-series regarding compute resources metrics.
  I receive a stream of json messages containing metrics like cpu usage, memory usage and so on.
  I'm stuck in understanding how to sum metrics' values and the number of processed values in order to calculate the average value on a time-window base (i.e. 300s).</p>
  
  <p>Incoming messages are like this:</p>
  
  <pre><code>[
     {
        "value": 27,
        "unit": "%",
        "type": "gauge",
        "metric": "cpu_usage",
        "time":1519314305.896,
        "host":"vm01-partition01",
     }
  ]
  </code></pre>
  
  <p>I'd like to obtain a json message like the following:</p>
  
  <pre><code>[
     {
        "value": 32,
        "aggregation": "mean",
        "metric": "cpu_usage",
        "time":1519314305.896,    //timestamp of the first processed value
        "host":"vm01-partition01",
     }
  ]
  </code></pre>
  
  <p>Anybody can switch on the light for me?
  Thanks</p>