io.prometheus.client.bridge.Graphite Java Examples

The following examples show how to use io.prometheus.client.bridge.Graphite. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PrometheusBistouryMetricRegistry.java    From bistoury with GNU General Public License v3.0 6 votes vote down vote up
public PrometheusBistouryMetricRegistry() {
    DynamicConfig<LocalDynamicConfig> config = DynamicConfigLoader.load("prometheus.properties", false);
    String type = config.getString("monitor.type", "prometheus");
    if ("prometheus".equals(type)) {
        String action = config.getString("monitor.action", "metrics");
        if ("metrics".equals(action)) {
            try {
                HTTPServer server = new HTTPServer(config.getInt("monitor.port", 3333));
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    } else if ("graphite".equals(type)) {
        String host = config.getString("graphite.host");
        int port = config.getInt("graphite.port");
        Graphite graphite = new Graphite(host, port);
        graphite.start(CollectorRegistry.defaultRegistry, 60);
    }
}
 
Example #2
Source File: PrometheusQmqMetricRegistry.java    From qmq with Apache License 2.0 6 votes vote down vote up
public PrometheusQmqMetricRegistry() {
    DynamicConfig config = DynamicConfigLoader.load("qmq.prometheus.properties", false);
    String type = config.getString("monitor.type", "prometheus");
    if ("prometheus".equals(type)) {
        String action = config.getString("monitor.action", "pull");
        if ("pull".equals(action)) {
            try {
                HTTPServer server = new HTTPServer(config.getInt("monitor.port", 3333));
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    } else if ("graphite".equals(type)) {
        String host = config.getString("graphite.host");
        int port = config.getInt("graphite.port");
        Graphite graphite = new Graphite(host, port);
        graphite.start(CollectorRegistry.defaultRegistry, 60);
    }

}
 
Example #3
Source File: JavaGraphiteBridge.java    From java_examples with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    // Add metrics about CPU, JVM memory etc.
    DefaultExports.initialize();

    Graphite g = new Graphite("localhost", 2003);
    // Send to graphite every 60s.
    Thread thread = g.start(CollectorRegistry.defaultRegistry, 60);
    thread.join();  // Waits forever.
}