class HeimdallElasticSearchRepository {

	public JsonArray getEventsProcessed() throws Exception
	{
		String responseJson = null;
		JsonParser jsonParser;
		JsonObject resultJson;
		StringBuilder urlToQueryBuffer = new StringBuilder(esUrl).append("/").append("blackbox").append("/").append("_search");

		StringBuilder requestBody = new StringBuilder(
				"{\"size\":0,\"query\":{\"range\":{\"eventTime\":{\"gte\":\"now-1d/d\"}}},\"aggs\":{\"events-per-day\":{\"date_histogram\":{\"field\":\"eventTime\",\"interval\":\"day\",\"order\":{\"_key\":\"desc\"}}}}}");

		try
		{
			responseJson = PacHttpUtils.doHttpPost(urlToQueryBuffer.toString(), requestBody.toString());
		} catch (Exception e)
		{
			logger.error("error retrieving inventory from ES", e);
			throw new Exception(e);
		}
		jsonParser = new JsonParser();
		resultJson = (JsonObject) jsonParser.parse(responseJson);
		JsonObject aggsJson = (JsonObject) jsonParser.parse(resultJson.get("aggregations").toString());
		return aggsJson.getAsJsonObject("events-per-day").getAsJsonArray("buckets");
	}

}