python-diamond / Diamond

Diamond is a python daemon that collects system metrics and publishes them to Graphite (and others). It is capable of collecting cpu, memory, network, i/o, load and disk metrics. Additionally, it features an API for implementing custom collectors for gathering metrics from almost any source.
http://diamond.readthedocs.org/
MIT License
1.74k stars 601 forks source link

MongoDbCollector sends several same-name metrics at a time, the latest set overwrites all the data sent to Graphite #657

Open stayen opened 7 years ago

stayen commented 7 years ago

OS: Ubuntu 16.04, Diamond: 4.0.515

I was studying the issue of MongoDbCollector providing zero metrics for MongoDb in Graphite. Finally, I saw via catching the traffic that the MongoDB collector sends data sets like those below:

servers.servername.mongo.network_per_sec.numRequests 24 1497791440
servers.servername.mongo.network_per_sec.bytesOut 57890 1497791440
servers.servername.mongo.network_per_sec.bytesIn 4156 1497791440
servers.servername.mongo.network_per_sec.numRequests 0 1497791440
servers.servername.mongo.network_per_sec.bytesOut 0 1497791440
servers.servername.mongo.network_per_sec.bytesIn 0 1497791440

The result: zero values are stored in Graphite.

Possible solutions could be:

  1. sum up the COUNTER type of metrics, use the last one for GAUGE, before sending to Graphite
  2. add an option to send data to Graphite aggregator (that would require additional setup on Graphite side)

Currently, the above collector became meaningless and I perhaps will try to use the first "hack" to send actual data at a cost of wasting more RAM on Diamond side.