def _collect_indexes_stats(self, instance, db, tags):
        """
        Collect indexes statistics for all collections in the configuration.
        This use the "$indexStats" command.
        """
        for coll_name in instance.get('collections', []):
            try:
                for stats in db[coll_name].aggregate([{"$indexStats": {}}], cursor={}):
                    idx_tags = tags + [
                        "name:{0}".format(stats.get('name', 'unknown')),
                        "collection:{0}".format(coll_name),
                    ]
                    val = int(stats.get('accesses', {}).get('ops', 0))
                    self.gauge('mongodb.collection.indexes.accesses.ops', val, idx_tags)
            except Exception as e:
                self.log.error("Could not fetch indexes stats for collection %s: %s", coll_name, e)
Collect indexes statistics for all collections in the configuration.
        This use the "$indexStats" command.