try {
final DBCollection collection = mongoConnection.getDatabase().getCollection("graylog2_metrics");
// don't hang on to the data for too long.
final BasicDBObject indexField = new BasicDBObject("timestamp", 1);
final BasicDBObject indexOptions = new BasicDBObject("expireAfterSeconds", 5 * 60);
collection.createIndex(indexField, indexOptions);
collection.insert(docs, WriteConcern.UNACKNOWLEDGED);
} catch (Exception e) {
LOG.warn("Unable to write graylog2 metrics to mongodb. Ignoring this error.", e);
}