Skip to content
This repository has been archived by the owner on Dec 19, 2023. It is now read-only.

Library for prometheus instrumentation in Dropwizard based apps.

License

Notifications You must be signed in to change notification settings

alphagov/gds_metrics_dropwizard

Repository files navigation

GDS metrics for Dropwizard

GOV.UK Verify has closed

This repository is out of date and has been archived

GDS Metrics are in Alpha and these instructions are subject to change.

The GDS Dropwizard metrics library enables your Java web app to export performance data to Prometheus and can be added to your app using this library.

The library is a thin wrapper around the Prometheus instrumentation library for JVM applications that adds a PrometheusBundle you can include in your dropwizard app.

Once you’ve added the library, metrics data is served from an endpoint on your app and is scraped by Prometheus. This data can be turned into performance dashboards using Grafana.

You can read more about the Reliability Engineering monitoring solution here.

Before using GDS metrics

Before using GDS metrics you should have:

  • created a Dropwizard app

How to build your project

Add your library as a dependency to your project.

Maven
```
<dependency>
    <groupId>uk.gov.ida</groupId>
    <artifactId>gds-metrics-dropwizard</artifactId>
    <version>0.7.0</version>
</dependency>
```

Gradle
```
implementation 'uk.gov.ida:gds-metrics-dropwizard:0.7.0'
```

The metrics will be exposed at the path /prometheus/metrics on the admin port.

How to Change your project

Add the PrometheusBundle:

public void initialize(final Bootstrap<ExampleConfiguration> bootstrap) {
    ...
    bootstrap.addBundle(new PrometheusBundle());
    ...
}

Your metrics endpoint will now be available in your production environment.

How to configure custom metrics

While common metrics are recorded by default, you can also:

  • record your own metrics such as how many users are signed up for your service, or how many emails it's sent
  • use the Prometheus interface to set your own metrics as the metrics Dropwizard library is built on top of the prometheus_java_client

You can read more about the different types of metrics available in the Prometheus documentation.

Contributing

GDS Reliability Engineering welcome contributions. We'd appreciate it if you write tests with your changes and document them where appropriate, this will help us review them quickly.

Releasing a new version

To release a new version:

  • bump the version in gradle.properties and the dependencies in the README and commit
  • tag with the new version number and push the tag (eg git tag 0.1.3; git push --tags)
  • travis will build and deploy the new version to bintray
  • bump the version in gradle.properties to the next SNAPSHOT (eg 0.1.3-SNAPSHOT)

Licence

This project is licensed under the MIT License.