client_java
Formats | client_javaOpen NavigationClose NavigationGitHubToggle Dark/Light/Auto modeToggle Dark/Light/Auto modeToggle Dark/Light/Auto modeBack to homepageClose Menu BarOpen Menu Bar - prometheus.github.io Formats | client_javaOpen NavigationClose NavigationGitHubToggle Dark/Light/Auto modeToggle Dark/Light/Auto modeToggle Dark/Light/Auto modeBack to homepageClose Menu BarOpen Menu Bar - prometheus.github.io Formats | client_javaOpen NavigationClose NavigationGitHubToggle Dark/Light/Auto modeToggle Dark/Light/Auto modeToggle Dark/Light/Auto modeBack to homepageClose Menu BarOpen Menu Bar - prometheus.github.io Formats | client_javaOpen NavigationClose NavigationGitHubToggle Dark/Light/Auto modeToggle Dark/Light/Auto modeToggle Dark/Light/Auto modeBack to homepageClose Menu BarOpen Menu Bar - prometheus.github.io Formats | client_javaOpen NavigationClose NavigationGitHubToggle Dark/Light/Auto modeToggle Dark/Light/Auto modeToggle Dark/Light/Auto modeBack to homepageClose Menu BarOpen Menu Bar - prometheus.github.io

Formats

All exporters the following exposition formats:

  • OpenMetrics text format
  • Prometheus text format
  • Prometheus protobuf format

Moreover, gzip encoding is supported for each of these formats.

OpenMetrics 2.0 Preview

The library also includes an experimental OpenMetrics 2.0 writer. It is disabled by default and must be enabled explicitly. See OpenMetrics 2.0 Preview.

Scraping with a Prometheus server

The Prometheus server sends an Accept header to specify which format is requested. By default, the Prometheus server will scrape OpenMetrics text format with gzip encoding. If the Prometheus server is started with --enable-feature=native-histograms, it will scrape Prometheus protobuf format instead.

Viewing with a Web Browser

If you view the /metrics endpoint with your Web browser you will see Prometheus text format. For quick debugging of the other formats, exporters provide a debug URL parameter:

  • /metrics?debug=openmetrics: View OpenMetrics text format.
  • /metrics?debug=text: View Prometheus text format.
  • /metrics?debug=prometheus-protobuf: View a text representation of the Prometheus protobuf format.

Exclude protobuf exposition format

You can exclude the protobuf exposition format by including the prometheus-metrics-exposition-textformats module and excluding the prometheus-metrics-exposition-formats module in your build file.

For example, in Maven:

<dependencies>
  <dependency>
      <groupId>io.prometheus</groupId>
      <artifactId>prometheus-metrics-exporter-httpserver</artifactId>
      <exclusions>
          <exclusion>
              <groupId>io.prometheus</groupId>
              <artifactId>prometheus-metrics-exposition-formats</artifactId>
          </exclusion>
      </exclusions>
  </dependency>
  <dependency>
      <groupId>io.prometheus</groupId>
      <artifactId>prometheus-metrics-exposition-textformats</artifactId>
  </dependency>
</dependencies>

Exclude the shaded protobuf classes

You can exclude the shaded protobuf classes including the prometheus-metrics-exposition-formats-no-protobuf module and excluding the prometheus-metrics-exposition-formats module in your build file.

If you are using the PushGateway in a shaded jar with minimizeJar=true, do not exclude the protobuf classes. The PushGateway loads the protobuf writer implementation via reflection, so the full prometheus-metrics-exposition-formats artifact must stay on the classpath and the relevant packages must be preserved during shading. See the PushGateway docs for the recommended Maven Shade configuration.

For example, in Maven:

<dependencies>
  <dependency>
      <groupId>io.prometheus</groupId>
      <artifactId>prometheus-metrics-exporter-httpserver</artifactId>
      <exclusions>
          <exclusion>
              <groupId>io.prometheus</groupId>
              <artifactId>prometheus-metrics-exposition-formats</artifactId>
          </exclusion>
      </exclusions>
  </dependency>
  <dependency>
      <groupId>io.prometheus</groupId>
      <artifactId>prometheus-metrics-exposition-formats-no-protobuf</artifactId>
  </dependency>
</dependencies>

Exclude the shaded otel classes

You can exclude the shaded otel classes including the prometheus-metrics-exporter-opentelemetry-no-otel module and excluding the prometheus-metrics-exporter-opentelemetry module in your build file.

For example, in Maven:

<dependencies>
  <dependency>
      <groupId>io.prometheus</groupId>
      <artifactId>prometheus-metrics-exporter-opentelemetry</artifactId>
      <exclusions>
          <exclusion>
              <groupId>io.prometheus</groupId>
              <artifactId>prometheus-metrics-exporter-opentelemetry</artifactId>
          </exclusion>
      </exclusions>
  </dependency>
  <dependency>
      <groupId>io.prometheus</groupId>
      <artifactId>prometheus-metrics-exporter-opentelemetry-no-otel</artifactId>
  </dependency>
</dependencies>