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.
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
.
Name | Javadoc | Note |
---|---|---|
io.prometheus.metrics.exemplarsEnabled | Counter.Builder.withExemplars() | (1) (2) |
io.prometheus.metrics.histogramNativeOnly | Histogram.Builder.nativeOnly() | (2) |
io.prometheus.metrics.histogramClassicOnly | Histogram.Builder.classicOnly() | (2) |
io.prometheus.metrics.histogramClassicUpperBounds | Histogram.Builder.classicUpperBounds() | (3) |
io.prometheus.metrics.histogramNativeInitialSchema | Histogram.Builder.nativeInitialSchema() | |
io.prometheus.metrics.histogramNativeMinZeroThreshold | Histogram.Builder.nativeMinZeroThreshold() | |
io.prometheus.metrics.histogramNativeMaxZeroThreshold | Histogram.Builder.nativeMaxZeroThreshold() | |
io.prometheus.metrics.histogramNativeMaxNumberOfBuckets | Histogram.Builder.nativeMaxNumberOfBuckets() | |
io.prometheus.metrics.histogramNativeResetDurationSeconds | Histogram.Builder.nativeResetDuration() | |
io.prometheus.metrics.summaryQuantiles | Summary.Builder.quantile(double) | (4) |
io.prometheus.metrics.summaryQuantileErrors | Summary.Builder.quantile(double, double) | (5) |
io.prometheus.metrics.summaryMaxAgeSeconds | Summary.Builder.maxAgeSeconds() | |
io.prometheus.metrics.summaryNumberOfAgeBuckets | Summary.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.
Name | Javadoc | Note |
---|---|---|
io.prometheus.exemplars.minRetentionPeriodSeconds | ExemplarsProperties.getMinRetentionPeriodSeconds() | |
io.prometheus.exemplars.maxRetentionPeriodSeconds | ExemplarsProperties.getMaxRetentionPeriodSeconds() | |
io.prometheus.exemplars.sampleIntervalMilliseconds | ExemplarsProperties.getSampleIntervalMilliseconds() |
Name | Javadoc | Note |
---|---|---|
io.prometheus.exporter.includeCreatedTimestamps | ExporterProperties.getIncludeCreatedTimestamps() | (1) |
io.prometheus.exporter.exemplarsOnAllMetricTypes | ExporterProperties.getExemplarsOnAllMetricTypes() | (1) |
(1) Boolean value, true
or false
. Default see Javadoc.
Name | Javadoc | Note |
---|---|---|
io.prometheus.exporter.filter.metricNameMustBeEqualTo | ExporterFilterProperties.getAllowedMetricNames() | (1) |
io.prometheus.exporter.filter.metricNameMustNotBeEqualTo | ExporterFilterProperties.getExcludedMetricNames() | (2) |
io.prometheus.exporter.filter.metricNameMustStartWith | ExporterFilterProperties.getAllowedMetricNamePrefixes() | (3) |
io.prometheus.exporter.filter.metricNameMustNotStartWith | ExporterFilterProperties.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.
Name | Javadoc | Note |
---|---|---|
io.prometheus.exporter.httpServer.port | HTTPServer.Builder.port() |
Name | Javadoc | Note |
---|---|---|
io.prometheus.exporter.opentelemetry.protocol | OpenTelemetryExporter.Builder.protocol() | (1) |
io.prometheus.exporter.opentelemetry.endpoint | OpenTelemetryExporter.Builder.endpoint() | |
io.prometheus.exporter.opentelemetry.headers | OpenTelemetryExporter.Builder.headers() | (2) |
io.prometheus.exporter.opentelemetry.intervalSeconds | OpenTelemetryExporter.Builder.intervalSeconds() | |
io.prometheus.exporter.opentelemetry.timeoutSeconds | OpenTelemetryExporter.Builder.timeoutSeconds() | |
io.prometheus.exporter.opentelemetry.serviceName | OpenTelemetryExporter.Builder.serviceName() | |
io.prometheus.exporter.opentelemetry.serviceNamespace | OpenTelemetryExporter.Builder.serviceNamespace() | |
io.prometheus.exporter.opentelemetry.serviceInstanceId | OpenTelemetryExporter.Builder.serviceInstanceId() | |
io.prometheus.exporter.opentelemetry.serviceVersion | OpenTelemetryExporter.Builder.serviceVersion() | |
io.prometheus.exporter.opentelemetry.resourceAttributes | OpenTelemetryExporter.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.
Name | Javadoc | Note |
---|---|---|
io.prometheus.exporter.pushgateway.address | PushGateway.Builder.address() | |
io.prometheus.exporter.pushgateway.scheme | PushGateway.Builder.scheme() | |
io.prometheus.exporter.pushgateway.job | PushGateway.Builder.job() |