Skip to content

Commit a9f113a

Browse files
committed
pipeline: output: kafka: document AWS MSK IAM support
Signed-off-by: Eduardo Silva <[email protected]>
1 parent 6472eb8 commit a9f113a

File tree

1 file changed

+93
-15
lines changed

1 file changed

+93
-15
lines changed

pipeline/outputs/kafka.md

Lines changed: 93 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,26 @@
1-
# Kafka
1+
# Kafka Producer
22

3-
Kafka output plugin allows to ingest your records into an [Apache Kafka](https://kafka.apache.org/) service. This plugin use the official [librdkafka C library](https://github.com/edenhill/librdkafka) \(built-in dependency\)
3+
Kafka output plugin, producer, allows to ingest your records into an [Apache Kafka](https://kafka.apache.org/) service. This plugin use the official [librdkafka C library](https://github.com/edenhill/librdkafka) \(built-in dependency\)
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
## Configuration Parameters
68

79
| Key | Description | default |
810
| :--- | :--- | :--- |
9-
| format | Specify data format, options available: json, msgpack, raw. | json |
10-
| message\_key | Optional key to store the message | |
11-
| message\_key\_field | If set, the value of Message\_Key\_Field in the record will indicate the message key. If not set nor found in the record, Message\_Key will be used \(if set\). | |
12-
| timestamp\_key | Set the key to store the record timestamp | @timestamp |
13-
| timestamp\_format | Specify timestamp format, should be 'double', '[iso8601](https://en.wikipedia.org/wiki/ISO_8601)' (seconds precision) or 'iso8601_ns' (fractional seconds precision) | double |
14-
| brokers | Single or multiple list of Kafka Brokers, e.g: 192.168.1.3:9092, 192.168.1.4:9092. | |
15-
| topics | Single entry or list of topics separated by comma \(,\) that Fluent Bit will use to send messages to Kafka. If only one topic is set, that one will be used for all records. Instead if multiple topics exists, the one set in the record by Topic\_Key will be used. | fluent-bit |
16-
| topic\_key | If multiple Topics exists, the value of Topic\_Key in the record will indicate the topic to use. E.g: if Topic\_Key is _router_ and the record is {"key1": 123, "router": "route\_2"}, Fluent Bit will use topic _route\_2_. Note that if the value of Topic\_Key is not present in Topics, then by default the first topic in the Topics list will indicate the topic to be used. | |
17-
| dynamic\_topic | adds unknown topics \(found in Topic\_Key\) to Topics. So in Topics only a default topic needs to be configured | Off |
18-
| queue\_full\_retries | Fluent Bit queues data into rdkafka library, if for some reason the underlying library cannot flush the records the queue might fills up blocking new addition of records. The `queue_full_retries` option set the number of local retries to enqueue the data. The default value is 10 times, the interval between each retry is 1 second. Setting the `queue_full_retries` value to `0` set's an unlimited number of retries. | 10 |
19-
| rdkafka.{property} | `{property}` can be any [librdkafka properties](https://github.com/edenhill/librdkafka/blob/master/CONFIGURATION.md) | |
20-
| raw\_log\_key | When using the raw format and set, the value of raw\_log\_key in the record will be send to kafka as the payload. | |
21-
| workers | The number of [workers](../../administration/multithreading.md#outputs) to perform flush operations for this output. | `0` |
11+
| 'format' | Specify data format, options available: json, msgpack, raw. | json |
12+
| 'message_key' | Optional key to store the message | |
13+
| 'message_key_field' | If set, the value of Message_Key_Field in the record will indicate the message key. If not set nor found in the record, Message_Key will be used (if set). | |
14+
| 'timestamp_key' | Set the key to store the record timestamp | @timestamp |
15+
| 'timestamp_format' | Specify timestamp format, should be 'double', '[iso8601](https://en.wikipedia.org/wiki/ISO_8601)' (seconds precision) or 'iso8601_ns' (fractional seconds precision) | double |
16+
| 'brokers' | Single or multiple list of Kafka Brokers, e.g: 192.168.1.3:9092, 192.168.1.4:9092. | |
17+
| 'topics' | Single entry or list of topics separated by comma (,) that Fluent Bit will use to send messages to Kafka. If only one topic is set, that one will be used for all records. Instead if multiple topics exists, the one set in the record by Topic_Key will be used. | fluent-bit |
18+
| 'topic_key' | If multiple Topics exists, the value of Topic_Key in the record will indicate the topic to use. E.g: if Topic_Key is _router_ and the record is {"key1": 123, "router": "route_2"}, Fluent Bit will use topic _route_2_. Note that if the value of Topic_Key is not present in Topics, then by default the first topic in the Topics list will indicate the topic to be used. | |
19+
| 'dynamic_topic' | adds unknown topics (found in Topic_Key) to Topics. So in Topics only a default topic needs to be configured | Off |
20+
| 'queue_full_retries' | Fluent Bit queues data into rdkafka library, if for some reason the underlying library cannot flush the records the queue might fills up blocking new addition of records. The `queue_full_retries` option set the number of local retries to enqueue the data. The default value is 10 times, the interval between each retry is 1 second. Setting the `queue_full_retries` value to `0` set's an unlimited number of retries. | 10 |
21+
| 'rdkafka.{property}' | '{property}' can be any [librdkafka properties](https://github.com/edenhill/librdkafka/blob/master/CONFIGURATION.md) | |
22+
| 'raw_log_key' | When using the raw format and set, the value of raw_log_key in the record will be send to kafka as the payload. | |
23+
| 'workers' | The number of [workers](../../administration/multithreading.md#outputs) to perform flush operations for this output. | `0` |
2224

2325
> Setting `rdkafka.log.connection.close` to `false` and `rdkafka.request.required.acks` to 1 are examples of recommended settings of librdfkafka properties.
2426
@@ -49,6 +51,8 @@ In your main configuration file append the following _Input_ & _Output_ sections
4951
Topics test
5052
```
5153

54+
55+
5256
### Avro Support
5357

5458
Fluent-bit comes with support for avro encoding for the out_kafka plugin.
@@ -141,3 +145,77 @@ key, and the _payloadkey_ value as the payload.
141145
Raw_Log_Key payloadkey
142146
Message_Key_Field msgkey
143147
```
148+
149+
## AWS MSK IAM Authentication
150+
151+
*Available since Fluent Bit v4.0.4*
152+
153+
Fluent Bit supports authentication to Amazon MSK (Managed Streaming for Apache Kafka) clusters using AWS IAM for the Kafka output plugin. This allows you to securely send data to MSK brokers with AWS credentials, leveraging IAM roles and policies for access control.
154+
155+
### Prerequisites
156+
157+
**Build Requirements**
158+
If you are compiling Fluent Bit from source, ensure the following requirements are met to enable AWS MSK IAM support:
159+
160+
- The packages `libsasl2` and `libsasl2-dev` must be installed on your build environment.
161+
162+
**Runtime Requirements**
163+
- **Network Access:** Fluent Bit must be able to reach your MSK broker endpoints (AWS VPC setup).
164+
- **AWS Credentials:** Provide credentials using any supported AWS method:
165+
- IAM roles (recommended for EC2, ECS, or EKS)
166+
- Environment variables (`AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`)
167+
- AWS credentials file (`~/.aws/credentials`)
168+
- Instance metadata service (IMDS)
169+
170+
Note these credentials are discovery by default when `aws_msk_iam` flag is enabled.
171+
172+
- **IAM Permissions:** The credentials must allow access to the target MSK cluster (see example policy below).
173+
174+
### Configuration Parameters
175+
176+
| Property | Description | Type | Required |
177+
|---------------------------|-----------------------------------------------------|---------|-------------------------------|
178+
| `aws_msk_iam` | Enable AWS MSK IAM authentication | Boolean | No (default: false) |
179+
| `aws_msk_iam_cluster_arn` | Full ARN of the MSK cluster for region extraction | String | Yes (if `aws_msk_iam` is true)|
180+
181+
### Configuration Example
182+
183+
```yaml
184+
pipeline:
185+
inputs:
186+
- name: random
187+
188+
outputs:
189+
- name: kafka
190+
match: "*"
191+
brokers: my-cluster.abcdef.c1.kafka.us-east-1.amazonaws.com:9098
192+
topics: my-topic
193+
aws_msk_iam: true
194+
aws_msk_iam_cluster_arn: arn:aws:kafka:us-east-1:123456789012:cluster/my-cluster/abcdef-1234-5678-9012-abcdefghijkl-s3
195+
```
196+
197+
### Example AWS IAM Policy
198+
199+
> **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.
200+
201+
The AWS credentials used by Fluent Bit must have permission to connect to your MSK cluster. Here is a minimal example policy:
202+
203+
```json
204+
{
205+
"Version": "2012-10-17",
206+
"Statement": [
207+
{
208+
"Sid": "VisualEditor0",
209+
"Effect": "Allow",
210+
"Action": [
211+
"kafka-cluster:*",
212+
"kafka-cluster:DescribeCluster",
213+
"kafka-cluster:ReadData",
214+
"kafka-cluster:DescribeTopic",
215+
"kafka-cluster:Connect"
216+
],
217+
"Resource": "*"
218+
}
219+
]
220+
}
221+
```

0 commit comments

Comments
 (0)