Store Nginx Access Logs in Amazon CloudWatch with Logging Operator

This guide describes how to collect application and container logs in Kubernetes using the Logging operator, and how to send them to CloudWatch.
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 and a demo Application
Install the Logging operator and a demo application using Helm.
Deploy the Logging operator with Helm
To install the Logging operator using Helm, complete these steps.
Note: For the Helm-based installation you need Helm v3.2.1 or later.
-
Add the chart repository of the Logging operator using the following commands:
-
Install 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 CloudWatch
outputdefinition.Note: In production environment, use a longer
timekeyinterval to avoid generating too many objects. -
Create a
flowresource. -
Install log-generator to produce logs with the label
app.kubernetes.io/name: log-generator
Validate the deployment

If you don’t get the expected result you can find help in the troubleshooting section.