Skip to content

fix(metrics): send a Content-Type with the Prometheus metrics - #270

Open
shanurwan wants to merge 1 commit into
Blockstream:new-indexfrom
shanurwan:fix/metrics-content-type
Open

shanurwan wants to merge 1 commit into
Blockstream:new-indexfrom
shanurwan:fix/metrics-content-type

Conversation

@shanurwan

Copy link
Copy Markdown

The --monitoring-addr endpoint responds without a Content-Type header. Prometheus 3 rejects targets like that unless fallback_scrape_protocol is set for them, so a default Prometheus 3 setup shows electrs as down:

health=down  lastError="non-compliant scrape target sending blank Content-Type and no fallback_scrape_protocol specified for target"

This sets the header from the encoder (text/plain; version=0.0.4, the text exposition format the endpoint already serves). The body is unchanged.

Tests

  • New unit test metrics::tests::metrics_endpoint_sets_prometheus_content_type starts the metrics server on a free port and checks the header and body. It fails on new-index (left: "") and passes with this change.
  • cargo fmt --check and cargo check --all-targets (also with --features liquid) are clean.
  • Live, against a testnet4 electrs with a minimal Prometheus 3.15.1 config and no fallback: down with the error above before, up with 438 series after.

The monitoring endpoint responded without a Content-Type header. Prometheus 3
refuses such targets unless fallback_scrape_protocol is configured, marking
them down with "non-compliant scrape target sending blank Content-Type".

Set the text exposition format's content type from the encoder.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants