Skip to content

Conversation

@aknuds1
Copy link
Contributor

@aknuds1 aknuds1 commented Dec 25, 2025

Summary

The receiver was sending HTTP 204 No Content before calling ConsumeMetrics(), so if the consumer failed, clients incorrectly thought data was delivered. This violates the Prometheus Remote Write 2.0 specification which states:

Receivers MUST NOT return a 2xx HTTP status code if any of the pieces of sent data known to the Receiver were NOT written successfully.

Changes

  • Move WriteHeader(204) to after ConsumeMetrics() succeeds
  • Return 400 Bad Request for permanent consumer errors
  • Return 500 Internal Server Error for retryable errors
  • Add tests for consumer error handling

Impact

Without this fix, when a downstream consumer fails (e.g., backend unavailable, memory limiter rejecting batches, exporter failures), Prometheus clients receive a success response and won't retry, leading to silent data loss.

Testing

Added TestHandlePRWConsumerResponse with sub-tests:

  • success returns 204 - verifies normal operation
  • retryable error returns 500 - verifies temporary failures return 500
  • permanent error returns 400 - verifies permanent failures return 400

@aknuds1 aknuds1 force-pushed the arve/prom-remote-write-silent-loss branch from a039576 to 23971f0 Compare December 25, 2025 10:07
…umer failure

The receiver was sending HTTP 204 No Content before calling ConsumeMetrics(),
so if the consumer failed, clients incorrectly thought data was delivered.
This violates the Prometheus Remote Write spec which states receivers MUST NOT
return 2xx if data was not successfully written.

Changes:
- Move WriteHeader(204) to after ConsumeMetrics() succeeds
- Return 400 Bad Request for permanent consumer errors
- Return 500 Internal Server Error for retryable errors
- Add tests for consumer error handling

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
@aknuds1 aknuds1 force-pushed the arve/prom-remote-write-silent-loss branch from 23971f0 to 85f883a Compare December 25, 2025 10:11
@aknuds1 aknuds1 marked this pull request as ready for review December 25, 2025 10:11
@aknuds1 aknuds1 requested review from a team, ArthurSens and dashpole as code owners December 25, 2025 10:12
@github-actions github-actions bot requested a review from perebaj December 25, 2025 10:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants