Read metrics from a Message Queue in Json format and expose them in a Prometheus compatible format.
Currently only works for MQTT compatible MQs.
make build
builds the mq2prom
binary which can be run directly. By default metrics are exposed on port 9641.
Alternatively, the provided Docker image can be used directly.
Consult the provided payload.schema.json
for the JSON Schema specification of the expected metric payload message on the MQ. This had been built taking into account the Prometheus constraints on metric and label names. Validate your json payloads against this schema using tools specified here. Currently, the code does not use the schema for validation.
Note: all relevant metrics have to be configured in config.yaml
to be exported. You are also recommended to following the Prometheus naming guidelines.
Run unit tests:
go test ./...
For an end-to-end test, make sure that a MQTT compatible MQ is running at the port specified in the config file config.yaml
. Run this binary.
Submit a message of the form '[{"name": "simple_metric", "value": 10, "labels": {"label1": "value1"}}]'
onto the MQ.
Now, check that the metric is showing up in the metrics:
curl localhost:9641/metrics | grep "simple_metric"
Mqtt2prometheus is the inspiration for this project, but falls short on several fronts:
- Focused on Sensor devices.
- Works with data coming in from multiple topics - which is a counter-feature.
- Does not allow generic labelling of metrics.
- Does not support Histogram and Summary metric types.
Licensed under Apache License 2.0.