一键导入
managing-kafka
Use when working with Kafka — apache Kafka topic management, consumer group monitoring, partition analysis, broker health, and lag monitoring.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Use when working with Kafka — apache Kafka topic management, consumer group monitoring, partition analysis, broker health, and lag monitoring.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Cloudflare GraphQL Analytics for zone traffic, firewall events, Workers metrics, and schema exploration. Use when querying Cloudflare analytics data or exploring the GraphQL API.
PostgreSQL database analysis, performance tuning, and health monitoring. You MUST read this entire skill document before executing any PostgreSQL operations — it contains mandatory workflows, safety constraints, and two-phase execution rules that prevent common errors like hallucinated column names and unsafe queries.
SonarQube code quality and security analysis. Use when working with code quality metrics, security hotspots, quality gates, or issue tracking in SonarQube Cloud or Server.
Use when working with Aws Billing — analyze, break down, and report AWS costs and bills. Covers cost breakdown by service, account, or usage type; monthly/daily billing trends; cost anomaly detection; RI/SP utilization; cost forecasting; credit/discount analysis; and multi-account cost comparison. Uses anti-hallucination rules, mandatory currency/credit detection workflow, and reusable Cost Explorer functions.
Use when working with Aws Idle Resources — detect unused and idle AWS resources that incur cost without providing value. Covers detached EBS volumes, idle load balancers, unused Elastic IPs, stopped EC2 instances, idle NAT Gateways, old snapshots, and unused ENIs. Includes estimated monthly waste per resource and anti-hallucination rules for safe detection.
Use when working with Aws Pricing — aWS pricing helper for cost queries. ALWAYS use get_aws_cost script for pricing questions. Use when: - User asks about AWS resource costs or pricing - User wants to compare pricing across regions - User needs spot, on-demand, or reserved pricing info Triggers: aws pricing, aws cost, how much does, ec2 price, rds cost, s3 pricing.
| name | managing-kafka |
| description | Use when working with Kafka — apache Kafka topic management, consumer group monitoring, partition analysis, broker health, and lag monitoring. |
| connection_type | kafka |
| preload | false |
Analyze and manage Kafka clusters with safe, read-only operations.
You MUST follow this two-phase pattern. Skipping Phase 1 causes hallucinated topic/group names.
#!/bin/bash
# 1. List brokers
kafka-broker-api-versions.sh --bootstrap-server "$KAFKA_BOOTSTRAP" 2>/dev/null | head -5
# 2. List topics
kafka-topics.sh --bootstrap-server "$KAFKA_BOOTSTRAP" --list
# 3. Describe a topic (never assume partition count)
kafka-topics.sh --bootstrap-server "$KAFKA_BOOTSTRAP" --describe --topic my_topic
# 4. List consumer groups
kafka-consumer-groups.sh --bootstrap-server "$KAFKA_BOOTSTRAP" --list
# 5. Describe consumer group
kafka-consumer-groups.sh --bootstrap-server "$KAFKA_BOOTSTRAP" --describe --group my_group
Phase 1 outputs:
Only reference topics, partitions, and consumer groups confirmed in Phase 1.
#!/bin/bash
# Core Kafka CLI helper — always use this
kafka_cmd() {
local tool="$1"; shift
"kafka-${tool}.sh" --bootstrap-server "${KAFKA_BOOTSTRAP:-localhost:9092}" "$@"
}
# Kafka topic describe
kafka_topic() {
kafka_cmd topics --describe --topic "$1"
}
# Kafka consumer group describe
kafka_group() {
kafka_cmd consumer-groups --describe --group "$1"
}
kafka-topics.sh --listkafka-consumer-groups.sh --list--dry-run with reset-offsets before executing#!/bin/bash
echo "=== Cluster Metadata ==="
kafka_cmd metadata --snapshot /dev/null 2>/dev/null || \
kafka_cmd topics --describe | head -1
echo ""
echo "=== Topics Overview ==="
kafka_cmd topics --list | while read TOPIC; do
INFO=$(kafka_cmd topics --describe --topic "$TOPIC" 2>/dev/null | head -1)
echo "$INFO"
done
echo ""
echo "=== Log Dirs (disk usage per broker) ==="
kafka-log-dirs.sh --bootstrap-server "$KAFKA_BOOTSTRAP" --describe | jq -r '.brokers[] | "\(.broker)\t\(.logDirs[].partitions | length) partitions\t\(.logDirs[].partitions | map(.size) | add // 0 | . / 1024 / 1024 | floor)MB"' 2>/dev/null
#!/bin/bash
echo "=== All Consumer Groups ==="
kafka_cmd consumer-groups --list
echo ""
echo "=== Consumer Group Details ==="
for GROUP in $(kafka_cmd consumer-groups --list); do
echo "--- $GROUP ---"
kafka_cmd consumer-groups --describe --group "$GROUP" 2>/dev/null | tail -n +2
done
echo ""
echo "=== Groups with Lag ==="
for GROUP in $(kafka_cmd consumer-groups --list); do
LAG=$(kafka_cmd consumer-groups --describe --group "$GROUP" 2>/dev/null | awk 'NR>1 {sum += $6} END {print sum+0}')
[ "$LAG" -gt 0 ] 2>/dev/null && echo "$GROUP: $LAG total lag"
done
#!/bin/bash
TOPIC="${1:-my_topic}"
echo "=== Topic Description ==="
kafka_topic "$TOPIC"
echo ""
echo "=== Partition Offsets ==="
kafka-get-offsets.sh --bootstrap-server "$KAFKA_BOOTSTRAP" --topic "$TOPIC" 2>/dev/null || \
kafka_cmd consumer-groups --describe --group __consumer_offsets 2>/dev/null
echo ""
echo "=== Under-replicated Partitions ==="
kafka_cmd topics --describe --under-replicated-partitions
echo ""
echo "=== Unavailable Partitions ==="
kafka_cmd topics --describe --unavailable-partitions
#!/bin/bash
TOPIC="${1:-my_topic}"
echo "=== Topic Config ==="
kafka-configs.sh --bootstrap-server "$KAFKA_BOOTSTRAP" --entity-type topics --entity-name "$TOPIC" --describe
echo ""
echo "=== Broker Config (dynamic) ==="
kafka-configs.sh --bootstrap-server "$KAFKA_BOOTSTRAP" --entity-type brokers --entity-default --describe
echo ""
echo "=== Retention Settings ==="
kafka-configs.sh --bootstrap-server "$KAFKA_BOOTSTRAP" --entity-type topics --entity-name "$TOPIC" --describe | grep -E "retention|cleanup|segment"
Present results as a structured report:
Managing Kafka Report
═════════════════════
Resources discovered: [count]
Resource Status Key Metric Issues
──────────────────────────────────────────────
[name] [ok/warn] [value] [findings]
Summary: [total] resources | [ok] healthy | [warn] warnings | [crit] critical
Action Items: [list of prioritized findings]
Target ≤50 lines of output. Use tables for multi-resource comparisons.
| Shortcut | Counter | Why |
|---|---|---|
| "I'll skip discovery and check known resources" | Always run Phase 1 discovery first | Resource names change, new resources appear — assumed names cause errors |
| "The user only asked for a quick check" | Follow the full discovery → analysis flow | Quick checks miss critical issues; structured analysis catches silent failures |
| "Default configuration is probably fine" | Audit configuration explicitly | Defaults often leave logging, security, and optimization features disabled |
| "Metrics aren't needed for this" | Always check relevant metrics when available | API/CLI responses show current state; metrics reveal trends and intermittent issues |
| "I don't have access to that" | Try the command and report the actual error | Assumed permission failures prevent useful investigation; actual errors are informative |
| Scenario | Tool | Command |
|---|---|---|
| List all topics | kafka-topics.sh | --list |
| Check partition health | kafka-topics.sh | --describe --under-replicated-partitions |
| Consumer group lag | kafka-consumer-groups.sh | --describe --group GROUP |
| Disk usage per broker | kafka-log-dirs.sh | --describe |
| Topic retention config | kafka-configs.sh | --entity-type topics --describe |
| Broker API versions | kafka-broker-api-versions.sh | --bootstrap-server |
| KRaft quorum status | kafka-metadata-quorum.sh | describe --status |
| Partition offsets | kafka-get-offsets.sh | --topic TOPIC |
| Active transactions | kafka-transactions.sh | list |
| Hanging transactions | kafka-transactions.sh | find-hanging |
| Replica consistency | kafka-replica-verification.sh | --broker-list --topics-include |
| Reset consumer offsets | kafka-consumer-groups.sh | --reset-offsets --dry-run first! |
kafka-metadata-quorum.sh only works with KRaft clusters--dry-run before --execute — offset reset is irreversible