-
Notifications
You must be signed in to change notification settings - Fork 2
Test stack producer consumer phases #43
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -7,10 +7,21 @@ BOOTSTRAP_SERVER="kafka:29092" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| TOPIC1="test-topic" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| TOPIC2="high-volume-topic" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| GROUP_ID="test-consumer-group" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| GRAFANA_URL="http://grafana:3000" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Message counter | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| MSG_COUNT=0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Function to create Grafana annotation for phase visibility | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| annotate() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| local text="$1" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| local tags="$2" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| curl -s -X POST "$GRAFANA_URL/api/annotations" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -H "Content-Type: application/json" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -d "{\"text\": \"$text\", \"tags\": [$tags]}" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+15
to
+21
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Function to create Grafana annotation for phase visibility | |
| annotate() { | |
| local text="$1" | |
| local tags="$2" | |
| curl -s -X POST "$GRAFANA_URL/api/annotations" \ | |
| -H "Content-Type: application/json" \ | |
| -d "{\"text\": \"$text\", \"tags\": [$tags]}" \ | |
| # Helper to escape strings for JSON context | |
| json_escape() { | |
| local str="$1" | |
| # Escape backslashes and double quotes | |
| str=${str//\\/\\\\} | |
| str=${str//\"/\\\"} | |
| # Escape newlines and carriage returns | |
| str=${str//$'\n'/\\n} | |
| str=${str//$'\r'/\\r} | |
| printf '%s' "$str" | |
| } | |
| # Function to create Grafana annotation for phase visibility | |
| annotate() { | |
| local text="$1" | |
| local tags="$2" | |
| local escaped_text | |
| escaped_text=$(json_escape "$text") | |
| curl -s -X POST "$GRAFANA_URL/api/annotations" \ | |
| -H "Content-Type: application/json" \ | |
| -d "{\"text\": \"$escaped_text\", \"tags\": [$tags]}" \ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,10 +6,21 @@ | |
| BOOTSTRAP_SERVER="kafka:29092" | ||
| TOPIC1="test-topic" | ||
| TOPIC2="high-volume-topic" | ||
| GRAFANA_URL="http://grafana:3000" | ||
|
|
||
| # Message counter | ||
| MSG_COUNT=0 | ||
|
|
||
| # Function to create Grafana annotation for phase visibility | ||
| annotate() { | ||
| local text="$1" | ||
| local tags="$2" | ||
| curl -s -X POST "$GRAFANA_URL/api/annotations" \ | ||
| -H "Content-Type: application/json" \ | ||
| -d "{\"text\": \"$text\", \"tags\": [$tags]}" \ | ||
| 2>/dev/null || true # Don't fail if Grafana isn't ready | ||
| } | ||
|
Comment on lines
+15
to
+22
|
||
|
|
||
| # Function to produce messages | ||
| produce_messages() { | ||
| local topic=$1 | ||
|
|
@@ -34,30 +45,36 @@ echo "This will create lag patterns observable in Grafana" | |
|
|
||
| while true; do | ||
| # Phase 1: Steady low rate (10 msg/sec for 30 seconds) | ||
| annotate "Producer Phase 1: Low rate 10 msg/sec for 30s" "\"producer\", \"phase1\"" | ||
| echo "[$(date)] Phase 1: Low rate - 10 msg/sec for 30s" | ||
| for ((j=1; j<=30; j++)); do | ||
| produce_messages $TOPIC1 10 0.1 | ||
| done | ||
|
|
||
| # Phase 2: Burst - high volume (100 messages quickly) | ||
| annotate "Producer Phase 2: Burst 100 messages to test-topic" "\"producer\", \"phase2\", \"burst\"" | ||
| echo "[$(date)] Phase 2: Burst - 100 messages to $TOPIC1" | ||
| produce_messages $TOPIC1 100 0.01 | ||
|
|
||
| # Phase 3: High volume topic burst | ||
| annotate "Producer Phase 3: High volume burst 200 messages" "\"producer\", \"phase3\", \"burst\"" | ||
| echo "[$(date)] Phase 3: High volume burst - 200 messages to $TOPIC2" | ||
| produce_messages $TOPIC2 200 0.005 | ||
|
|
||
| # Phase 4: Steady medium rate (20 msg/sec for 30 seconds) | ||
| annotate "Producer Phase 4: Medium rate 20 msg/sec for 30s" "\"producer\", \"phase4\"" | ||
| echo "[$(date)] Phase 4: Medium rate - 20 msg/sec for 30s" | ||
| for ((j=1; j<=30; j++)); do | ||
| produce_messages $TOPIC1 20 0.05 | ||
| done | ||
|
|
||
| # Phase 5: Pause (let consumer catch up) | ||
| annotate "Producer Phase 5: Pause for 20s (consumer catch-up)" "\"producer\", \"phase5\", \"pause\"" | ||
| echo "[$(date)] Phase 5: Pause for 20s (consumer catch-up)" | ||
| sleep 20 | ||
|
|
||
| # Phase 6: Multi-topic burst | ||
| annotate "Producer Phase 6: Multi-topic burst" "\"producer\", \"phase6\", \"burst\"" | ||
| echo "[$(date)] Phase 6: Multi-topic burst" | ||
| produce_messages $TOPIC1 50 0.02 & | ||
| produce_messages $TOPIC2 100 0.01 & | ||
|
|
||
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.
Changing the dashboard UID from "kafka-lag-dashboard" to "kafka-lag-dashboard-test" may break existing references, bookmarks, or links to this dashboard. If this is intentional to create a separate test dashboard while keeping the original, consider documenting this change. If this is meant to replace the existing dashboard, the UID should remain unchanged to preserve continuity.