iTranslated by AI

The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
📖

re:Invent 2024: Enhancing Amazon ECS Observability and Actionable Insights

に公開
2024/12/10

Introduction

By transcribing various international presentations into Japanese articles, we aim to make high-quality, hidden knowledge more accessible. In this project, we feature the following presentation!

📖 AWS re:Invent 2024 - Enhancing observability in Amazon ECS to gain actionable insights (SVS328)

This video explains how to enhance Observability for Amazon ECS to gain actionable insights. Utilizing tools such as Container Insights, Application Signals, and CloudWatch Log Insights, it demonstrates how to identify and resolve performance degradation and error issues through three concrete scenarios using the actual Watch Store application. It also introduces how to analyze and visualize ECS cluster costs by combining ECS Split Cost Allocation and Amazon QuickSight. The video includes guidance on practical resources that can be implemented immediately, such as the One Observability Workshop and CDK/Terraform templates.
https://www.youtube.com/watch?v=8ABbfHlYTJ4
Note: This article is automatically generated from the video. It may contain typos or incorrect information, so please refer to the actual video for accurate details.
Clicking on the images will jump to the corresponding scene in the video.

For other re:Invent 2024 transcript articles, please check this Spreadsheet. Please take a look!

Main Content

Amazon ECS Observability Session: Overview and Objectives

Thumbnail 0

Welcome to re:Invent. Hello. Thank you for joining today's session, "SVS328: Enhancing observability in Amazon ECS to gain actionable insights." I am Steven David, Principal Solutions Architect at AWS. And let me introduce my co-presenter, Lucy.

Hello, everyone. We are very happy you could join us today. I am Lucy Hartung, Senior Worldwide BD Specialist at AWS. I heard that some of you stood in line for 30 minutes for this session, and I am very touched. We hope to provide valuable information over the next hour on how to gain actionable insights with Amazon ECS.

Thumbnail 60

This is today's agenda. First, we will deepen our understanding of the challenges customers are facing, and then delve into the benefits of Observability and the necessity of observing ECS. We have prepared actual scenarios and demos to provide a practical introduction on how to leverage AWS features to gain actionable insights. Finally, we will provide information on reference resources and next steps so you can apply what you learn in this session to your daily operations.

Container Technology and the Benefits of ECS: The Importance of Observability

Thumbnail 120

Now, I would like to ask you all a question. How many of you are currently building workloads or applications on Amazon ECS? Could you please raise your hand? That's great. Containers are helping customers innovate more quickly and effectively. Why is that possible? Containers offer portability. All application packages are bundled into a single container and run on the same OS, ensuring consistency. This innovation, portability, and consistency enable faster automation, increase software delivery speed, and reduce resource overhead.

Thumbnail 200

This is why so many people choose to build on ECS today. The most important feedback we've received from customers is about the simplicity of building with ECS. Customers say they love the seamless integration with other AWS services. Let's take a closer look at this automation workflow. A typical application on ECS begins with a build and deployment pipeline equipped with agility and speed, followed by observing metrics, logs, and application health. Throughout the process, security measures are in place. And let's not forget orchestration, a key element of automation. Orchestration helps determine networking, compute, and storage while handling critical aspects such as scheduling and auto-scaling.

Thumbnail 270

This is the core reason why so many people choose to build workloads and applications on ECS. For those of you already aware of how wonderful ECS is, this might just be a confirmation of what you know. Oops, it looks like we have a problem here. I just finished talking about how great ECS is, but no matter how wonderful ECS is, or how much we love it, problems sometimes occur. Containers break occasionally, and not every day is sunny with rainbows. Sometimes we have to fix problems. Our goal is not to promise 100% availability on ECS; that would be leading you toward failure.

Instead, our goal is to support customers when problems occur in containers. We want to ensure we provide the right tools and features to identify and resolve issues.

Thumbnail 340

