Skip to content

Add snappy encoding support for /metrics endpoint#518

Merged
beorn7 merged 1 commit intoprometheus:masterfrom
danteu:issue441
Dec 1, 2022
Merged

Add snappy encoding support for /metrics endpoint#518
beorn7 merged 1 commit intoprometheus:masterfrom
danteu:issue441

Conversation

@danteu
Copy link
Contributor

@danteu danteu commented Nov 29, 2022

  • Replace gunzipRequest() with decodeRequest() where the decoding-method is determined based on the "Content-Encoding" header in a switch statement.
  • Add support for snappy-encoded HTTP bodies.
$ echo "some_metric 1" | curl --data-binary @- http://localhost:9091/metrics/job/myjob/instance/myinstance
$ curl http://localhost:9091/metrics/
# TYPE some_metric untyped
some_metric{instance="myinstance",job="myjob"} 1

$ echo "some_gziped_metric 2" | gzip | curl -H "Content-Encoding: gzip" --data-binary @- http://localhost:9091/metrics/job/myjob/instance/myinstance
$ curl http://localhost:9091/metrics/
# TYPE some_gzipped_metric untyped
some_gziped_metric{instance="myinstance",job="myjob"} 2

$ echo "some_snappied_metric 3" | snzip | curl -H 'Content-Encoding: snappy' --data-binary @- http://localhost:9091/metrics/job/myjob/instance/myinstance
$ curl http://localhost:9091/metrics/
# TYPE some_snappied_metric untyped
some_snappied_metric{instance="myinstance",job="myjob"} 3

Resolves #441

@danteu danteu force-pushed the issue441 branch 3 times, most recently from 5e214b5 to 4862e71 Compare November 29, 2022 21:32
Copy link
Member

@beorn7 beorn7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much. Just a few syntax nitpicks (for English, not even for Go ;).

* Replace gunzipRequest() with decodeRequest() where the decoding-method
is determined based on the "Content-Encoding" header in a switch
statement.
* Add support for snappy-encoded HTTP bodies.

Signed-off-by: Daniel Teunis <daniel@teunis.cc>
Copy link
Member

@beorn7 beorn7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again.

@beorn7 beorn7 merged commit c0d0c3e into prometheus:master Dec 1, 2022
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.

Feature request: snappy support for pushgateway

2 participants