Skip to content

Add HTTP compression support (via 'Accept-Encoding') for metrics (e.g. OTLP, Prometheus, ...) #48925

@frittentheke

Description

@frittentheke

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 ...

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-text
  • application/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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: declinedA suggestion or change that we don't feel we should currently apply

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions