org.graylog2.metrics.LibratoMetricsFormatter Maven / Gradle / Ivy
/**
* This file is part of Graylog.
*
* Graylog is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Graylog is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Graylog. If not, see .
*/
package org.graylog2.metrics;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.graylog2.plugin.Tools;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
/**
* @author Lennart Koopmann
*/
public class LibratoMetricsFormatter extends MetricsFormatter {
private static final Logger LOG = LoggerFactory.getLogger(LibratoMetricsFormatter.class);
private final ObjectMapper objectMapper = new ObjectMapper();
//private MessageCounter counter;
private List streamFilter;
private String hostFilter;
private String source;
private Map streamNames;
public LibratoMetricsFormatter (String prefix, List streamFilter, String hostFilter, Map streamNames) {
//this.counter = counter;
this.streamFilter = streamFilter;
this.hostFilter = hostFilter;
this.source = prefix + "graylog2-server";
this.streamNames = streamNames;
}
/*
* Example:
*
* {
* "gauges": [
* {
* "value": 200,
* "source": "graylog2",
* "name": "gl2-total"
* },
* {
* "value": 50,
* "source": "graylog2",
* "name": "gl2-stream-4f60e84e54f0ba1a8d000003"
* }
* ]
* }
*/
public String asJson() {
Map m = Maps.newHashMap();
// TODO
/*List