EKS Fargate Logs
Ingesting EKS Fargate Logs with KubeSense
KubeSense supports ingesting logs from Amazon EKS Fargate pods. Since Fargate pods don't have node-level access, logs are typically delivered via CloudWatch Logs and then forwarded to KubeSense aggregator through Amazon Firehose.
Prerequisites
Before you begin, ensure you have:
- EKS Fargate cluster running
- Pods configured to send logs to CloudWatch Logs
- KubeSense aggregator deployed with public ingress enabled
- AWS permissions to create Firehose streams and subscription filters
Architecture
EKS Fargate logs flow through the following path:
Fargate Pods → CloudWatch Logs → Firehose → KubeSense AggregatorStep 1: Configure Fargate Pod Logging
EKS Fargate automatically sends container logs to CloudWatch Logs. Ensure your pods are configured correctly:
Verify Log Group
Fargate creates log groups in the format:
/aws/eks/<cluster-name>/cluster
/aws/containerinsights/<cluster-name>/applicationCheck Pod Log Configuration
Ensure your pods have proper logging configuration. Fargate automatically captures stdout/stderr from containers.
Step 2: Create Firehose Stream
Create a Firehose stream to forward CloudWatch Logs to KubeSense:
- Go to Amazon Data Firehose
- Click Create Firehose stream
- Configure:
- Source: Direct PUT
- Destination: HTTP Endpoint
- Delivery stream name:
kubesense-eks-fargate-logs - HTTP endpoint URL:
https://<KUBESENSE_AGGREGATOR_HOST>:<PORT>/firehose - Access key: Your KubeSense API token
- Content encoding: GZIP
- Parameters: Add
env_nameparameter (e.g.,eks-fargate-prod)
Step 3: Create IAM Role for CloudWatch
Create an IAM role that allows CloudWatch to write to Firehose:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "logs.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
}Attach a policy allowing Firehose write access:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"firehose:PutRecord",
"firehose:PutRecordBatch"
],
"Resource": "arn:aws:firehose:region:account:deliverystream/kubesense-eks-fargate-logs"
}
]
}Step 4: Create Subscription Filters
Create subscription filters for EKS Fargate log groups:
Using AWS CLI
# For cluster logs
aws logs put-subscription-filter \
--log-group-name "/aws/eks/<cluster-name>/cluster" \
--filter-name "kubesense-fargate-cluster" \
--filter-pattern "" \
--destination-arn "arn:aws:firehose:region:account:deliverystream/kubesense-eks-fargate-logs" \
--role-arn "arn:aws:iam::account:role/KubeSenseCloudWatchFirehoseRole"
# For application logs
aws logs put-subscription-filter \
--log-group-name "/aws/containerinsights/<cluster-name>/application" \
--filter-name "kubesense-fargate-app" \
--filter-pattern "" \
--destination-arn "arn:aws:firehose:region:account:deliverystream/kubesense-eks-fargate-logs" \
--role-arn "arn:aws:iam::account:role/KubeSenseCloudWatchFirehoseRole"Using AWS Console
- Go to CloudWatch Logs
- Navigate to the EKS Fargate log groups
- Click Subscription filters tab
- Click Create
- Select Create Amazon Data Firehose subscription filter
- Select your Firehose stream
- Select the IAM role
- Click Start streaming
Step 5: Configure KubeSense Aggregator
Configure the aggregator to handle EKS Fargate logs:
aggregator:
customSources:
enabled: true
sources:
eks_fargate_logs:
type: aws_kinesis_firehose
address: 0.0.0.0:443
access_keys:
- "<KUBESENSE_API_TOKEN>"Alternative: LogSensor Sidecar (Experimental)
For more direct control, you can deploy LogSensor as a sidecar container in Fargate pods:
Pod Configuration Example
apiVersion: v1
kind: Pod
metadata:
name: fargate-app-with-logsensor
spec:
containers:
- name: app
image: your-app:latest
- name: logsensor
image: kubesense/logsensor:latest
env:
- name: AGGREGATOR_HOST
value: "<KUBESENSE_AGGREGATOR_HOST>"
- name: AGGREGATOR_PORT
value: "30052"
- name: CLUSTER_NAME
value: "<cluster-name>"
- name: LOG_PATHS
value: "/var/log/containers"
volumeMounts:
- name: varlog
mountPath: /var/log
resources:
requests:
memory: "128Mi"
cpu: "100m"
limits:
memory: "256Mi"
cpu: "200m"
volumes:
- name: varlog
emptyDir: {}Note: LogSensor sidecar in Fargate is experimental and may have limitations. The CloudWatch → Firehose method is recommended for production use.
Log Enrichment
KubeSense aggregator automatically enriches EKS Fargate logs with:
- Pod metadata: Pod name, namespace, labels
- Container information: Container name, image
- Cluster context: Cluster name, region
- Fargate metadata: Task ID, platform version
Monitoring and Verification
- Check CloudWatch Logs: Verify logs are being written to CloudWatch
- Monitor Firehose: Check Firehose delivery metrics in AWS Console
- Verify subscription filters: Ensure filters are active
- Check KubeSense dashboard: Verify logs appear in KubeSense with proper metadata
- Review aggregator logs: Check for any ingestion errors
Troubleshooting
Logs Not Appearing
- Verify Fargate logging: Check that pods are generating logs
- Check CloudWatch log groups: Ensure logs are being written
- Verify Firehose stream: Check stream status and metrics
- Review subscription filters: Ensure filters are active and correct
- Check IAM permissions: Verify all roles have correct permissions
- Review aggregator logs: Check for connection or parsing errors
Missing Metadata
- Verify log format: Ensure logs include Kubernetes metadata
- Check enrichment config: Verify aggregator enrichment is enabled
- Review log structure: Check that logs match expected format
Best Practices
- Use descriptive env_name: Set meaningful environment names in Firehose parameters
- Filter logs: Use subscription filter patterns to only send relevant logs
- Monitor costs: CloudWatch and Firehose can generate significant costs
- Set retention: Configure appropriate CloudWatch Logs retention
- Use log groups: Organize logs by namespace or application using log group prefixes
- Monitor Firehose: Set up CloudWatch alarms for Firehose delivery failures
Cost Considerations
- CloudWatch Logs: Charged per GB ingested and stored
- Firehose: Charged per GB processed
- Data transfer: Consider data transfer costs between AWS and KubeSense
- Optimize with filters: Use filter patterns to reduce log volume
Conclusion
EKS Fargate logs integration enables comprehensive observability for serverless Kubernetes workloads, providing the same rich log analysis capabilities as traditional EKS deployments.