io.prometheus.client.vertx.MetricsHandler Java Examples

The following examples show how to use io.prometheus.client.vertx.MetricsHandler. 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: MetricsConfiguration.java    From prebid-server-java with Apache License 2.0 5 votes vote down vote up
@PostConstruct
public void startPrometheusServer() {
    logger.info("Starting Prometheus Server on port {0,number,#}", prometheusPort);
    final Router router = Router.router(vertx);
    router.route("/metrics").handler(new MetricsHandler());

    CollectorRegistry.defaultRegistry.register(new DropwizardExports(metricRegistry));

    contextRunner.<HttpServer>runOnServiceContext(promise ->
            vertx.createHttpServer().requestHandler(router).listen(prometheusPort, promise));

    logger.info("Successfully started Prometheus Server");
}
 
Example #2
Source File: PromMetricsExporter.java    From vertx-mqtt-broker with Apache License 2.0 5 votes vote down vote up
@Override
public void start() throws Exception {
    JsonObject conf = config().getJsonObject("prometheus_exporter", new JsonObject());
    int httpPort = conf.getInteger("port", 9100);
    String path = conf.getString("path", "/metrics");

    DefaultExports.initialize();

    Router router = Router.router(vertx);
    router.route(path).handler(new MetricsHandler());
    vertx.createHttpServer().requestHandler(router::handle).listen(httpPort);
}
 
Example #3
Source File: ExampleExporter.java    From client_java with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
  final Vertx vertx = Vertx.vertx();
  final Router router = Router.router(vertx);

  router.route("/metrics").handler(new MetricsHandler());

  vertx.createHttpServer().requestHandler(router::accept).listen(1234);

  g.set(1);
  c.inc(2);
  s.observe(3);
  h.observe(4);
  l.labels("foo").inc(5);
}