Prometheus exporter for librdkafka.
This repository includes:
- A Go library to export librdkafka metrics in Prometheus exposition format.
- A daemon that exposes the same functionality over an HTTP API.
To get the library, run:
go get github.com/allsopp/librdkafka-exporter
The reference documentation for the latest release is available here.
First, clone this repository:
git clone https://github.com/allsopp/librdkafka-exporter
Then run the daemon:
cd librdkafka-exporter
go run main.go
Or build an executable and run that:
cd librdkafka-exporter
go build -o main main.go
./main
Alternatively, an example Dockerfile
for building a Docker container image to run the
daemon is included with this distribution.
The daemon exposes the following HTTP endpoints:
Making a POST /metrics
request will update the metric values.
-
The request body must be the JSON data returned from the
stats_cb
callback of librdkafka. -
The content type must be
application/json
, otherwise a415 Unsupported Media Type
status will be returned and the metrics will not be updated.
Making a GET /metrics
request will return the metric values in
Prometheus exposition format.
Making a GET /health
request will always return a 200 OK
if the daemon is running.
This is expected to be used for diagnostics and/or health probes.
The daemon can be configured with the following environment variables:
Environment variable | Description |
---|---|
LISTEN_ADDR |
The address and TCP port to listen on (defaults to :8080 ) |
READ_TIMEOUT |
Amount of time allowed to read request (defaults to 30s ) |
WRITE_TIMEOUT |
Amount of time allowed to write response (defaults to 30s ) |
SHUTDOWN_TIMEOUT |
Amount of time allowed for graceful shutdown (defaults to 10s ) |