Let's talk about why Observability is important. Observability starts with ensuring visibility into containers through metrics and logs. This serves as the foundation for troubleshooting real-time issues. However, Observability goes beyond root cause identification and problem resolution. It extends to business benefits, such as understanding the end-user experience in an ECS environment. When building applications on ECS, there is always user interaction. You need to know if page loads are failing or if users are successfully completing transactions. You want to maintain such experiences and ensure that no issues are occurring.

We often hear complaints from customers saying that pages won't load or they cannot register. We want to be able to understand the information and resolve issues before end-users experience them. That is also part of Observability. And finally, cost is crucial. For many, this might not seem obvious at first. How many times have you been asked by a manager or project leader about the cost of building an application? When budgeting for the next year, you need to understand how much the application will cost or whether it is scaling excessively. These aspects are extremely important when building workloads and applications on ECS, and this is the overall picture of Observability.

Scenario 1: Identifying and Resolving Application Performance Issues

Thumbnail 480

Thumbnail 500

Now, I'd like to pass it over to my partner Steven to talk about Container Insights for ECS. We've talked about why we're here, so let's discuss how we approach this. When errors occur, we're going to look at four different scenarios, but you need to understand how to get insights and use the available AWS tools to understand what's happening in your cluster. One case could be having multiple applications deployed across multiple accounts. How can we make this more application-centric? How can we get insights across the entire application, including resources in ECS and other services?

Thumbnail 520

Thumbnail 550

Thumbnail 570

You need to understand application health and which KPIs to monitor. Let's look at common metrics like error rates and latency. When looking at metrics, logs, and traces, you need to understand how to combine them to make the necessary changes to your codebase. Finally, sometimes you're not just debugging but improving—how can you enhance application responsiveness and use resources more effectively?

Thumbnail 580

Thumbnail 600

Let's look at the application we're using for the demo. It's basically a watch store sample application that we use in many demos across the AWS container ecosystem. Looking at the homepage, you can see a catalog where you can sort by watch type.

Thumbnail 610

Thumbnail 620

Once you select a watch type, you can add it to your cart and proceed to the checkout process. This is a multi-step checkout process where various issues can occur during a transaction. This is meant to visually represent the type of application we are dealing with.

Thumbnail 630

Let's assume you are the infrastructure administrator for this application. You have received reports that the application's responsiveness is not as expected and there is an issue with the application itself. You've been asked to help debug it, as system complaints are increasing. Opening the console and looking at the homepage, there is something you didn't see before: the "My Applications" widget. You can use this widget to collect various resources related to the application, from monitoring and CPU information to related compute.

Thumbnail 680

Thumbnail 690

Let's take a closer look. We have the Watch Application set up, with general information displayed at the top. Below that is all the Compute information. First, EC2 Compute is highlighted, showing whether there are any related alarms. Lambda Compute is also displayed here. Scrolling back up, the immediate realization is that nothing particularly stands out—it's just functioning normally. At least, you can gather the information in one place. That's because there's other information here that you'd want to check. There is cost information, although in this specific scenario, nobody is asking about costs. There are also security issues that you might want to investigate later. Nobody has asked about them, but there appear to be several high-priority items that should be checked later.

Thumbnail 740

Scrolling down, I noticed there were no alarms for this case, so I decided to check CloudWatch. From here, I can go directly to CloudWatch information to check the status of the related EC2 instances. Overall, there isn't much noticeable activity, but you can see a large spike in the networking for this application. Looking at the network side, this seems to be the first clue. Since the complaint is about slowness rather than frequent errors, the cause might be here.

Thumbnail 760

To examine this in more detail, let's look at the recently upgraded Container Insights for Amazon ECS. This is the new look and feel of Container Insights. It has a new design using hexagonal elements. In this environment, we only have one cluster, but if you have multiple clusters, many hexagons will appear, and you can click on the cluster you want to investigate to switch to it. This allows you to investigate in detail at that level.

Thumbnail 800

Thumbnail 820

The enhanced home page for Container Insights displays several key metrics. Looking at CPU usage, there are no particular anomalies, and it is actually quite low overall. Below that, there are more detailed CPU and memory metrics, which also do not seem to be problematic. The point is that you have an environment ready for immediate investigation. Now, let's dive a little deeper into the related performance metrics. For ECS workloads, you can split information by cluster, or if necessary, check at the instance, task, or service level. You can analyze data from various perspectives to grasp the situation.

Thumbnail 880

Looking below, it is immediately clear that latency is standing out in this case as well. I have a hunch that there is a problem with the application's latency. While I don't yet know which component of the application has the problem, I am certain something is happening. Let's use these tools to investigate further. I checked a few other metrics out of curiosity, but none of them showed anything unusual. Looking at each service that makes up the application individually (displayed as blue links) below, nothing stands out as a definitive issue.

Thumbnail 910

Other than the latency issue, no other obvious problems are visible. Clicking on Application Signals, which is integrated within the same interface, I can still see the first red indicator on the screen. This red text showing the SLI status indicates that there is a Service Level Indicator with a configured threshold, and alarm has been triggered because that threshold was exceeded. This tells us that the response should be faster and the system should be operating differently than it currently is.

Thumbnail 950

Thumbnail 960

Thumbnail 970

I decided to check Application Signals since it's worth investigating. I immediately noticed an unusual latency spike that is not typically seen in this application. Looking into this latency spike, I found it was related to the Cart store. I want to highlight here that I have identified the component. Initially, I was looking at the entire application, but now I have been able to narrow it down to a specific component of the application to identify the root cause.

Thumbnail 980

Thumbnail 990

Thumbnail 1000

I also confirmed which action is related to the issue. This was happening during the execution of a GET action. I clicked on the latency chart to immediately investigate the traces. Viewing the traces allows me to see what is happening at that moment. Looking at the data, an 800ms delay in a small component of the web application is clearly unacceptable. I was able to track it from the entire application down to the specific component causing the problem. I now have a good idea that the latency issue is in this Carts controller, so I can go back to the developers, explain that I have received reports and that users are experiencing problems, and pinpoint exactly where they should investigate what the issue was.

Scenario 2: Rapid Diagnosis and Resolution of Critical Errors

Thumbnail 1050

Thumbnail 1070

Thumbnail 1080

That was our first scenario. We needed to investigate a performance issue where the response was slow, rather than a clear error from the application. In the next scenario, a critical error is occurring. This is a new issue that hasn't happened before. The application was running smoothly, but suddenly my phone started ringing. Things like this usually happen around 3 AM, don't they? When confirming what is happening, there are several approaches you can take. This time, I'm going to try finding a solution using Log Insights. I think it's an interesting starting point for this specific problem. Of course, you can also investigate anomalies if there are patterns that need to be tracked over time.

Thumbnail 1110

Thumbnail 1120

Thumbnail 1130

Thumbnail 1160

I want to correlate the error message with something that might lead to a resolution. The goal is not just to identify what is happening, but also to propose how to resolve it. Let's see if this configuration allows for that. In this case, I already have the screen displayed. Knowing which application I am dealing with, I am directly checking Application Signals. I probably started from the Watch Store application, but I'm already there. I can immediately see two errors the system is warning about through the SLOs I configured. Looking at the metrics to quickly pinpoint what is happening, I don't see anything particularly important other than an increase in Faults. So, I will focus on that to proceed with the investigation.

Thumbnail 1170

Thumbnail 1190

Clicking on that displays Golden Metrics at the top. In this case, the Faults and Errors metrics are the most helpful for understanding the situation. Clicking to check the traces shows that everything is linked. These systems interact to provide insights into what is happening. And I can see that there is a problem with the Checkout service. I've decided to use CloudWatch Log Insights to investigate the logs for that service.

Thumbnail 1210

