---
name: "apache-kafka-consumer-lag-monitor"
description: "Diagnose consumer group lag, optimize partition assignment, and avoid Stop-The-World rebalances."
metadata:
  author: "Apache Software Foundation"
  version: "1.0.0"
  runtime_compatibility:
    - "codex"
    - "claude-code"
    - "cursor"
    - "windsurf"
triggers:
  - "monitor kafka consumer lag"
  - "tune kafka max.poll.interval.ms"
  - "fix kafka rebalance storm"
permissions:
  fs_read: true
  fs_write: "workspace"
  shell_exec: false
  net_access: false
---

# Apache Kafka Consumer Lag Monitoring & Partition Rebalancing

Monitors and tunes Apache Kafka: inspecting consumer lag with kafka-consumer-groups.sh, tuning max.poll.interval.ms and session.timeout.ms, implementing CooperativeStickyAssignor, and managing offset commits.

## When to Invoke
Invoke this skill whenever you need to:
- monitor kafka consumer lag
- tune kafka max.poll.interval.ms
- fix kafka rebalance storm

## Execution SOP & Rules
1. Check consumer group lag: kafka-consumer-groups.sh --bootstrap-server localhost:9092 --describe --group order_group.
2. Set partition.assignment.strategy = org.apache.kafka.clients.consumer.CooperativeStickyAssignor.
3. Configure auto.offset.reset = 'earliest' and enable.auto.commit = false for manual transaction commits.
4. Ensure message batch processing time never exceeds max.poll.interval.ms (default 300,000ms).

## Verification Checklist
- Run local linting, syntax validation, and type-checks before reporting completion.
- Ensure all created or modified files adhere to workspace boundaries and avoid uncommitted secrets.
- Verify tests or build commands exit cleanly with return code 0.
