Transport all logs into Amazon S3 with Logging operator

This guide describes how to collect all the container logs in Kubernetes using the Logging operator, and how to send them to Amazon S3.
The following figure gives you an overview about how the system works. The Logging operator collects the logs from the application, selects which logs to forward to the output, and sends the selected log messages to the output. For more details about the Logging operator, see the Logging operator overview.

Deploy the Logging operator
Install the Logging operator.
Deploy the Logging operator with Helm
To install the Logging operator using Helm, complete the following steps.
Note: You need Helm v3.8 or later to be able to install the chart from an OCI registry.
-
Install the Logging operator into the logging namespace:
Expected output:
Note:
-
Helm has a known issue in version 3.13.0 that requires users to log in to the registry, even though the repo is public.
Upgrade to 3.13.1 or higher to avoid having to log in, see: https://github.com/kube-logging/logging-operator/issues/1522
-
If you’re installing the Helm chart from Terraform, reference the repository as
repository = "oci://ghcr.io/kube-logging/helm-charts/"(without thelogging-operatorsuffix). Otherwise, you’ll get a 403 Forbidden error.
-
Configure the Logging operator
-
Create AWS
secretIf you have your
$AWS_ACCESS_KEY_IDand$AWS_SECRET_ACCESS_KEYset you can use the following snippet.Or set up the secret manually.
-
Create the
loggingresource.Note: You can use the
ClusterOutputandClusterFlowresources only in thecontrolNamespace. -
Create an S3
outputdefinition.Note: In production environment, use a longer
timekeyinterval to avoid generating too many objects. -
Create a
flowresource. (Mind the label selector in thematchthat selects a set of pods that we will install in the next step) -
Install log-generator to produce logs with the label
app.kubernetes.io/name: log-generator
Validate the deployment
Check fluentd logs (errors with AWS credentials should be visible here):
Fluentd logs were written to the container filesystem up until Logging operator version 4.3, which has been changed to stdout with 4.4. See FluentOutLogrotate why this was changed and how you can re-enable it if needed.
Check the output. The logs will be available in the bucket on a path like:
If you don’t get the expected result you can find help in the troubleshooting section.