Add broker_source label to all Prometheus metrics#45
Merged
Conversation
Adds a broker_source label (from BROKER_SOURCE env var) to every metric, alongside the existing pipeline label. Enables distinguishing MSK vs WarpStream consumers in Grafana during the ingestion migration.
There was a problem hiding this comment.
Pull request overview
Adds a broker_source Prometheus label across millpond metrics to support Grafana filtering during the Kafka ingestion migration (e.g., distinguishing MSK vs WarpStream consumers).
Changes:
- Add
broker_sourcetoConfig, sourced fromBROKER_SOURCEenv var (default""). - Add
broker_sourcelabel to all Prometheus metric definitions and update metrics initialization to bind bothpipelineandbroker_source. - Wire
broker_sourcethroughmain()intometrics.init(), and update unit test config fixture.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
millpond/config.py |
Adds broker_source config field loaded from BROKER_SOURCE. |
millpond/metrics.py |
Adds broker_source label to all metrics and binds it during init(). |
millpond/main.py |
Passes cfg.broker_source into metrics.init(). |
tests/unit/test_consumer.py |
Updates Config fixture to include broker_source. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add a
broker_sourcelabel to every Prometheus metric, enabling filtering by broker type (e.g.mskvswarpstream) in Grafana during the ingestion migration to WarpStream.Changes
config.py: Newbroker_sourcefield, read fromBROKER_SOURCEenv var (default empty)metrics.py:broker_sourceadded as a label to all metric definitions._AutoPipelineLabelsrenamed to_AutoCommonLabelsto inject bothpipelineandbroker_source.main.py: Passesbroker_sourcetometrics.init()tests/unit/test_consumer.py: Fixture updated for new config fieldDeployment
Requires companion charts PR (PostHog/charts) to set
BROKER_SOURCEenv var:BROKER_SOURCE=mskBROKER_SOURCE=warpstreamBackward compatible — if
BROKER_SOURCEis unset, the label defaults to empty string.