Skip to content

Commit 48b4829

Browse files
committed
Start Use Case Guide with EKS templating examples
Signed-off-by: Wesley Pettit <[email protected]>
1 parent 9186898 commit 48b4829

File tree

6 files changed

+910
-0
lines changed

6 files changed

+910
-0
lines changed

README.md

+5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
- [Versioning FAQ](#versioning-faq)
66
- [Debugging Guide](troubleshooting/debugging.md)
7+
- [Use Case Guide](use_cases/)
78
- [Public Images](#public-images)
89
- [Using the stable tag](#using-the-stable-tag)
910
- [Using SSM to find available versions](#using-ssm-to-find-available-versions)
@@ -52,6 +53,10 @@ No. We continue to consume Fluent Bit from its main repository. We are not forki
5253

5354
[Please read the debugging.md](troubleshooting/debugging.md)
5455

56+
### Use Case Guide
57+
58+
[A set of tutorials on use cases that Fluent Bit can solve](use_cases/).
59+
5560
### Public Images
5661

5762
Each release updates the `latest` tag and adds a tag for the version of the image. The `stable` tag is also available which marks a release as the latest stable version. Deploying `latest` to prod without going through a test stage first is not recommended.

use_cases/README.md

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# AWS for Fluent Bit Use Case Guide
2+
3+
The goal of this guide is a central location for all tutorials on solving use cases for AWS customers with Fluent Bit.
4+
5+
## Troubleshooting errors and issues
6+
7+
## ECS FireLens Examples
8+
9+
All FireLens (side-car) examples for ECS are housed in their own repo: [aws-samples/amazon-ecs-firelens-examples](https://github.com/aws-samples/amazon-ecs-firelens-examples)
10+
11+
We have guides on everything from JSON parsing to sending Fluent Bit's internal metrics to CloudWatch Metrics, and much much more.
12+
13+
## ECS Daemon Service Examples
14+
15+
Coming Soon!
16+
17+
## EKS/Kubernetes Examples
18+
19+
### Getting Started with Fluent Bit and Kubernetes
20+
* [Kubernetes Logging powered by AWS for Fluent Bit](https://aws.amazon.com/blogs/containers/kubernetes-logging-powered-by-aws-for-fluent-bit/)
21+
* [Set up Fluent Bit as a DaemonSet to send logs to CloudWatch Logs](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Container-Insights-setup-logs-FluentBit.html)
22+
* [AWS for Fluent Bit helm charts](https://github.com/aws/eks-charts/tree/master/stable/aws-for-fluent-bit)
23+
* [Fluent Community maintained Kubernetes Repo](https://github.com/fluent/fluent-bit-kubernetes-logging)
24+
25+
### Common Use Cases
26+
* [Customize CloudWatch log group or stream name based on kubernetes metadata](k8s-metadata-customize-cw/)
27+
* [Customize the tag based on Kubernetes metadata](k8s-metadata-customize-tag/)
28+
29+
### Monitoring Fluent Bit
30+
* [Fluent Bit Prometheus endpoint](https://docs.fluentbit.io/manual/administration/monitoring)
31+
32+
33+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Customizing CloudWatch Log Group or Stream with Kubernetes Metadata
2+
3+
### Option 1: Use the high performance cloudwatch_logs plugin
4+
5+
To use the [recommended AWS CloudWatch Plugin](https://docs.fluentbit.io/manual/pipeline/outputs/cloudwatch/), please see the main [Customize the tag based on Kubernetes metadata](k8s-metadata-customize-tag/) example, which demonstrates the technique with the cloudwatch_logs plugin.
6+
7+
### Option 2: Use templating in the older Golang cloudwatch plugin
8+
9+
The [lower performance CloudWatch plugin](https://github.com/aws/amazon-cloudwatch-logs-for-fluent-bit#new-higher-performance-core-fluent-bit-plugin) has a [templating feature](https://github.com/aws/amazon-cloudwatch-logs-for-fluent-bit#templating-log-group-and-stream-names) which can be used to customize the log group and stream names.
10+
11+
First, you must enable the [kubernetes filter](https://docs.fluentbit.io/manual/pipeline/filters/kubernetes), which can add metadata like this:
12+
```
13+
kubernetes: {
14+
annotations: {
15+
"kubernetes.io/psp": "eks.privileged"
16+
},
17+
container_hash: "<some hash>",
18+
container_name: "myapp",
19+
docker_id: "<some id>",
20+
host: "ip-10-1-128-166.us-east-2.compute.internal",
21+
labels: {
22+
app: "myapp",
23+
"pod-template-hash": "<some hash>"
24+
},
25+
namespace_name: "default",
26+
pod_id: "198f7dd2-2270-11ea-be47-0a5d932f5920",
27+
pod_name: "myapp-5468c5d4d7-n2swr"
28+
}
29+
```
30+
31+
The kubernetes metadata can be referenced just like any other keys using the templating feature, for example, the following will result in a log group name which is /eks/{namespace_name}/{pod_name}.
32+
33+
```
34+
[OUTPUT]
35+
Name cloudwatch
36+
Match application.*
37+
region us-east-1
38+
log_group_name /eks/$(kubernetes['namespace_name'])/$(kubernetes['pod_name'])
39+
log_stream_name $(kubernetes['host'])/$(kubernetes['namespace_name'])/$(kubernetes['pod_name'])/$(kubernetes['container_name'])
40+
auto_create_group on
41+
```
42+
43+
If you want to deploy this example yourself, included is an altered version of the [Amazon CloudWatch Container Insights Daemonset](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Container-Insights-setup-logs-FluentBit.html) that uses this technique the customize the log stream and group names. Follow the steps 1 & 2 to create a namespace and config map. Then, instead of step 3, apply the file in this example with:
44+
45+
```
46+
kubectl apply -f fluent-bit.yaml
47+
```

0 commit comments

Comments
 (0)