Skip to content

Commit d87adff

Browse files
committed
pipeline: input: kafka: document AWS MSK IAM
Signed-off-by: Eduardo Silva <[email protected]>
1 parent 69f4bbe commit d87adff

File tree

1 file changed

+77
-7
lines changed

1 file changed

+77
-7
lines changed

pipeline/inputs/kafka.md

Lines changed: 77 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
# Kafka
1+
# Kafka Consumer
22

3-
The _Kafka_ input plugin subscribes to one or more Kafka topics to collect messages from an [Apache Kafka](https://kafka.apache.org/) service.
3+
The _Kafka_ input plugin enables Fluent Bit to consume messages directly from one or more [Apache Kafka](https://kafka.apache.org/) topics. By subscribing to specified topics, this plugin efficiently collects and forwards Kafka messages for further processing within your Fluent Bit pipeline.
4+
5+
Starting with version 4.0.4, the Kafka input plugin supports authentication with AWS MSK IAM, enabling integration with Amazon MSK (Managed Streaming for Apache Kafka) clusters that require IAM-based access.
46

57
This plugin uses the official [librdkafka C library](https://github.com/edenhill/librdkafka) as a built-in dependency.
68

@@ -18,6 +20,15 @@ This plugin uses the official [librdkafka C library](https://github.com/edenhill
1820
| `rdkafka.{property}` | `{property}` can be any [librdkafka properties](https://github.com/edenhill/librdkafka/blob/master/CONFIGURATION.md) | _none_ |
1921
| `threaded` | Indicates whether to run this input in its own [thread](../../administration/multithreading.md#inputs). | `false` |
2022

23+
24+
## Configuration parameters for AWS MSK clusters based on IAM authentication
25+
26+
| Property | Description | Type | Required |
27+
|----------|-------------|------|----------|
28+
| `aws_msk_iam` | Enable AWS MSK IAM authentication | Boolean | No (default: false) |
29+
| `aws_msk_iam_cluster_arn` | Full ARN of the MSK cluster for region extraction | String | Yes (when `aws_msk_iam` is true) |
30+
31+
2132
## Get started
2233

2334
To subscribe to or collect messages from Apache Kafka, run the plugin from the command line or through the configuration file as shown below.
@@ -30,7 +41,7 @@ The Kafka plugin can read parameters through the `-p` argument (property):
3041
$ fluent-bit -i kafka -o stdout -p brokers=192.168.1.3:9092 -p topics=some-topic
3142
```
3243

33-
### Configuration file
44+
### Configuration file (recommended)
3445

3546
In your main configuration file append the following:
3647

@@ -44,7 +55,7 @@ pipeline:
4455
brokers: 192.168.1.3:9092
4556
topics: some-topic
4657
poll_ms: 100
47-
58+
4859
outputs:
4960
- name: stdout
5061
match: '*'
@@ -83,13 +94,13 @@ pipeline:
8394
topics: fb-source
8495
poll_ms: 100
8596
format: json
86-
97+
8798
filters:
8899
- name: lua
89100
match: '*'
90101
script: kafka.lua
91102
call: modify_kafka_message
92-
103+
93104
outputs:
94105
- name: kafka
95106
brokers: kafka-broker:9092
@@ -128,4 +139,63 @@ Since the payload will be in JSON format, the plugin is configured to parse the
128139

129140
Every message received is then processed with `kafka.lua` and sent back to the `fb-sink` topic of the same broker.
130141

131-
The example can be executed locally with `make start` in the `examples/kafka_filter` directory (`docker/compose` is used).
142+
The example can be executed locally with `make start` in the `examples/kafka_filter` directory (`docker/compose` is used).
143+
144+
## AWS MSK IAM Authentication
145+
146+
*Available since Fluent Bit v4.0.4*
147+
148+
Fluent Bit supports authentication to Amazon MSK (Managed Streaming for Apache Kafka) clusters using AWS IAM. This allows you to securely connect to MSK brokers with AWS credentials, leveraging IAM roles and policies for access control.
149+
150+
### Prerequisites
151+
152+
**Build Requirements**
153+
154+
If you are compiling Fluent Bit from source, ensure the following requirements are met to enable AWS MSK IAM support:
155+
156+
- The packages `libsasl2` and `libsasl2-dev` must be installed on your build environment.
157+
158+
**Runtime Requirements**
159+
- **Network Access:** Fluent Bit must be able to reach your MSK broker endpoints (AWS VPC setup).
160+
- **AWS Credentials:** Provide credentials using any supported AWS method:
161+
- IAM roles (recommended for EC2, ECS, or EKS)
162+
- Environment variables (`AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`)
163+
- AWS credentials file (`~/.aws/credentials`)
164+
- Instance metadata service (IMDS)
165+
166+
Note these credentials are discovery by default when `aws_msk_iam` flag is enabled.
167+
168+
- **IAM Permissions:** The credentials must allow access to the target MSK cluster (see example policy below).
169+
170+
### Configuration Parameters
171+
172+
| Property | Description | Type | Required |
173+
|---------------------------|-----------------------------------------------------|---------|-------------------------------|
174+
| `aws_msk_iam` | Enable AWS MSK IAM authentication | Boolean | No (default: false) |
175+
| `aws_msk_iam_cluster_arn` | Full ARN of the MSK cluster for region extraction | String | Yes (if `aws_msk_iam` is true)|
176+
177+
### Example AWS IAM Policy
178+
179+
> **Note:** IAM policies and permissions can be complex and may vary depending on your organization's security requirements. If you are unsure about the correct permissions or best practices, please consult with your AWS administrator or an AWS expert who is familiar with MSK and IAM security.
180+
181+
The AWS credentials used by Fluent Bit must have permission to connect to your MSK cluster. Here is a minimal example policy:
182+
183+
```json
184+
{
185+
"Version": "2012-10-17",
186+
"Statement": [
187+
{
188+
"Sid": "VisualEditor0",
189+
"Effect": "Allow",
190+
"Action": [
191+
"kafka-cluster:*",
192+
"kafka-cluster:DescribeCluster",
193+
"kafka-cluster:ReadData",
194+
"kafka-cluster:DescribeTopic",
195+
"kafka-cluster:Connect"
196+
],
197+
"Resource": "*"
198+
}
199+
]
200+
}
201+
```

0 commit comments

Comments
 (0)