vert.xhawkular

How to call Hawkular from Vert.x


I want to get the metrics from vert.x with Hawkular, but I have problem. Following the tutorial of this. http://vertx.io/docs/vertx-hawkular-metrics/java/

Then, I change the code of the tutorial of vert.x http://vertx.io/blog/my-first-vert-x-3-application/

like this.

from this

@Before
  public void setUp(TestContext context) {
    vertx = Vertx.vertx();
    vertx.deployVerticle(MyFirstVerticle.class.getName(),
        context.asyncAssertSuccess());
  }

to this

VertxOptions vertxOptions = new VertxOptions()
    .setMetricsOptions(new VertxHawkularOptions()
        .setHost("localhost")
        .setPort(8080)
        .setTenant("com.acme")
        .setAuthenticationOptions(
            new AuthenticationOptions()
                .setEnabled(true)
                .setId("jdoe")
                .setSecret("password")).setEnabled(true));
vertx = Vertx.vertx(vertxOptions);

  JsonObject message = new JsonObject()
      .put("id", "myapp.files.opened")
      .put("value", 7);
  vertx.eventBus().publish("metrics", message);

But I think I there are no changes in Hawkular. First of all, I checked with WireShark, there looks like no connection of HTTP request of this application. I want to know if I execute this code, can I see some change in the Hawkular Metrics?

I already checked.


Solution

  • I think the test process finishes before the metrics had time to get reported. I tried with your example (which looks correct beside this timing issue), and had to put a Thread.sleep of 1 second after publishing on the event bus in order to see something in Hawkular.

    curl -u jdoe:password -H "Hawkular-Tenant: com.acme" http://localhost:8080/hawkular/metrics/counters

    now gives

    [{"id":"vertx.eventbus.publishedRemoteMessages","dataRetention":14,"type":"counter","tenantId":"com.acme"},{"id":"vertx.pool.worker.vert.x-internal-blocking.queuedCount","dataRetention":14,"type":"counter","tenantId":"com.acme"},{"id":"vertx.eventbus.receivedMessages","dataRetention":14,"type":"counter","tenantId":"com.acme"}, etc.