AWS Fargate on EKS provides a fully managed experience for running Kubernetes workloads. Kinesis Data Firehose can be used with EKS’s Fluent Bit log router to collect logs in Datadog. This guide provides a comparison of log forwarding through Kinesis Data Firehose and CloudWatch logs, as well as a sample EKS Fargate application to send logs to Datadog through Kinesis Data Firehose.
Kinesis Data Firehose and CloudWatch log forwarding
The following are key differences between using Kinesis Data Firehose and CloudWatch log forwarding.
Metadata and tagging: Metadata such as Kubernetes namespace and container ID are accessible as structured attributes when sending logs with Kinesis Data Firehose.
AWS Costs: AWS Costs may vary for individual use cases but Kinesis Data Firehose ingestion is generally less expensive than comparable Cloudwatch Log ingestion.
An EKS cluster with a Fargate profile and Fargate pod execution role. In this guide, the cluster is named fargate-cluster with a Fargate profile named fargate-profile applied to the namespace fargate-namespace. If you don’t already have these resources, use Getting Started with Amazon EKS to create the cluster and Getting Started with AWS Fargate using Amazon EKS to create the Fargate profile and pod execution role.
Setup
The following steps outline the process for sending logs from a sample application deployed on an EKS cluster through Fluent Bit and a Kinesis Data Firehose delivery stream to Datadog. To maximize consistency with standard Kubernetes tags in Datadog, instructions are included to remap selected attributes to tag keys.
Configure Fluent Bit for Firehose on an EKS Fargate cluster
Create the aws-observability namespace.
kubectl create namespace aws-observability
Create the following Kubernetes ConfigMap for Fluent Bit as aws-logging-configmap.yaml. Substitute the name of your delivery stream.
apiVersion:v1kind:ConfigMapmetadata:name:aws-loggingnamespace:aws-observabilitydata:filters.conf:| [FILTER]
Name kubernetes
Match kube.*
Merge_Log On
Buffer_Size 0
Kube_Meta_Cache_TTL 300sflb_log_cw:'true'output.conf:| [OUTPUT]
Name kinesis_firehose
Match kube.*
region <REGION>
delivery_stream <YOUR-DELIVERY-STREAM-NAME>
Use kubectl to apply the ConfigMap manifest.
kubectl apply -f aws-logging-configmap.yaml
Create an IAM policy and attach it to the pod execution role to allow the log router running on AWS Fargate to write to the Kinesis Data Firehose. You can use the example below, replacing the ARN in the Resource field with the ARN of your delivery stream, as well as specifying your region and account ID.