-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Add Kafka Cluster Monitoring #21736
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
piochelepiotr
wants to merge
12
commits into
master
Choose a base branch
from
piotr-wolski/add-kafka-integration
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+2,665
−5
Draft
Add Kafka Cluster Monitoring #21736
Changes from 8 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
ab60caf
Update kafka_consumer integration to collect Kafka cluster data
piochelepiotr 8e91387
Add caching & optimize
piochelepiotr b3c4ac0
add changelog
piochelepiotr 6d9e065
update
piochelepiotr 5f496a3
update requests version
piochelepiotr b360b2d
update
piochelepiotr 8e8f795
fix license
piochelepiotr cf1e108
sync models
piochelepiotr df793ae
Add controllers
piochelepiotr b762db5
lint
piochelepiotr a88d7dd
update unit
piochelepiotr 03ccd9c
update units
piochelepiotr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Add Kafka Cluster Monitoring |
611 changes: 611 additions & 0 deletions
611
kafka_consumer/datadog_checks/kafka_consumer/cluster_metadata.py
Large diffs are not rendered by default.
Oops, something went wrong.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -83,6 +83,18 @@ def __init__(self, init_config, instance, log) -> None: | |
| # Data Streams live messages | ||
| self.live_messages_configs = instance.get('live_messages_configs', []) | ||
|
|
||
| # Cluster metadata collection (single flag to enable all cluster monitoring) | ||
| enable_cluster_monitoring = is_affirmative(instance.get('enable_cluster_monitoring', False)) | ||
|
|
||
| # If cluster monitoring is enabled, collect all metadata | ||
| self._collect_broker_metadata = enable_cluster_monitoring | ||
| self._collect_topic_metadata = enable_cluster_monitoring | ||
| self._collect_consumer_group_metadata = enable_cluster_monitoring | ||
|
Comment on lines
+90
to
+92
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| # Schema registry: auto-enable if URL is provided | ||
| self._schema_registry_url = instance.get('schema_registry_url') | ||
| self._collect_schema_registry = enable_cluster_monitoring and self._schema_registry_url is not None | ||
|
|
||
| def validate_config(self): | ||
| if not self._kafka_connect_str: | ||
| raise ConfigurationError('`kafka_connect_str` is required') | ||
|
|
||
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| # Kafka Consumer Integration - Local Testing | ||
|
|
||
| ## Setup | ||
|
|
||
| ```bash | ||
| # 1. Set your Datadog API key | ||
| cp env.template .env | ||
| # Edit .env and add DD_API_KEY | ||
|
|
||
| # 2. Start everything | ||
| docker compose -f docker-compose-test.yml up -d | ||
|
|
||
| # 3. Verify | ||
| docker exec datadog-agent agent status | grep kafka_consumer | ||
| ``` | ||
|
|
||
| ## What's Running | ||
|
|
||
| - Kafka with 6 topics (orders, users, events, payments, analytics, notifications) | ||
| - Schema Registry with 5 AVRO schemas | ||
| - Producer generating messages every 10s | ||
| - 5 consumer groups (one intentionally slow to create lag) | ||
| - Datadog Agent with `enable_cluster_monitoring: true` | ||
|
|
||
| ## View Data | ||
|
|
||
| Metrics: https://app.datadoghq.com/metric/explorer | ||
| - Filter by `kafka_cluster_id:WxsTRn91ShWgIdlNQWBTxg` | ||
| - Example metrics: `kafka.broker.count`, `kafka.topic.size`, `kafka.consumer_lag` | ||
|
|
||
| Dashboard: Import `kafka_cluster_dashboard.json` at https://app.datadoghq.com/dashboard/lists | ||
|
|
||
| ## Stop | ||
|
|
||
| ```bash | ||
| docker compose -f docker-compose-test.yml down -v | ||
| ``` |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| init_config: | ||
|
|
||
| instances: | ||
| - kafka_connect_str: kafka:29092 | ||
|
|
||
| # Monitor all consumer groups | ||
| monitor_unlisted_consumer_groups: true | ||
|
|
||
| # Enable cluster metadata collection | ||
| collect_broker_metadata: true | ||
| collect_topic_metadata: true | ||
| collect_consumer_group_metadata: true | ||
| collect_schema_registry: true | ||
|
|
||
| schema_registry_url: http://schema-registry:8081 | ||
|
|
||
| # Enable data streams for lag in seconds | ||
| data_streams_enabled: true | ||
|
|
||
| min_collection_interval: 30 | ||
|
|
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not broker id as well? Cardinality? No info available? Something else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most metrics are cluster wide metrics, so not specific to only one broker. I will make sure that metrics specific to one broker are tagged with broker id.