Thumbnail 1240

CloudWatch Log Insights allows me to examine and deeply analyze the logs for that service. When I access Log Insights, I see a general query providing a wealth of information across the entire application. Since I have already identified that the problem lies around the Checkout service, I want to narrow the scope to that. I know the Checkout logs are within the retail task, so I will limit the query to that part. Searching for "Cart" there should display the necessary information.

Thumbnail 1250

Running the search reveals something interesting. Actual errors are shown, and there were multiple ways to find this error. I could have also found the error by returning to Application Signals and checking for exceptions. What is more interesting on this page is knowing when the error occurred. The blue bar has been appearing for several hours before this event. I also know exactly what the content of the error is - a list mismatch is occurring that didn't exist before this event took place.

Thumbnail 1290

Thumbnail 1300

Once I identified this, I wanted to check if anything had happened to this service a few hours ago, or if there were any traces of changes. Since I'm making changes to the cluster itself and its output, let's check the cluster. There is a deployment page, which is one of the features we added. This allows us to track recent activities on this service. If this had been a case where deploying a new service didn't function fully, ECS would have automatically rolled back once the health check failed. In this instance, the service is partially functional, but there is a situation where specific functionality within the service struggles when a particular API is called.

From here, I know that a new deployment took place a few hours ago today. Since the deployment occurred a few hours ago and errors began appearing around the same time, it is easy to inform the team of the need for a rollback to the previous version and an investigation. Because a new error is occurring, further testing on the Cart service's list function is required. In this way, I can narrow down what is happening and find correlations that actually allow for a fix across these boundaries.

Scenario 3: Tracking and Troubleshooting Intermittent Issues

Thumbnail 1390

Thumbnail 1420

Thumbnail 1440

Thumbnail 1450

Let's look at scenario 3. The next case can sometimes be more troublesome. Unlike the previous scenario where the service was consistently failing, this is a situation where the service is not failing consistently. The overall health of the application is good, and health checks are always passing. However, when following a specific path with specific input, it fails. This is also a common problem encountered especially when calling external APIs that you cannot control. You can trace this in these services, and the goal here is to reduce the time to detection, and hopefully, reduce the time to recovery as well.

Thumbnail 1460

Thumbnail 1470

Thumbnail 1480

Thumbnail 1500

Let's examine this situation in more detail. This time, we've returned to the Watch Store, but we'll confirm it with less information than before. I want to use this to grasp the situation. Looking around, the state of the compute is healthy, with nothing particularly concerning. There are some spikes, but they aren't extremely large. We plan to address the issues of cost and importance after this video is released. However, as a new element, there is a Canary monitored as part of the application, which is triggering alarms. This alarm comes from another feature we haven't explained yet. One of the things we are running to track new issues in this application is these Synthetics. This Canary is not just simple health checks or API calls.

This actually executes workflows within the system. We use the retail store demo for testing this workflow. As I showed when I first introduced the application earlier, it executes that whole flow: clicking on the catalog, adding items to the cart, and starting the checkout process, all the way to checkout. This is achieved by turning on the recorder for this service, recording the operations while clicking through the application, and adding that to the Canary. It also provides screenshots and information.

What is particularly useful is that it tells us when more complex errors occur. There are many red dots displayed, but if we look at the last hour, not everything is a red dot. For me, I would prefer everything to be either all red (failure) or all blue (normal operation). If you get results where it sometimes works and sometimes doesn't, even when using the same input, that is a very difficult situation to handle. It is also difficult to track. These Canaries help understand whether the problem is due to the input or if the service itself is occasionally causing issues. In this case, since the input is consistent, it is more reasonable to suspect the latter.

Thumbnail 1620

