Easily Monitor Containerized Applications with Amazon CloudWatch Container Insights
How to collect, aggregate, and analyze metrics from your containerized applications using Amazon CloudWatch Container Insights.
Step 1: Set up Container Insights on Amazon EKS
Step 2: Deploy a Container Application in the Cluster
Step 3: Use CloudWatch Logs Insights Query to search and analyze container logs
To Run a CloudWatch Logs Insights Sample Query:
Step 4: Monitor Performance of the Application with Container Insights
View Container Insights Dashboard Metrics
View Additional Amazon EKS and Kubernetes Container Insights Metrics
Note: If you're within your inaugural 12-month phase, be advised that Amazon CloudWatch Container Insights falls outside the AWS free tier, hence usage could result in additional charges.
About | |
---|---|
✅ AWS experience | 200 - Intermediate |
⏱ Time to complete | 30 minutes |
🧩 Prerequisites | - AWS Account |
📢 Feedback | Any feedback, issues, or just a 👍 / 👎 ? |
⏰ Last Updated | 2023-10-02 |
- Install the latest version of kubectl. To check your version, run:
kubectl version --short
. - Install the latest version of eksctl. To check your version, run:
eksctl info
.
ClusterName
and RegionName
. In the following example, my-cluster
is the name of your Amazon EKS cluster, and us-east-2
is the region where the logs are published. You should replace these values with your own values. It's advisable to specify the same region where your cluster is located to minimize AWS outbound data transfer costs. Additionally, FluentBitHttpPort
is given a value of '2020' because this port is commonly used for monitoring purposes and allows for integration with existing tools, and FluentBitReadFromHead
is given a value of 'Off' to ensure that the logs are read from the end, not the beginning, which can be essential for managing large log files and optimizing performance.FluentBitHttpServer
for monitoring plugin metrics is on by default.workload.yaml
.- Create a Kubernetes manifest called workload.yaml and paste the following contents into it.
- Deploy the Kubernetes resources in
workload.yaml
.
- Use the following command to check the status of the deployed Nginx containers and ensure that they are running:
- Use the following command to view the real-time logs of the "load" Pod, which is continuously making requests to the Nginx service. Use Ctrl+C to stop.
/aws/containerinsights/Cluster_Name/application
which contains all log files in /var/log/containers
on each worker node in the cluster.- Open the CloudWatch console.
- In the navigation pane, choose Logs, and then choose Log groups.
- Click the log group
/aws/containerinsights/CLUSTER_NAME/application
. Where CLUSTER_NAME is the actual name of your EKS cluster. - Under the log details (top-right), click View in Logs Insights.
- Delete the default query in the CloudWatch Log Insight Query Editor. Then, enter the following command and select Run query:
- Use the time interval selector to select a time period that you want to query. For example:
- Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/.
- In the left navigation pane, open the Insights dropdown menu, and then choose Container Insights.
- Under “Container Insights” (top), select Performance Monitoring from the dropdown menu.
- In the “EKS Clusters” dropdown field, select the name of your cluster.
- Use the additional dropdown menus to filter resources, such as “EKS Clusters” and “EKS Pods.” For example:
- Create a Kubernetes manifest called
geo-api.yaml
with the content below to deploy a simple backend application called geo-api with the following command:
- Deploy the application using the command below:
- Create a load for the web server by running a container.
- Verify the Pods status:
- Let’s view the Container Insights metrics of this pod:
- Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/.
- In the navigation pane, choose Metrics, and then choose All metrics.
- Select the ContainerInsights metric namespace. Select the ClusterName, Namespace, and PodName, in the search bar, copy and paste PodName="geo-api".
- You can view the percentage of CPU units being used by the pod relative to the pod limit and the percentage of memory that is being used by pods relative to the pod limit by selecting the metrics below:
pod_cpu_utilization_over_pod_limit
pod_memory_utilization_over_pod_limit
Any opinions in this post are those of the individual author and may not reflect the opinions of AWS.