-
Notifications
You must be signed in to change notification settings - Fork 41.8k
Description
Prometheus metrics exposed via https://docs.spring.io/spring-boot/reference/actuator/metrics.html#actuator.metrics.export.prometheus, and very likely all served metrics currently don't support HTTP compressing even if scraper does send appropriate Accept-Encoding headers due to the Spring webserver not being configured appropriately?
Even for push metrics (e.g. OTLP) compression has to be explicitly enabled ...
- https://opentelemetry.io/docs/languages/java/configuration/#properties-exporters
- Provide auto-configuration for OpenTelemetry metrics #36546
Metrics are usually presented as Content-Type: text/plain, but Prometheus / OTEL also support protobuf and openmetrics (https://prometheus.io/docs/instrumenting/content_negotiation/#protocol-headers)
OpenTelemetry (https://opentelemetry.io/docs/specs/otlp/#otlphttp) standardized this to:
application/openmetrics-textapplication/openmetrics-protobuf
in the end this type of data is VERY compressible, >90%. Depending on the application and the amount of metrics, each scrape is hundreds of KBs so this adds up to substantial bandwidth savings, money even when running on public cloud infrastructure which changes for the amount of data transferred (across AZs).
I know SpringBoot already optionally supports HTTP compression via https://docs.spring.io/spring-boot/how-to/webserver.html#howto.webserver.enable-response-compression. This is something that has to be switched on explicitly, so looking at articles like https://dev.to/rock_win_c053fa5fb2399067/enabling-gzip-compression-in-spring-boot-for-faster-web-apps-3abe this is likely not universally known.
If I may quote Prometheus' @SuperQ (again) ... prometheus/prometheus#13166 (comment)
Compression is cheap on modern CPUs and saves 90% of bandwith - this should really be enabled by default and not something people find by accident or the hard when looking at their $Hyperscaler bill.