Generated banner for Managing Amazon Msk
Generated logo for Managing Amazon Msk

Managing Amazon Msk

AWSOfficialPublished by AWS

  • Skill
  • Tool integration
  • Cloud and DevOps
  • Apache-2.0
  • Low risk
  • Has scripts

From the author

Operates Amazon MSK Provisioned clusters (Standard and Express brokers). Required for ANY MSK Provisioned task — training data conflates Standard and Express. Covers performance, consumer lag, storage, traffic shaping; sizing Standard vs Express; Kafka client tuning; CloudWatch alarms; cluster configs; maintenance, patching, rolling restarts; topic management; MSK Replicator setup for DR and active-active/active-passive replication (same-/cross-account), including throughput and partition sizing; Streaming Tables for S3 Tables and Data Delivery for General Purpose S3 — setup, IAM, monitoring. Prefer Flink for Kafka Iceberg sink questions. Migrations: use migrate-to-msk. Triggers: MSK Provisioned, Kafka, `kafka.*`/`express.*` types, AWS/Kafka namespace, cross-cluster replication, Kafka to Iceberg on S3 Tables, Kafka to S3, lakehouse, data lake from Kafka, Kafka Connect S3 Sink or Firehose alternative. DO NOT USE for MSK Connect — search docs instead. Serverless: only S3 Tables/data delivery eligibility.
— the description by AWS

AutoGineer summary

Written by AutoGineer from the skill’s own files, not by the author

This skill provides domain expertise for operating Amazon MSK Provisioned clusters. It covers performance troubleshooting, consumer lag diagnosis, storage management, cluster sizing, client configuration, and CloudWatch monitoring. It distinguishes between Standard and Express broker architectures, providing specific workflows for maintenance, topic management, and MSK Replicator setup. The skill also includes guidance on integrating with S3 via Streaming Tables and Data Delivery for General Purpose S3.

What it does

  • Provides configuration patterns for Kafka producers and consumers.
  • Offers workflows for managing MSK cluster configurations and custom domain names.
  • Includes a sizing script for determining broker counts and instance types.
  • Details procedures for MSK Replicator setup for DR and cross-account replication.
  • Outlines monitoring and alerting strategies using CloudWatch metrics.
  • Guides the setup of Streaming Tables and Data Delivery for S3.

When to use it

  • When configuring or tuning Kafka clients for MSK connectivity.
  • When sizing a new MSK cluster or choosing between Standard and Express brokers.
  • When troubleshooting performance issues, consumer lag, or storage constraints.
  • When setting up cross-cluster replication or disaster recovery.
  • When integrating MSK with S3 for data lake or streaming table requirements.

Advantages

  • Provides clear decision frameworks for Standard vs. Express broker types.
  • Includes automated sizing logic via provided scripts.
  • Centralizes operational procedures for common MSK maintenance tasks.
  • Offers specific guidance for complex configurations like custom advertised listeners.

Usage examples

“How do I choose between MSK Standard and Express brokers for my workload?”
The agent will guide you through the size-and-choose-cluster.md reference and run the msk_sizing.py script to compare costs and performance characteristics.
“My consumer lag is increasing, what should I check?”
The agent will provide a troubleshooting workflow based on troubleshoot-consumer-lag.md, covering rebalance issues and consumer group health.
“How do I configure a custom domain name for my MSK brokers?”
The agent will explain how to use the custom.advertised.listeners configuration property as detailed in configure-cluster.md.
“What are the recommended producer settings for MSK?”
The agent will provide the table of recommended values for settings like linger.ms, batch.size, and acks from the configure-clients.md reference.

Install

  1. Download the skill as a ZIP:

    https://mp-staging.autogineer.com/agent-skills/aws/managing-amazon-msk/download
  2. Unzip it into the cross-client skills folder of your project:

    mkdir -p .agents/skills && unzip managing-amazon-msk.zip -d .agents/skills

Documentation by AWS

Amazon MSK

Overview

Domain expertise for operating Amazon MSK Provisioned clusters with Standard and Express broker types. Covers performance troubleshooting, consumer lag diagnosis, storage management, cluster sizing, client configuration, and CloudWatch monitoring.

Execute commands using available tools from the AWS MCP server when connected — it provides sandboxed execution, audit logging, and observability. When the MCP server is not available, fall back to the AWS CLI or shell as needed.

Standard brokers use customer-managed EBS volumes for storage. You choose instance types (kafka.m5/m7g families), provision EBS, and manage storage scaling.