It is clear that a problem is occurring, but this workflow is functioning across the entire application. I don't know yet which component has a major issue, but I know that a failure is occurring somewhere in the application. Let's return to Application Signals, as it is a suitable method for connecting these dots. Immediately, I can see that this service is displaying a Service Health Indicator. It is not meeting the expected response and is in violation of the contract. We were expecting better performance. Looking at this, I can see that some of the services it communicates with are consistently having issues, and I can also confirm the rate at which these issues are occurring. The Checkout service has an issue, and the Retail Store UI also shows an issue, but the rate there is much lower. This is probably because it eventually communicates with the Checkout store when interacting with the UI.

Thumbnail 1670

Thumbnail 1720

At this point, I suspect the Checkout service and am checking the metrics to understand what they are indicating. I don't see much of a problem with latency. There is some, but I don't think it's a major issue. The graph shows an interesting pattern. The chart on the left shows something happening at the top. Retries might be occurring. However, what we should really focus on is the graph showing more errors than the others. The orange line highlighted earlier indicates a higher failure rate and problem. And in the final graph, significantly more failures are clearly visible. The orange line has diverged significantly upwards from the other lines. It shouldn't be like that; it should be trending at the same level as the other lines.

Thumbnail 1730

Thumbnail 1750

It has become quite clear that the Checkout Service is the main cause of the problem. Looking at the Faults section and clicking on it allows me to investigate in detail what is occurring. I can see there is a problem with the GET flow. It's not the Checkout Service in general; looking here, the POST and health check responses are good. We haven't configured SLOs for these, but no errors have been reported. The Checkout Service is where the errors are appearing.

Thumbnail 1770

Thumbnail 1780

Thumbnail 1790

Thumbnail 1800

So, let's check Traces to see what's happening. In the previous example, we moved to a different section to check the situation. Here, let's look at the overall flow of the Checkout. At first glance, it looks fine, but there is actually an error in this flow. Clicking this error allows me to grasp what is happening and may help in resolving the problem. Various information is embedded here, such as summary information and the resources being used, but this time let's check Exceptions to see if any exceptions are being raised.

Are exceptions being raised? Yes, they are. I named this exception. It is not an actual exception, but it stands out significantly as showing a random Fault in this situation. I can trace this and check the related code. This is part of my GetCheckout process, which is part of the code within the application. I can confirm the error actually being thrown, which provides good context to resolve this problem and find a way to fix it.

What I want you to understand from these scenarios is the cooperation between Enhanced Container Insights and Application Signals. By using Container Insights, you can delve deep into many metrics to understand them, and by linking those with Application Signals, you can verify if a problem is occurring from an application-centric perspective. Furthermore, if the necessary information is in the logs, you can delve even deeper. I would like to hand it over to Lucy here.

ECS Cost Management and Next Steps for Observability

Thumbnail 1880

Thumbnail 1900

Thank you. Steven explained how to use these features to troubleshoot and resolve problems. Now, let's delve into a point that may not be very obvious. That is cost. As I mentioned earlier, these costs are important for application budget allocation and for the people who need that information, such as project leaders and management teams. You can also set up alerts and notifications to be notified immediately if you exceed your budget for a specific application or workload.

Thumbnail 1910

Thumbnail 1940

Thumbnail 1950

Thumbnail 1960

Let's look in detail at how to check costs. First, let's start with the basic initial setup. The current situation is that many customers don't know where to perform cost management. If you scroll down to Cost Preferences, there is an option called ECS Split Cost Allocation. I want you to know about this basic setting; you need to configure this feature and setting correctly.

Thumbnail 2020

The reason is that by enabling this setting, you will be able to export the data. Go to the same Billing and Cost Management console and open Data Explorer. Here you can confirm that Split Data Cost is enabled, and you can obtain that information. This is the fundamental setting for the content I will show you in the demo from here on. The reason this setting is necessary is to enable you to utilize this data to obtain information and actually execute more advanced queries regarding the information you need. Here, I am executing a query using that Split Cost data. There are several pre-built queries here.

Thumbnail 2040

Thumbnail 2080

Thumbnail 2090

