Consumer Group Metrics Endpoint
This page describes the Lenses-compatible consumer group metrics endpoint exposed by HQ.
HQ exposes consumer group lag and state as Prometheus gauges in the same shape the Lenses Agent served them, so dashboards and alerts written against it keep working when the data behind them comes from HQ. The one addition is an environment label on every series, since a single HQ covers many Kafka environments.
Endpoint
GET /kafka-metrics
HEAD /kafka-metricsThe endpoint is served on HQ's Prometheus listener, not the HTTP API listener. The address is set by the metrics.prometheusAddress configuration setting (default :9090), alongside GET /metrics.
200
Prometheus text exposition of the selected series.
400
metrics= names a metric that does not exist; the body lists the valid names.
405
Any method other than GET or HEAD (Allow: GET, HEAD).
500
Fetching the data failed.
Parameters
Both parameters are optional, comma-separated and repeatable, so ?environment=a,b and ?environment=a&environment=b are equivalent. Values are trimmed and deduplicated, and omitting a parameter means no filter on that dimension.
environment=
Environment names
Serve only these environments.
metrics=
One or more metric names
Serve only these metric families.
Exposed metrics
The endpoint exposes six gauge families:
lenses_consumer_group_state
environment, consumerGroup, state
Group-scoped
The group's state, carried in the state label.
lenses_consumer_group_max_lag
environment, consumerGroup
Group-scoped
Highest lag in records across the partitions the group consumes.
lenses_consumer_group_max_lag_seconds
environment, consumerGroup
Group-scoped
That same maximum as an estimated time behind, in seconds.
lenses_topic_consumer_lag
environment, topic, consumerGroup
Partition-scoped
The group's lag in records for one topic, summed over its partitions.
lenses_partition_consumer_lag
environment, topic, partition, consumerGroup
Partition-scoped
Lag in records for one group, topic and partition.
lenses_partition_consumer_lag_seconds
environment, topic, partition, consumerGroup
Partition-scoped
That same lag as an estimated time behind, in seconds.
The state label is one of Stable, Rebalancing, NoActiveMembers, ExistsNot or Unknown.
Scrape cost
A scrape returns every series the filters allow, and its cost is set by how many topic partitions HQ holds in total, across all environments. Response size, memory and scrape time all scale with that total partition count.
Up to a couple of hundred thousand total topic partitions, an unfiltered scrape should be comfortable. Past that, measure it against your own hardware and setup to confirm the scrape completes within the time Prometheus allows it, and reach for the filters below if it does not.
Choosing a scrape strategy
No filters
Everything in one scrape. Use this while the total topic partition count across all environments stays within a couple of hundred thousand.
One scrape per environment
For a large total partition count, configure one Prometheus target per environment and scrape each individually. Each target then costs one environment's worth of work, and all six metric families are still served.
Group-scoped families only, all environments
For when a single environment is already too large to scrape. These three families never touch per-partition data, so their cost tracks consumer group count rather than partition count.
Both filters together
The filters compose, so a single target can narrow on both dimensions at once. This suits a setup where one environment is large enough that only group-level alerting is wanted from it, while the smaller environments are still scraped in full from their own targets.
Last updated
Was this helpful?