Express brokers use instance types prefixed with express.m7g and are the default recommendation for almost all MSK workloads — they typically cost less, not just less effort. Up to 3x ingress per broker (MSK Express broker types) means fewer brokers for the same load, and storage is billed per GB-hour on data actually retained rather than provisioned up front on EBS that cannot shrink. They also scale 20x faster, rebalance partitions 180x faster (Intelligent Rebalancing), recover 90% quicker (MSK Express broker types), and have no maintenance windows. Express brokers have NO customer-managed EBS — do NOT recommend EBS expansion or provisioned throughput for Express clusters. Express brokers enforce fixed replication factor of 3 and min.insync.replicas=2. See size-and-choose-cluster.md for the full Standard vs Express decision framework.

Which Workflow Do You Need?

Determine the broker type first: aws kafka describe-cluster-v2 --cluster-arn <arn>. Check Provisioned.BrokerNodeGroupInfo.InstanceType — if it starts with express., it is an Express cluster.

Customer IntentReference
High CPU, high latency, slow cluster, traffic shapingtroubleshoot-performance.md
Consumer lag increasing, rebalance storms, stuck consumer groupstroubleshoot-consumer-lag.md
Disk filling up, retention planning, tiered storagemanage-storage.md
Choosing Standard vs Express, sizing a cluster, partition limits, broker count, monthly costsize-and-choose-cluster.md
Producer/consumer configuration, IAM/SCRAM/TLS authconfigure-clients.md
Creating/applying MSK configurations (server.properties); custom domain names on brokers via custom.advertised.listeners (advertised listeners, static/custom bootstrap endpoint) — validation rules, apply/rollback, scaling; migrating from the dynamic per-broker kafka-configs.sh override to the static propertyconfigure-cluster.md
Client-side connectivity for a custom domain: NLB + ACM certificate + Route 53 fronting, TLS handshake/termination, mTLS through an NLB, cross-zone load balancingconfigure-clients.md (Custom Domain Name Connectivity section)
Create, update, delete, list, or describe Kafka topics; when to use the native topic APIs / CfnTopic vs. a Kafka admin clientmanage-topics.md
MSK Replicator setup, migration, DR, active-active/active-passive, cross-account replication, self-managed-to-MSK or MSK-to-MSK, loop-prevention/topic-naming behaviormsk-replicator.md
Replication throughput per partition, how many partitions a replicator needs, why replicator scaling isn't increasing throughput, replicator quotas (topics, ingress, record size), ReplicationLatency/MessageLag/ReplicatorThroughputmsk-replicator.md (Size partition count section)
Setting up monitoring, dashboards, alarmsmonitor-and-alarm.md
Full CloudWatch metric list (Standard or Express)Prefer monitor-and-alarm.md for strategic recommendations and how to interpret metrics, only search documentation if you need to understand a metric not included in this reference file (MSK Standard CloudWatch Metrics, MSK Express CloudWatch Metrics) for full list
Rolling restart impact, patching, maintenance resiliencemaintenance-operations.md
Deliver streaming data to Apache Iceberg tables on S3 Tables with low cost in a fully managed service (Streaming Tables) — setup, IAM, schema, create/update/delete/list/describe channelsstreaming-tables.md
Deliver topic data to S3 bucket as JSON/ByteArray/String objects with low cost in a fully managed service (Data Delivery for General Purpose S3 buckets) — setup, IAM, output key templates, create/update/delete/list/describe channelsdata-delivery-for-general-purpose-s3.md
Build a lakehouse / data lake from Kafka; make streaming data queryable in Athenastreaming-tables.md
Alternative to Kafka Connect S3 Sink or Amazon Data Firehose for MSK; zero-ops streaming delivery to S3data-delivery-for-general-purpose-s3.md
Streaming Tables / Data Delivery CloudWatch metrics and alarms, DLQ errors, failed deliveries, channel state transitions, freshness lagstreaming-tables-troubleshooting.md
"Can I use Streaming Tables / Data Delivery on MSK Serverless / Standard brokers?" — eligibility routingstreaming-tables.md (answer is always: Express brokers only, use Firehose, Flink, or Kafka Connect for Standard and Serqverless - Firehose integration for Amazon MSK)
What are the current supported Kafka versions for MSK?Supported Apache Kafka versions
Does MSK support KRaft clusters, and how do I migrate between ZooKeeper and KRaft mode clusters?zk-to-kraft-migration.md
What are the current quotas for MSK Express (ingress, egress, partitions, broker count, etc.)?MSK Express Quotas
What are the current quotas for MSK Standard (partitions, broker count, etc.)?MSK Standard Quotas, and MSK Standard best practices for partition count limits
What broker-level configuration changes can I make on MSK Express or Standard brokers?MSK Configuration

