Review MSK broker logging

Send Amazon MSK broker logs to an appropriate destination.

Description

Send MSK broker logs to CloudWatch Logs, Firehose or S3 to see what the brokers recorded during a Kafka connection failure or processing delay.

Potential impact

Broker logs record operational events. To trace an individual message, also check the application’s delivery records.

Remediation

Create the destination first. In logging_info.broker_logs, set that destination’s enabled to true. For Firehose, tag the delivery stream LogDeliveryEnabled=true. After applying the change, check the destination for a recent broker log entry.

Examples

The first excerpt disables both CloudWatch Logs and Firehose. The second sends logs only to the referenced CloudWatch log group. Also supply the cluster name, Kafka version and broker node settings before deploying.

Before

hcl
resource "aws_msk_cluster" "example" {
  logging_info {
    broker_logs {
      cloudwatch_logs {
        enabled   = false
        log_group = aws_cloudwatch_log_group.test.name
      }
      firehose {
        enabled         = false
        delivery_stream = aws_kinesis_firehose_delivery_stream.test_stream.name
      }
    }
  }
}

After

hcl
resource "aws_msk_cluster" "example" {
  logging_info {
    broker_logs {
      cloudwatch_logs {
        enabled   = true
        log_group = aws_cloudwatch_log_group.test.name
      }
    }
  }
}

References