client_java
GitHubToggle Dark/Light/Auto modeToggle Dark/Light/Auto modeToggle Dark/Light/Auto modeBack to homepage

Config

The Prometheus metrics library provides multiple options how to override configuration at runtime:

  • Properties file
  • System properties

Future releases will add more options, like configuration via environment variables.

Example:

io.prometheus.exporter.httpServer.port = 9401

The property above changes the port for the HTTPServer exporter to 9401.

  • Properties file: Add the line above to the properties file.
  • System properties: Use the command line parameter -Dio.prometheus.exporter.httpServer.port=9401 when starting your application.

Location of the Properties File

The properties file is searched in the following locations:

  • /prometheus.properties in the classpath. This is for bundling a properties file with your application.
  • System property -Dprometheus.config=/path/to/prometheus.properties.
  • Environment variable PROMETHEUS_CONFIG=/path/to/prometheus.properties.

Metrics Properties

NameJavadocNote
io.prometheus.metrics.exemplarsEnabledCounter.Builder.withExemplars()(1) (2)
io.prometheus.metrics.histogramNativeOnlyHistogram.Builder.nativeOnly()(2)
io.prometheus.metrics.histogramClassicOnlyHistogram.Builder.classicOnly()(2)
io.prometheus.metrics.histogramClassicUpperBoundsHistogram.Builder.classicUpperBounds()(3)
io.prometheus.metrics.histogramNativeInitialSchemaHistogram.Builder.nativeInitialSchema()
io.prometheus.metrics.histogramNativeMinZeroThresholdHistogram.Builder.nativeMinZeroThreshold()
io.prometheus.metrics.histogramNativeMaxZeroThresholdHistogram.Builder.nativeMaxZeroThreshold()
io.prometheus.metrics.histogramNativeMaxNumberOfBucketsHistogram.Builder.nativeMaxNumberOfBuckets()
io.prometheus.metrics.histogramNativeResetDurationSecondsHistogram.Builder.nativeResetDuration()
io.prometheus.metrics.summaryQuantilesSummary.Builder.quantile(double)(4)
io.prometheus.metrics.summaryQuantileErrorsSummary.Builder.quantile(double, double)(5)
io.prometheus.metrics.summaryMaxAgeSecondsSummary.Builder.maxAgeSeconds()
io.prometheus.metrics.summaryNumberOfAgeBucketsSummary.Builder.numberOfAgeBuckets()

Notes

(1) withExemplars() and withoutExemplars() are available for all metric types, not just for counters
(2) Boolean value. Format: property=true or property=false.
(3) Comma-separated list. Example: .005, .01, .025, .05, .1, .25, .5, 1, 2.5, 5, 10.
(4) Comma-separated list. Example: 0.5, 0.95, 0.99.
(5) Comma-separated list. If specified, the list must have the same length as io.prometheus.metrics.summaryQuantiles. Example: 0.01, 0.005, 0.005.

There’s one special feature about metric properties: You can set a property for one specific metric only by specifying the metric name. Example: Let’s say you have a histogram named latency_seconds.

io.prometheus.metrics.histogramClassicUpperBounds = 0.2, 0.4, 0.8, 1.0

The line above sets histogram buckets for all histograms. However:

io.prometheus.metrics.latency_seconds.histogramClassicUpperBounds = 0.2, 0.4, 0.8, 1.0

The line above sets histogram buckets only for the histogram named latency_seconds.

This works for all Metrics properties.

Exemplar Properties

NameJavadocNote
io.prometheus.exemplars.minRetentionPeriodSecondsExemplarsProperties.getMinRetentionPeriodSeconds()
io.prometheus.exemplars.maxRetentionPeriodSecondsExemplarsProperties.getMaxRetentionPeriodSeconds()
io.prometheus.exemplars.sampleIntervalMillisecondsExemplarsProperties.getSampleIntervalMilliseconds()

Exporter Properties

NameJavadocNote
io.prometheus.exporter.includeCreatedTimestampsExporterProperties.getIncludeCreatedTimestamps()(1)
io.prometheus.exporter.exemplarsOnAllMetricTypesExporterProperties.getExemplarsOnAllMetricTypes()(1)

(1) Boolean value, true or false. Default see Javadoc.

Exporter Filter Properties

NameJavadocNote
io.prometheus.exporter.filter.metricNameMustBeEqualToExporterFilterProperties.getAllowedMetricNames()(1)
io.prometheus.exporter.filter.metricNameMustNotBeEqualToExporterFilterProperties.getExcludedMetricNames()(2)
io.prometheus.exporter.filter.metricNameMustStartWithExporterFilterProperties.getAllowedMetricNamePrefixes()(3)
io.prometheus.exporter.filter.metricNameMustNotStartWithExporterFilterProperties.getExcludedMetricNamePrefixes()(4)

(1) Comma sparated list of allowed metric names. Only these metrics will be exposed.
(2) Comma sparated list of excluded metric names. These metrics will not be exposed.
(3) Comma sparated list of prefixes. Only metrics starting with these prefixes will be exposed.
(4) Comma sparated list of prefixes. Metrics starting with these prefixes will not be exposed.

Exporter HTTPServer Properties

NameJavadocNote
io.prometheus.exporter.httpServer.portHTTPServer.Builder.port()

Exporter OpenTelemetry Properties

NameJavadocNote
io.prometheus.exporter.opentelemetry.protocolOpenTelemetryExporter.Builder.protocol()(1)
io.prometheus.exporter.opentelemetry.endpointOpenTelemetryExporter.Builder.endpoint()
io.prometheus.exporter.opentelemetry.headersOpenTelemetryExporter.Builder.headers()(2)
io.prometheus.exporter.opentelemetry.intervalSecondsOpenTelemetryExporter.Builder.intervalSeconds()
io.prometheus.exporter.opentelemetry.timeoutSecondsOpenTelemetryExporter.Builder.timeoutSeconds()
io.prometheus.exporter.opentelemetry.serviceNameOpenTelemetryExporter.Builder.serviceName()
io.prometheus.exporter.opentelemetry.serviceNamespaceOpenTelemetryExporter.Builder.serviceNamespace()
io.prometheus.exporter.opentelemetry.serviceInstanceIdOpenTelemetryExporter.Builder.serviceInstanceId()
io.prometheus.exporter.opentelemetry.serviceVersionOpenTelemetryExporter.Builder.serviceVersion()
io.prometheus.exporter.opentelemetry.resourceAttributesOpenTelemetryExporter.Builder.resourceAttributes()(3)

(1) Protocol can be grpc or http/protobuf.
(2) Format: key1=value1,key2=value2
(3) Format: key1=value1,key2=value2

Many of these attributes can alternatively be configured via OpenTelemetry environment variables, like OTEL_EXPORTER_OTLP_ENDPOINT. The Prometheus metrics library has support for OpenTelemetry environment variables. See Javadoc for details.

Exporter PushGateway Properties

NameJavadocNote
io.prometheus.exporter.pushgateway.addressPushGateway.Builder.address()
io.prometheus.exporter.pushgateway.schemePushGateway.Builder.scheme()
io.prometheus.exporter.pushgateway.jobPushGateway.Builder.job()