if (after != -1) {
obj.add(new BasicDBObject("$gt", new BasicDBObject("$gt", new Date(after))));
}
andQuery.put("$and", obj);
final DBCursor cursor = mongoConnection.getDatabase().getCollection("graylog2_metrics")
.find(andQuery).sort(new BasicDBObject("timestamp", 1));
Map<String, Object> metricsData = Maps.newHashMap();
metricsData.put("name", metricName);
List<Object> values = Lists.newArrayList();
metricsData.put("values", values);
while (cursor.hasNext()) {
final DBObject value = cursor.next();
metricsData.put("node", value.get("node"));
final MetricType metricType = MetricType.valueOf(((String) value.get("type")).toUpperCase());
Map<String, Object> dataPoint = Maps.newHashMap();
values.add(dataPoint);