Available scripts

  • scripts/msk_sizing.py — MUST be run for any sizing question (broker count, instance choice, cost). Prices from the live AWS Pricing API when AWS credentials with pricing:GetProducts are available, and falls back to an embedded us-east-1 snapshot when they are not, so it runs with or without credentials. See size-and-choose-cluster.md for the required workflow and script reference.

Guardrail — where this skill's own files live (MCP vs local install)

This skill can be loaded two ways, and they resolve the skill's own bundled files — the references/ documents and the scripts/ files from different places. Determine how the skill was loaded before you read a reference or run a script:

  • Loaded through the AWS MCP retrieve_skill tool call. The skill is not installed on the local filesystem; its reference files and scripts do not exist on disk. You MUST fetch each reference or script through the same retrieve_skill tool by passing the file parameter (for example, file="references/configure-clients.md" or file="scripts/msk_sizing.py"), and run a script from the content that tool returns. Do NOT file_read these paths from the local or working directory, and do NOT search the filesystem for them — they are not there, and any local file that happens to match the name is unrelated to this skill.

  • Installed locally (the skill lives in a local skills directory such as .claude/skills/managing-amazon-msk/, ~/.claude/skills/managing-amazon-msk/, or .kiro/skills/managing-amazon-msk/). Read references and run scripts from the local skill directory using the relative paths shown throughout this documentation.

This distinction applies only to the skill's own packaged files. Every artifact created during a session or supplied by users are read from and written to the user's working directory regardless of how the skill was loaded. Never fetch or write customer data through retrieve_skill.

Common Workflows

