com.expediagroup:dropwizard-prometheus-bundle

Dropwizard bundle to integrate dropwizard metrics with prometheus

License

License

Categories

Categories

DropWizard Container Microservices Prometheus Application Testing & Monitoring Monitoring
GroupId

GroupId

com.expediagroup
ArtifactId

ArtifactId

dropwizard-prometheus-bundle
Last Version

Last Version

1.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

com.expediagroup:dropwizard-prometheus-bundle
Dropwizard bundle to integrate dropwizard metrics with prometheus
Project URL

Project URL

https://github.com/eleduardo/dropwizard-prometheus-bundle
Source Code Management

Source Code Management

https://github.com/homeaway/dropwizard-prometheus-bundle

Download dropwizard-prometheus-bundle

How to add to project

<!-- https://jarcasting.com/artifacts/com.expediagroup/dropwizard-prometheus-bundle/ -->
<dependency>
    <groupId>com.expediagroup</groupId>
    <artifactId>dropwizard-prometheus-bundle</artifactId>
    <version>1.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.expediagroup/dropwizard-prometheus-bundle/
implementation 'com.expediagroup:dropwizard-prometheus-bundle:1.0.0'
// https://jarcasting.com/artifacts/com.expediagroup/dropwizard-prometheus-bundle/
implementation ("com.expediagroup:dropwizard-prometheus-bundle:1.0.0")
'com.expediagroup:dropwizard-prometheus-bundle:jar:1.0.0'
<dependency org="com.expediagroup" name="dropwizard-prometheus-bundle" rev="1.0.0">
  <artifact name="dropwizard-prometheus-bundle" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.expediagroup', module='dropwizard-prometheus-bundle', version='1.0.0')
)
libraryDependencies += "com.expediagroup" % "dropwizard-prometheus-bundle" % "1.0.0"
[com.expediagroup/dropwizard-prometheus-bundle "1.0.0"]

Dependencies

compile (4)

Group / Artifact Type Version
io.dropwizard : dropwizard-core jar
io.dropwizard.metrics : metrics-core jar
io.prometheus : simpleclient_dropwizard jar 0.8.0
io.prometheus : simpleclient_servlet jar 0.8.0

provided (1)

Group / Artifact Type Version
org.projectlombok : lombok jar 1.18.12

test (4)

Group / Artifact Type Version
org.junit.jupiter : junit-jupiter-api jar 5.6.0
org.junit.jupiter : junit-jupiter-engine jar 5.6.0
io.dropwizard : dropwizard-testing jar
org.assertj : assertj-core jar 3.15.0

Project Modules

There are no modules declared in this project.

dropwizard-prometheus-bundle

Build Status

This bundle allows for a quick drop-in enablement of prometheus exposition format in dropwizard applications. The bundle allows a user to integrate and configure the prometheus dropwizard metrcis bridge and the exposition servlet into a dropwizard application.

Usage

Step 1- Add the PrometeusBundleConfig attribute to your application configuration class, add a

public class YourApplicationConfiguration extends Configuration{
    PrometeusBundleConfig prometheusConfiguration;
    
     public PrometheusBundleConfig getPrometheusBundleConfig() {
        return this.prometheusBundleConfig;
     }
}

Step 2- Add the bundle to your application

In your application class subscribe the bundle in the initialize method using the bootstrap.

public class YourApplication extends Application<YourApplicationConfiguration>{
    
     public void initialize(Bootstrap<DropwizardtestConfiguration> bootstrap) {
         //....
         bootstrap.addBundle(new PrometheusBundle<>(YourApplicationConfiguration::getPrometheusBundleConfig));
         //....
     }
     
}

Note: the bundle constructor will take a function to extract the config, just pass your getter.

Step 3- Set your configuration

The bundle will default to subscribing a /metrics under the admin servlet to expose the metrics.

Configuration

The following configuration options are supported by the bundle by adding the following to your yaml file

Override the endpoint path

prometheusConfig:
  scrapePath: /newPath

Custom metric mapping

Since dropwizard metrics do not support labels you can add mapping actions to re-normalize names and provide labels from the original tokenized name. Refer to the prometheus client guide for more information.

prometheusConfig:
  mapperConfig:
    - matchField: "com.request.*.value"
      matchName: "ContextHandler.requests"
      labels: {"method":"${0}"}
    - matchField: "com.test.*.value.*"
      matchName: "testName.value"
      labels: {"method":"${0}", "value":"${1}"}

Static tag addition

Adding static tags from the client is considered and anti pattern and should be avoided since it is the prometheus server in the job configuration that should do this. That said, in the advent of OpenMetrics this might be something that could help specially if prometheus is not the scraper. Use this at your own discretion

prometheusConfig: customLabels: {"mylabel":"myvalue"}

com.expediagroup

HomeAway

Versions

Version
1.0.0
0.0.2
0.0.1