Prometheus plugin for pubsub
import (
"github.com/hmoragrega/pubsub"
pubsubprom "github.com/hmoragrega/pubsub-prometheus"
)
// Initialize a router with default metrics.
router := pubsubprom.MustInstrumentRouter(pubsub.Router{})
// Add the publisher middleware for publishing metrics.
publisher := pubsubprom.InstrumentPublisher(publisher)
pubsub_message_processed
(histogram
)pubsub_message_acknowledgements
(counter
)pubsub_message_checkpoint
(counter
)pubsub_message_consumed
(counter
)pubsub_message_published
(counter
)pubsub_message_publishing
(histogram
)
The names of the metrics can be tweaked in multiple ways:
The monitor accepts a namespace and subsystem option that will be applied to all metrics.
You can also tweak the name of a single metric and other parameters by adjusting the prometheus option struct.
You can pass custom constant labels to all the metric.
Most metrics share these common labels when available in the operation:
consumer
: name of the consumer.msg_name
: name of the message.msg_version
: version of the message.error
:true|false
if the monitored operation reported an error.
The amount of time it took to process a message in the consumer.
- Default name:
pubsub_message_processed
For every executed checkpoint while processing a message
- Default name:
pubsub_message_checkpoint
- Extra labels:
checkpoint
: the name of the checkpoint
The message acknowledgements operations.
- Default name:
pubsub_message_acknowledgements
- Extra labels:
operation
:ack|nack|re-schedule
Number of messages consumed by consumer.
- Default name:
pubsub_message_consumed
Number of messages published by publisher.
- Default name:
pubsub_message_published
A histogram with the result of publishing operations.
- Default name:
pubsub_message_publishing