Create/apply Amazon MSK configurations and set custom domain names — creating an Amazon MSK configuration (server.properties with the fileb:// real-newline requirement), applying it with update-cluster-configuration, and setting broker custom domain names via custom.advertised.listeners: see configure-cluster.md. For the NLB/certificate/DNS connectivity that fronts a custom domain, see configure-clients.md.

Files

references/maintenance-operations.md

MSK Maintenance Operations

How MSK Maintenance Works

Standard brokers

During patching and version upgrades, MSK performs rolling broker restarts — one broker at a time. The cluster enters MAINTENANCE state. You can still produce and consume data, but you cannot perform MSK API update operations until the cluster returns to ACTIVE. These operations appear as SECURITY_PATCHING in the DescribeClusterOperation API.

Expected client impact: Transient disconnect errors and brief p99 latency spikes (high milliseconds, up to ~2 seconds) lasting up to 2 minutes per broker restart as clients reconnect to new leaders. With the default RF=3 and proper client configuration (retries, delivery.timeout.ms >= 60000, acks=all), this does NOT cause data loss or prolonged unavailability — retries transparently reconnect to the new leader within seconds. Topics with RF=1 become completely unavailable while their broker restarts — there is no replica to fail over to, so producers receive errors and consumers stall for the full restart duration (5-15 min). See configure-clients.md and the "Consumer Resilience During Maintenance" section below.

Expected metric impact: UnderReplicatedPartitions increases temporarily (partitions on the offline broker stop replicating). After restart, the broker catches up on missed messages — you may see increased volume throughput and CPU usage during catch-up.

Express brokers

Express brokers have no maintenance windows. MSK updates Express broker software on an ongoing basis in a time-distributed manner — occasional singular broker reboots spread across the month. The cluster stays ACTIVE during all maintenance. These operations appear as BROKER_UPDATE in the DescribeClusterOperation API.

Why Express patching is less disruptive:

  • No cluster-wide maintenance window to plan around

  • Throughput quotas prevent overloading during broker restarts

  • Fixed RF=3 guarantees all topics survive a single broker restart (no RF=1 or RF=2 topics)

  • Faster catch-up after restart than Standard brokers

  • No advance notification needed

Client contract still applies: Clients must still handle leadership failover. Configure producers with retries, delivery.timeout.ms >= 60000, and acks=all; configure consumers with session.timeout.ms = 45000-60000. See configure-clients.md and the "Consumer Resilience During Maintenance" section below.

Can You Reschedule or Opt Out of Patching?

Patching cannot be opted out of on either broker type — it is mandatory for the health and security of the cluster.

  • Standard: the maintenance window is configurable, but only by opening an AWS Support case — there is no self-service control (no MSK API, SDK, CLI, or console setting) to change it yourself. Use a Support case to shift the window or reschedule/postpone a specific pending patch. Do not rely on repeatedly postponing: MSK force-applies patching to clusters whose maintenance is continually delayed.

  • Express: patching is continuous and time-distributed with no maintenance window, so there is nothing to schedule or reschedule.

What Happens During a Rolling Restart

When a broker restarts during maintenance:

  1. Broker goes offline: The broker's metrics disappear from CloudWatch for several minutes.

  2. Leadership transfer: Partition leadership moves from the restarting broker to other in-sync replicas. LeaderCount shifts across brokers.

  3. UnderReplicatedPartitions (URP) spikes (Standard only — Express does not emit URP): While the broker is down, its partitions are under-replicated. This is expected and temporary.

  4. ActiveControllerCount may change: If the controller broker is restarted, a new controller is elected.

  5. Consumer group rebalances: If consumers were connected to the restarting broker, the session timeout triggers a rebalance.

  6. Broker restarts and catches up: The broker comes back online, loads logs, replicates missed data, and rejoins ISR. URP decreases as replicas catch up.

  7. MSK moves to the next broker: MSK waits for the broker to fully catch up before restarting the next one.

Typical timeline per broker: 5-15 minutes depending on data volume and partition count. Log loading progress can be tracked via the JMX metrics remainingLogsToRecover and remainingSegmentsToRecover (available through Prometheus/JMX monitoring, not via CloudWatch).

Speeding up log recovery: By default, Kafka uses a single thread per log directory for log recovery after an unclean shutdown. With thousands of partitions, recovery can take hours. Set num.recovery.threads.per.data.dir to the number of CPU cores to parallelize recovery. This is a broker-side configuration — update via aws kafka update-cluster-configuration.

What NOT To Do During Maintenance

  • NEVER restart additional brokers — MSK is already performing a rolling restart. Manual restarts compound the problem.

  • NEVER reassign partitions during URP — Reassignment adds replication load on already-stressed brokers.

  • NEVER lower min.insync.replicas — This weakens durability guarantees. The NotEnoughReplicasException during maintenance is transient.

  • NEVER escalate as a cluster-level issue if URP is decreasing and only one broker has a metrics gap.

Impact of Scaling Operations (Standard)

Scaling operations on Standard clusters trigger rolling restarts or add replication load. Plan these during low-traffic periods and ensure the cluster has headroom.

Broker size updates

Updating the broker size (e.g., kafka.m5.large → kafka.m5.xlarge) triggers a rolling restart — MSK takes brokers offline one at a time and temporarily reassigns partition leadership to other brokers. This is the same process as a maintenance rolling restart. A size update typically takes 10-15 minutes per broker. During this time:

  • UnderReplicatedPartitions will spike per broker, same as during patching

  • Remaining brokers absorb extra leadership and replication load

  • Ensure CPU is under 60% before initiating a size change

Adding brokers and reassigning partitions

After adding brokers to expand a Standard cluster, existing partitions are NOT automatically redistributed. You must manually reassign partitions using kafka-reassign-partitions.sh. This creates replication load as data is copied from existing brokers to new ones.

Constraints:

  • Limit to 10 partitions per reassignment call for safe operations on Standard clusters

  • Do NOT reassign partitions when CPU utilization is above 70% — replication adds significant CPU and network load that can cascade

  • Do NOT reassign partitions while UnderReplicatedPartitions > 0

  • Consider using Cruise Control for continuous, automated partition rebalancing

Storage expansion

Expanding EBS storage does NOT trigger a rolling restart — it happens online. However, the volume enters an optimizing state that can take up to 24 hours, and a second expansion cannot be performed for at least 6 hours. See manage-storage.md for details.

Impact of Scaling Operations (Express)

Express scaling is simpler than Standard, but broker size changes still involve rolling restarts.

Broker size updates

Updating the Express broker size also triggers a rolling restart, same as Standard. MSK takes brokers offline one at a time. However, the cluster stays ACTIVE (not MAINTENANCE) throughout. Key differences from Standard:

  • Express does not emit UnderReplicatedPartitions — you cannot use URP to track restart progress. Monitor ProduceThrottleTime, FetchThrottleTime, and consumer lag instead.

  • Ensure CPU (CpuUser + CpuSystem) is under 60% before initiating a size change, same as Standard.

Adding brokers and partition redistribution

When you add brokers to an Express cluster:

  • If Intelligent Rebalancing is enabled (default): Partitions are automatically redistributed to new brokers. No manual action needed. You cannot use kafka-reassign-partitions.sh while Intelligent Rebalancing is active.

  • If Intelligent Rebalancing is disabled: You must manually reassign partitions using kafka-reassign-partitions.sh. Limit to 20 partitions per reassignment call (vs 10 for Standard).

Storage

Express storage is fully managed — there is no expansion operation, no cooldown period, and no provisioning required. Storage scales automatically with data retained. However, you should still monitor StorageUsed and per-topic ingress to catch runaway growth that impacts cost. See manage-storage.md for investigation steps.

Consumer Resilience During Maintenance

Configure consumers to survive broker restarts gracefully. See configure-clients.md for full settings.

Key settings for maintenance resilience:

SettingRecommendedWhy
session.timeout.ms45000-60000Must exceed time for broker restart + consumer reconnection. Default 10000 is too short.
heartbeat.interval.ms10000-15000Should be < 1/3 of session.timeout.ms.
partition.assignment.strategyCooperativeStickyAssignorIncremental rebalances instead of stop-the-world. Only moved partitions are reassigned.
group.instance.idUnique per consumerEnables static membership. Consumer can rejoin after brief disconnect without triggering full rebalance.
group.initial.rebalance.delay.msMatch average deployment timeBroker-side config (set via aws kafka update-cluster-configuration, not consumer properties). Prevents cascading rebalances during rolling deployments.

Producer settings for maintenance:

SettingRecommendedWhy
retriesInteger.MAX_VALUEAllows retrying through broker restart.
delivery.timeout.ms60000 minimum; 120000 (2 minutes) or higherBounds total retry time. AWS recommends a minimum of 60 seconds. Must be ≥ request.timeout.ms + linger.ms. With RF=3 and min.insync.replicas=2, producers only stall during leader election (seconds, not minutes). The 2-min default covers this. Increase if you observe TimeoutException during maintenance.
acksallWith min.insync.replicas=2 (MSK default), writes succeed as long as 2 of 3 replicas are available. One broker offline is tolerated.

Preparing for Maintenance Windows (Standard)

  1. Ensure CPU < 60%: During maintenance, remaining brokers handle extra leadership and replication. If CPU is already near 60%, the added load during maintenance may cause cascading issues.

  2. Ensure storage headroom: Brokers that take over leadership temporarily handle more writes.

  3. Use 3-AZ clusters with RF=3 and min.insync.replicas=2: This tolerates one broker offline.

  4. Distribute connection strings across AZs: Client bootstrap servers SHOULD include at least one broker from each AZ.

  5. Test consumer resilience: Simulate broker failure by rebooting a broker via the MSK API: aws kafka reboot-broker --cluster-arn <arn> --broker-ids <id>.

Kafka Version Upgrades

Version upgrades trigger rolling restarts. The process:

  1. MSK updates brokers one at a time to the new version.

  2. Between each broker restart, MSK waits for the broker to fully catch up.

  3. The cluster enters UPDATING state during the upgrade.

Constraints:

  • You MUST check that partition counts per broker are within the limits for the target version before upgrading (see size-and-choose-cluster.md).

  • Upgrades are forward-only — you cannot downgrade Kafka versions.

  • The supported version list and end-of-support dates change over time — check Supported Apache Kafka versions rather than relying on memory, and query a specific cluster's valid upgrade targets with aws kafka get-compatible-kafka-versions --cluster-arn <arn>. Express supports a narrower set than Standard.

  • KRaft metadata mode (no ZooKeeper) is available from Kafka 3.7.x — see Metadata management.

Monitoring During Maintenance

Watch these metrics to track maintenance progress:

MetricWhat to Look For
UnderReplicatedPartitions (Standard only)Should spike when a broker restarts, then decrease as it catches up. If URP stays elevated for > 30 min after a broker comes back, investigate. Express does not emit this metric.
ActiveControllerCountShould always be 1. Brief fluctuation during controller broker restart is normal.
CpuUser on remaining brokersShould increase temporarily as they absorb extra leadership. If > 80%, cluster is undersized for maintenance.
BytesInPerSec per brokerShould redistribute when a broker goes offline and rebalance when it returns.
LeaderCount per brokerShould shift during restart and rebalance afterward via auto.leader.rebalance.enable=true (MSK default).

Requirements and compatibility

Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta

“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.

Needs: Needs an MCP server, Needs Python

Security

What our scanner noticed· Low risk

  • Scripts that your agent may run

This skill includes scripts that your agent may run. Read them before you use it.

A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.

Attribution and licence

Published by
AWS
Publisher
AWS (Official)
Source
aws/agent-toolkit-for-aws · plugins/aws-data-analytics/skills/managing-amazon-msk · commit 0a218f8
Licence
Apache License 2.0 (redistribution allowed)
  • LICENSE (added by AutoGineer from LICENSE)
  • NOTICE (added by AutoGineer from NOTICE)
  • ATTRIBUTION.md (written by AutoGineer)
Synced
Also distributed in
aws/agent-toolkit-for-aws

AutoGineer is not affiliated with or endorsed by AWS.

Download ZIP

The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download managing-amazon-msk.zip