Let's close this query and execute a new pre-built query to see how it is displayed. This is highly customizable depending on the items you want to check in ECS. These are pre-built queries that define Line Items, Usage Types, and so on, but you can freely create queries for items you specifically want to check in ECS. Let's execute this query right away. Now, I am generating a preview of the executed query. A list of items is displayed here, and items such as Item ID, all items in the ECS cluster defined by the query, Usage Type, and Product ID are shown. Let's scroll a little.

Thumbnail 2110

Thumbnail 2120

I will scroll a bit more so you can see all the information generated in this format. However, this is a list view, and if a project leader or manager asks about the budget, this way of presenting the data may not be the most effective. Therefore, you can utilize Amazon QuickSight to express this list view data in a more easily viewable form.

Thumbnail 2140

Thumbnail 2190

Thumbnail 2200

Let's pause here. Moving from the list view we just executed, we now go to Amazon QuickSight. Based on that dataset, there are several pre-built dashboards for deeply analyzing ECS cluster costs. Let's look at ECS Usage Type first. This displays the Usage Type and its cost across the entire ECS cluster. As you can see from this large blue chart, the CPU Usage Type accounts for the majority of the usage. Looking at the next chart, you can clearly understand which elements of the ECS cluster account for the most cost.

Thumbnail 2220

Thumbnail 2240

Now, let's look at the breakdown of the ECS cluster. This is the cost of the Watch Store that Steven introduced in the demo, but you might be running other applications on ECS as well. Looking at this, you can clearly compare the construction cost of the Watch Store and the construction cost of other applications on ECS. Looking to the right, a breakdown by region is displayed for teams building applications in multiple regions. You can confirm how much cost each region is spending on ECS, and whether that is as expected. The East team is spending the most cost on the ECS cluster, followed by the West team, so analysis by region is also possible this way.

Thumbnail 2280

Thumbnail 2300

Now, let's focus on the Watch Store that Steven demoed earlier and look at the top. This is a second-layer analysis for this specific application, showing the cost by usage type, CPU and GB, for the Watch Store. This provides more detailed information about the application introduced in the demo this time. And finally, you can also check the cost per Task. For this Watch Store, you can understand how much cost each ECS Task is incurring. This provides a very clear definition and understanding of the project cost for a specific application or the entire ECS cluster. When asked about application costs by a supervisor, you can show the costs related to workloads or applications in such an easily understandable form.

Thumbnail 2350

Thumbnail 2400

With this, you can return your containers to the most organized state. To summarize, Steven explained various functions based on different customer scenarios, such as real-time issues, intermittent issues, and API issues, and I covered the cost aspect. This provides the tools to keep your containers in the most organized state. You might return to a problematic state again in a few days, but at least at that time, you should know where to check and how to fix it to return to this ideal state quickly. Finally, I will introduce the resources and next steps you should take away from this presentation.

First, I recommend starting with the One Observability Workshop, which is available for free to all customers. You can contact your AWS account representative to schedule a workshop to test all the features Steven and I explained.

Next, there is a best practices session where you can learn how to set up alarms, obtain metrics, and check logs. For CDK and Terraform users, we have pre-built CDK and Terraform templates available so you can start Observability faster. This can speed up the introduction of Observability. For those who want to learn more, there are many e-learning resources related to Observability on the Skill Builder platform.

Thumbnail 2500

Could those who learned something new in this session please raise your hand? Fantastic. I hope this will be helpful for your ECS journey. And thank you very much for gathering here during this time after lunch. Thank you to everyone who participated today. Finally, please be sure to complete the survey and provide your feedback on our session.


※ This article was created entirely automatically using Amazon Bedrock.
※ In light of concerns about internet pollution by generative AI articles, this article aims to convert session videos into text and images with almost no change in the amount of information, thereby maintaining the value of the original content itself as much as possible while enhancing Accessibility and Googlability in multiple languages.

Discussion