Skip to content

Latest commit

 

History

History
 
 

metrics-examples

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

Vert.x Metrics Examples

Vert.x core provides a Service Provide Interface (SPI) for collecting metrics. The Dropwizard implementation collects these metrics in a Dropwizard registry that can be used for reporting in other system or can be queried via the Dropwizard MetricsService.

UI monitoring dashboard

This example is a UI monitoring dashboard built on top of the Dropwizard metrics implementation.

The dashboard uses the vertx-web eventbus bridge to push metrics periodically on the event bus. The metrics are retrieved from the MetricsService in Json format.

Run the dashboard either in your IDE or on the command line, then open your browser and hit link:http://localhost:8080 to see the dashboard

You can also launch the example using the vertx cli as follows:

# compile the example, you need to have built example-utils before.
mvn clean package

# java
vertx run io.vertx.example.metrics.dashboard.Dashboard -cp target/metrics-examples-3.7.0.jar:src/main/java/io/vertx/example/metrics/dashboard -Dvertx.metrics.options.enabled=true

# javascript
cd src/main/js/io/vertx/example/metrics/dashboard
vertx run dashboard.js -cp ./../../../../../../../../target/metrics-examples-3.7.0.jar:. -Dvertx.metrics.options.enabled=true


# groovy
cd src/main/groovy/io/vertx/example/metrics/dashboard
vertx run dashboard.groovy -cp ./../../../../../../../../target/metrics-examples-3.7.0.jar:. -Dvertx.metrics.options.enabled=true


# ruby
cd src/main/ruby/io/vertx/example/metrics/dashboard
vertx run dashboard.rb -cp ./../../../../../../../../target/metrics-examples-3.7.0.jar:. -Dvertx.metrics.options.enabled=true

To enable JMX append the following options: -Dvertx.metrics.options.jmxEnabled=true -Dvertx.metrics.options.jmxDomain=vertx. Then, if you open a JMX explorer (such the JConsole), in the list of beans you will find the Vert.x metrics under the vertx domain.

If you want to use Jolokia to expose the JMX metrics as a REST interface, download the Jolokia JVM agent from https://jolokia.org/download.html and create a JAVA_OPTS env variable as follow:

export JAVA_OPTS="-javaagent:path/to/jolokia-jvm-x.x.x-agent.jar=port=7777,host=localhost"

Once defined, relaunch the application with the JMX metrics enabled.

Monitoring for prometheus

This example is a monitoring setup for Prometheus via Dropwizard metrics.

The verticle uses Dropwizard metrics to register a Prometheus CollectorRegistry (in this case the defaultRegistry) which is bound to a router via MetricsHandler. To create some metrics data a counter "testCounter" is periodically incremented.

Run the verticle either in your IDE or on the command line, then open your browser and hit link:http://localhost:8080/metrics to see if the counter is increased.