Prometheus Java Client Library

Introduction

The Prometheus Java client library is a Java metrics library provided by the Prometheus community.

Instana's com.instana.plugin.java will automatically detect the Prometheus Java Client library, and the metrics are shown on the JVM dashboard.

This page describes the automatic instrumentation of the Prometheus Java client library, as well as Micrometer's Prometheus meter registry. If you are looking for a way to scrape metrics from a Prometheus exporter via HTTP, or to configure the Instana agent as a Prometheus remote write endpoint, see Prometheus.

Screenshot: Prometheus Java Client Metrics

Configuration

All configuration options are optional. Instana monitors metrics from the Prometheus Java client library with reasonable default values without requiring manual configuration.

However, you can overwrite the defaults by adding a prometheusMetricCollection section under com.instana.plugin.java in your agent's configuration.yaml file, as illustrated in the following example:

com.instana.plugin.java:
  prometheusMetricCollection:
    enabled: true
    limit: 200
    pollIntervalSeconds: 15
    excludeMetricNamesStartingWith:
      - jvm
      - process
    excludeMetricsMatching:
      - eu-central-1

The following configuration options are supported:

Monitoring Custom Collector Registries

By default, the Prometheus Java Client library registers all metrics with a global CollectorRegistry.defaultRegistry. In that case, Instana will find the registered metrics automatically and monitor them by default.

However, you might have your metrics registered with a custom CollectorRegistry in your code. In that case, you need to include a line of code to inform Instana about your custom collector registry. Instana provides a prometheus-java-library-integration dependency for that purpose, documentation can be found on github.com/instana/prometheus-java-library-integration.

Integration with Micrometer

You might not use the Prometheus Java Client library directly, but indirectly via Micrometer's Prometheus Meter Registry. If you want to keep that setup and see the Prometheus metrics in Instana, you can use our prometheus-java-library-integration to monitor the PrometheusMeterRegistry with Instana. Documentation can be found on github.com/instana/prometheus-java-library-integration.