Troubleshooting Amazon EKS API servers with Prometheus

容器
海外精选
海外精选的内容汇集了全球优质的亚马逊云科技相关技术内容。同时,内容中提到的“AWS” 是 “Amazon Web Services” 的缩写,在此网站不作为商标展示。
0
0
{"value":"It’s every on-call’s nightmare—awakened by a text at 3 a.m. from your alert system that says there’s a problem with the cluster. You need to quickly determine if the issue is with the Amazon EKS managed control plane or the new custom application you just rolled out last week. Even though you installed the default dashboards the blogs recommended, you’re still having difficulty understanding the meaning of the metrics you are looking at.\n\nIf only you had a dashboard that was focused on the most common problems seen in the field—one where you understood what everything means right away, letting you quickly scan for even obscure issues efficiently.\n\n### **The API server troubleshooter**\nThe above is an ambitious goal, so I created a starter dashboard to help you with troubleshooting [Amazon Elastic Kubernetes Service (Amazon EKS)](https://aws.amazon.com/eks) API Servers with Prometheus. We will use it to help you understand the metrics I look at when troubleshooting production clusters. I will put a special focus on what these metrics mean, and why I think they are important.\n\nWe will use the newer [Grafana 8.5.0](https://grafana.com/docs/grafana/latest/release-notes/release-notes-8-5-0/) features, which might be disorienting at first, but it is my hope that with a modest time investment you will also find them effective for pinpointing complex problems quickly.\n\n### **Prerequisites**\nThe following guide is designed to help operators that have experience with production Kubernetes environments. The rest of this guide assumes that you already have access to a Prometheus/Grafana setup.\n\n#### **Steps**\n1. If you are coming from a different monitoring platform you can follow along in our [guide to setting up Amazon Managed Grafana blog post](https://aws.amazon.com/blogs/mt/amazon-managed-grafana-getting-started/)\n2. Once you are logged into Grafana, please download the [API troubleshooter dashboard](https://github.com/RiskyAdventure/Troubleshooting-Dashboards/blob/main/api-troubleshooter.json)\n3. Navigate to the Manage tab under dashboards\n\n![image.png](https://dev-media.amazoncloud.cn/8fba3bdde377441893af4175eb96d4c6_image.png)\n\n4. From the Manage window, click Import\n\n![image.png](https://dev-media.amazoncloud.cn/a5926e1b6d6248fabc34c8ab80ddedc4_image.png)\n\n\n5. Then click upload JSON file to import the chart\n\n\n![image.png](https://dev-media.amazoncloud.cn/c41dc1de8d714ccc811640a18cd7a3c6_image.png)\n\n### **Understanding the Problem**\nLet’s say you found an interesting open-source project that you wanted to install in your cluster. That operator deploys a DaemonSet to your cluster that might be using malformed requests, a needlessly high volume of LIST calls, or maybe each of its DaemonSets across all your 1,000 nodes are requesting status of all 50,000 pods on your cluster every minute!\n\nDoes this really happen often? Yes, it does! Let’s take a quick detour on how that happens.\n\n#### **Understanding LIST vs. WATCH**\nSome applications need to understand the state of the objects in your cluster. For example, your machine learning (ML) application wants to know the job status by understanding how many pods are not in the Completed status.\n\nIn Kubernetes, there are well-behaved ways to do this with something called a WATCH, and some not-so-well-behaved ways that list every object on the cluster to find the latest status on those pods.\n\n#### **A well-behaved WATCH** \nUsing a WATCH or a single, long-lived connection to receive updates via a push model is the most scalable way to do updates in Kubernetes. To oversimplify, we ask for the full state of the system, then only update the object in a cache when changes are received for that object, periodically running a re-sync to ensure that no updates were missed.\n\nIn the below image we use the ```apiserver_longrunning_gauge``` to get an idea of the number of these long-lived connections across both API servers.\n\n![image.png](https://dev-media.amazoncloud.cn/0264c8ac913c4769b35ad06f4a78ea74_image.png)\n\nEven with this efficient system, we can still have too much of a good thing. For example, if we use many very small nodes, each using two or more DaemonSets that need to talk to the API server, it is quite easy to dramatically increase the number of WATCH calls on the system unnecessarily. For example, let’s look at the difference between eight xlarge nodes vs. a single 8xlarge. Here we see an 8x increase of WATCH calls on the system!\n\n![image.png](https://dev-media.amazoncloud.cn/e030f2b736094f98bc50384fb5925d1d_image.png)\n\nNow these are efficient calls, but what if instead they were the ill-behaved calls we alluded to earlier? Imagine if one of the above DaemonSets on each of the 1,000 nodes is requesting updates on each of the total 50,000 pods in the cluster. We will explore this idea of an unbounded list call in next section.\n\nA quick word of caution before continuing, the type of consolidation in the above example must be done with great care, and has many other factors to consider. Everything from the delay of the number of threads competing for a limited number of CPUs on the system, Pod churn rate, to the maximum number of volume attachments a node can handle safely. However, our focus will be on the metrics that lead us to actionable steps that can prevent issues from happening—and maybe give us new insight into our designs.\n\nThe WATCH metric is a simple one, but it can be used to track and reduce the number of watches, if that is a problem for you. Here are a few options you could consider to reduce this number:\n\n- Limit the number of ConfigMaps Helm creates to track History\n- Use Immutable ConfigMaps and Secrets which do not use a WATCH\n- Sensible node sizing and consolidation\n\n\n### **The unbounded list call**\nNow for the LIST call we have been talking about. A list call is pulling the full history on our Kubernetes objects each time we need to understand an object’s state, nothing is being saved in a cache this time.\n\nHow impactful is all this? That will vary depending on how many agents are requesting data, how often they are doing so, and how much data they are requesting. Are they asking for everything on the cluster, or just a single namespace? Does that happen every minute, on very node?\n\nLet’s use an example of a logging agent that is appending Kubernetes metadata on every log sent from a node. This could be an overwhelming amount of data in larger clusters. There are many ways for the agent to get that data via a list call, so let’s look at a few.\n\nThis request is asking for pods from a specific namespace.\n\n```/api/v1/namespaces/my-namespace/pods```\n\n\nNext, we request all 50,000 pods on the cluster, but in chunks of 500 pods at a time.\n\n```/api/v1/pods?limit=500```\n\nThe next call is the most disruptive. Fetching all 50,000 pods on the entire cluster at the same time.\n\n```/api/v1/pods```\n\nThis happens quite commonly in the field and can be seen in the logs.\n\n### **Stopping bad behavior**\nHow can we protect our cluster from such bad behavior? Before Kubernetes 1.20, the API server would protect itself by limiting the number of *inflight* requests processed per second. Since etcd can only handle so many requests at one time in a performant way, we need to ensure the number of requests is limited to a value per second that keeps etcd reads and writes in a reasonable latency band. Unfortunately, at the time of this writing, there is no dynamic way to do this.\n\nIn the below chart we see a breakdown of read requests, which has a default maximum of 400 inflight request per API server and a default max of 200 concurrent write requests. In a default EKS cluster you will see two API servers for a total of 800 reads and 400 writes. However, caution is advised as these servers can have asymmetric loads on them at different times like right after an upgrade, etc.\n\n![image.png](https://dev-media.amazoncloud.cn/b00ac542f5ad4e9bbde767ce9823fc87_image.png)\n\n\nIt turns out that the above was not a perfect scheme. For example, how could we keep this badly behaving new operator we just installed from taking up all the inflight write requests on the API server and potentially delaying important requests such as node keepalive messages?\n\n### **API Priority and Fairness**\nInstead of worrying about how many read/write requests were open per second, what if we treated the capacity as one total number, and each application on the cluster got a fair percentage or share of that total maximum number?\n\nTo do that that effectively, we would need to identify who sent the request to the API server, then give that request a name tag of sorts. With this new name tag, we could then see all these requests are coming from a new agent we will call “Chatty.” Now we can group all of Chatty’s requests into something called a flow, that identifies those requests are coming from the same DaemonSet. This concept now gives us the ability to restrict this bad agent and ensure it does not consume the whole cluster.\n\nHowever, not all requests are created equal. The control plane traffic that is needed to keep the cluster operational should be a higher priority than our new operator. This is where the idea of priority levels comes into play.\n\nWhat if, by default, we had a several “buckets” or queues for critical, high, and low priority traffic? We do not want the chatty agent flow getting a fair share of traffic in the critical traffic queue. We can however put that traffic in a low priority queue so that flow is competing with perhaps other chatty agents. We then would want to ensure that each priority level had the right number of shares or percentage of the overall maximum the API server can handle to ensure the requests were not too delayed.\n\n#### **Priority and fairness in action**\nSince this is a relatively new feature, many existing dashboards will use the older model of maximum inflight reads and maximum inflight writes. Why this can be problematic?\n\nWhat if we were giving high priority name tags to everything in the kube-system namespace, but we then installed that bad agent into that important namespace, or even simply deployed too many applications in that namespace? We could end up having the same problem we were trying to avoid! So best to keep a close eye on such situations.\n\nI have broken out for you some of the metrics I find most interesting to track these kinds of issues.\n\n- What percentage of a priority group’s shares are used?\n- What is the longest time a request waited in a queue?\n- Which flow is using the most shares?\n- Are there unexpected delays on the system?\n\n\n##### **Percent in use**\nHere we see the different default priority groups on the cluster and what percentage of the max is used.\n\n![image.png](https://dev-media.amazoncloud.cn/83e02912203a4c63a994ed1093f67f66_image.png)\n\n*New metrics in Kubernetes 1.21*\n\n##### **Time request was in queue**\nHow long in seconds the request sat in the priority queue before being processed.\n\n![image.png](https://dev-media.amazoncloud.cn/711e66a43e034b699cac0620b4368650_image.png)\n\n##### **Top executed requests by flow**\nWhich flow is taking up the most shares?\n\n![image.png](https://dev-media.amazoncloud.cn/7c0cac2ea3f447d4b1b66ac6a29cd076_image.png)\n\n##### **Request Execution Time**\nAre there any unexpected delays in processing?\n\n![image.png](https://dev-media.amazoncloud.cn/b775360ac0054b5a88ee58d2daf45858_image.png)\n\n### **The big picture**\nNow that we understand the nature of the things that cause API latency, we can take a step back and look at the big picture. It’s important to remember that our dashboard designs are simply trying to get a quick snapshot if there is a problem we should be investigating. For detailed analysis, we would use ad-hoc queries with PromQL—or better yet, logging queries.\n\nWhat are some ideas for the high-level metrics we would want to look at?\n\n- What API call is taking the most time to complete?\nWhat is the call doing? (Listing objects, deleting them, etc.)\nWhat objects is it trying to do that operation on? (Pods, Secrets, ConfigMaps, etc.)\n- Is there a latency problem on the API server itself?\nIs there a delay in one of my priority queues causing a backup in requests?\n- Does it just look like API server is slow because the etcd server is experiencing latency?\n\n\n#### **Slowest API call**\nIn the below chart we are looking for the API calls that took the most time to complete for that period. In this case we see a custom resource definition (CRD) is calling a LIST function that is the most latent call during the 05:40 time frame. Armed with this data we can use CloudWatch Insights to pull LIST requests from the audit log in that timeframe to see which application this might be.\n\n![image.png](https://dev-media.amazoncloud.cn/0454b0e1835347e8980d1f3244ec8313_image.png)\n\n##### **API Request Duration**\nThis API latency chart helps us to understand if any requests are approaching the timeout value of one minute. I like the histogram over time format below as I can see outliers in the data that a line graph would hide.\n\n\n![image.png](https://dev-media.amazoncloud.cn/afaf731005bc468295dbfe9a3320847c_image.png)\n\nSimply hovering over a bucket shows us the exact number of calls that took around 25 milliseconds.\n\n![image.png](https://dev-media.amazoncloud.cn/5c9d5c21bf7b45fbb75b4c9f8db12896_image.png)\n\nThis concept is important when we are working with other systems that cache requests. Cache requests will be fast; we do not want to merge those request latencies with slower requests. Here we can see two distinct bands of latency, requests that have been cached, and those that have not.\n\n![image.png](https://dev-media.amazoncloud.cn/9cc9c6c06a304aa28ea1c09ac8ecd03d_image.png)\n\n##### **etcd Request Duration**\netcd latency is one of the most important factors in Kubernetes performance. Amazon EKS allows you see this performance from the API server’s perspective by looking at the ```request_duration_seconds_bucket``` metric.\n\n![image.png](https://dev-media.amazoncloud.cn/5781530ba88f4f91b9ac48ccfca87fab_image.png)\n\nWe can now start to put the things we learned together by seeing if certain events are correlated. In the below chart we see API server latency, but we also see much of this latency is coming from the etcd server. Being able to quickly move to the right problem area with just a glance is what makes a dashboard powerful.\n\n![image.png](https://dev-media.amazoncloud.cn/24a805bb937c4773905c7fe2d4801680_image.png)\n\n### **Conclusion**\nWe have covered quite a bit of ground in a short period of time. There is, of course, much more to explore and discuss, but I hope this gives you a firm footing to begin your own journey of creating dashboards with information you find important. If that all sounds like a bit much right now, I would encourage you just to download the dashboard I have put together for you [here](https://github.com/RiskyAdventure/Troubleshooting-Dashboards/blob/main/api-troubleshooter.json).\n\nAre you a Kubernetes monitoring enthusiast? If so, you can check out some of [my other dashboards](https://github.com/RiskyAdventure/Troubleshooting-Dashboards). If you have strong opinions on what is important to monitor in production or have good tips and tricks you would like to share, I would love to hear from you! You can reach me at [shancor@amazon.com](shancor@amazon.com).\n\n![image.png](https://dev-media.amazoncloud.cn/48dc8b50444f4b9291e57f8c0a83f440_image.png)\n\n**Shane Corbett**\n\nShane Corbett is a Senior Containers Specialist at AWS focused on helping customers with the finer points of Kubernetes large scale design and performance. When not pushing Kubernetes to extremes you will find Shane pursuing his lifelong obsession of exploring the edge of the extreme sports world.","render":"<p>It’s every on-call’s nightmare—awakened by a text at 3 a.m. from your alert system that says there’s a problem with the cluster. You need to quickly determine if the issue is with the Amazon EKS managed control plane or the new custom application you just rolled out last week. Even though you installed the default dashboards the blogs recommended, you’re still having difficulty understanding the meaning of the metrics you are looking at.</p>\n<p>If only you had a dashboard that was focused on the most common problems seen in the field—one where you understood what everything means right away, letting you quickly scan for even obscure issues efficiently.</p>\n<h3><a id=\"The_API_server_troubleshooter_4\"></a><strong>The API server troubleshooter</strong></h3>\n<p>The above is an ambitious goal, so I created a starter dashboard to help you with troubleshooting <a href=\"https://aws.amazon.com/eks\" target=\"_blank\">Amazon Elastic Kubernetes Service (Amazon EKS)</a> API Servers with Prometheus. We will use it to help you understand the metrics I look at when troubleshooting production clusters. I will put a special focus on what these metrics mean, and why I think they are important.</p>\n<p>We will use the newer <a href=\"https://grafana.com/docs/grafana/latest/release-notes/release-notes-8-5-0/\" target=\"_blank\">Grafana 8.5.0</a> features, which might be disorienting at first, but it is my hope that with a modest time investment you will also find them effective for pinpointing complex problems quickly.</p>\n<h3><a id=\"Prerequisites_9\"></a><strong>Prerequisites</strong></h3>\n<p>The following guide is designed to help operators that have experience with production Kubernetes environments. The rest of this guide assumes that you already have access to a Prometheus/Grafana setup.</p>\n<h4><a id=\"Steps_12\"></a><strong>Steps</strong></h4>\n<ol>\n<li>If you are coming from a different monitoring platform you can follow along in our <a href=\"https://aws.amazon.com/blogs/mt/amazon-managed-grafana-getting-started/\" target=\"_blank\">guide to setting up Amazon Managed Grafana blog post</a></li>\n<li>Once you are logged into Grafana, please download the <a href=\"https://github.com/RiskyAdventure/Troubleshooting-Dashboards/blob/main/api-troubleshooter.json\" target=\"_blank\">API troubleshooter dashboard</a></li>\n<li>Navigate to the Manage tab under dashboards</li>\n</ol>\n<p><img src=\"https://dev-media.amazoncloud.cn/8fba3bdde377441893af4175eb96d4c6_image.png\" alt=\"image.png\" /></p>\n<ol start=\"4\">\n<li>From the Manage window, click Import</li>\n</ol>\n<p><img src=\"https://dev-media.amazoncloud.cn/a5926e1b6d6248fabc34c8ab80ddedc4_image.png\" alt=\"image.png\" /></p>\n<ol start=\"5\">\n<li>Then click upload JSON file to import the chart</li>\n</ol>\n<p><img src=\"https://dev-media.amazoncloud.cn/c41dc1de8d714ccc811640a18cd7a3c6_image.png\" alt=\"image.png\" /></p>\n<h3><a id=\"Understanding_the_Problem_29\"></a><strong>Understanding the Problem</strong></h3>\n<p>Let’s say you found an interesting open-source project that you wanted to install in your cluster. That operator deploys a DaemonSet to your cluster that might be using malformed requests, a needlessly high volume of LIST calls, or maybe each of its DaemonSets across all your 1,000 nodes are requesting status of all 50,000 pods on your cluster every minute!</p>\n<p>Does this really happen often? Yes, it does! Let’s take a quick detour on how that happens.</p>\n<h4><a id=\"Understanding_LIST_vs_WATCH_34\"></a><strong>Understanding LIST vs. WATCH</strong></h4>\n<p>Some applications need to understand the state of the objects in your cluster. For example, your machine learning (ML) application wants to know the job status by understanding how many pods are not in the Completed status.</p>\n<p>In Kubernetes, there are well-behaved ways to do this with something called a WATCH, and some not-so-well-behaved ways that list every object on the cluster to find the latest status on those pods.</p>\n<h4><a id=\"A_wellbehaved_WATCH_39\"></a><strong>A well-behaved WATCH</strong></h4>\n<p>Using a WATCH or a single, long-lived connection to receive updates via a push model is the most scalable way to do updates in Kubernetes. To oversimplify, we ask for the full state of the system, then only update the object in a cache when changes are received for that object, periodically running a re-sync to ensure that no updates were missed.</p>\n<p>In the below image we use the <code>apiserver_longrunning_gauge</code> to get an idea of the number of these long-lived connections across both API servers.</p>\n<p><img src=\"https://dev-media.amazoncloud.cn/0264c8ac913c4769b35ad06f4a78ea74_image.png\" alt=\"image.png\" /></p>\n<p>Even with this efficient system, we can still have too much of a good thing. For example, if we use many very small nodes, each using two or more DaemonSets that need to talk to the API server, it is quite easy to dramatically increase the number of WATCH calls on the system unnecessarily. For example, let’s look at the difference between eight xlarge nodes vs. a single 8xlarge. Here we see an 8x increase of WATCH calls on the system!</p>\n<p><img src=\"https://dev-media.amazoncloud.cn/e030f2b736094f98bc50384fb5925d1d_image.png\" alt=\"image.png\" /></p>\n<p>Now these are efficient calls, but what if instead they were the ill-behaved calls we alluded to earlier? Imagine if one of the above DaemonSets on each of the 1,000 nodes is requesting updates on each of the total 50,000 pods in the cluster. We will explore this idea of an unbounded list call in next section.</p>\n<p>A quick word of caution before continuing, the type of consolidation in the above example must be done with great care, and has many other factors to consider. Everything from the delay of the number of threads competing for a limited number of CPUs on the system, Pod churn rate, to the maximum number of volume attachments a node can handle safely. However, our focus will be on the metrics that lead us to actionable steps that can prevent issues from happening—and maybe give us new insight into our designs.</p>\n<p>The WATCH metric is a simple one, but it can be used to track and reduce the number of watches, if that is a problem for you. Here are a few options you could consider to reduce this number:</p>\n<ul>\n<li>Limit the number of ConfigMaps Helm creates to track History</li>\n<li>Use Immutable ConfigMaps and Secrets which do not use a WATCH</li>\n<li>Sensible node sizing and consolidation</li>\n</ul>\n<h3><a id=\"The_unbounded_list_call_61\"></a><strong>The unbounded list call</strong></h3>\n<p>Now for the LIST call we have been talking about. A list call is pulling the full history on our Kubernetes objects each time we need to understand an object’s state, nothing is being saved in a cache this time.</p>\n<p>How impactful is all this? That will vary depending on how many agents are requesting data, how often they are doing so, and how much data they are requesting. Are they asking for everything on the cluster, or just a single namespace? Does that happen every minute, on very node?</p>\n<p>Let’s use an example of a logging agent that is appending Kubernetes metadata on every log sent from a node. This could be an overwhelming amount of data in larger clusters. There are many ways for the agent to get that data via a list call, so let’s look at a few.</p>\n<p>This request is asking for pods from a specific namespace.</p>\n<p><code>/api/v1/namespaces/my-namespace/pods</code></p>\n<p>Next, we request all 50,000 pods on the cluster, but in chunks of 500 pods at a time.</p>\n<p><code>/api/v1/pods?limit=500</code></p>\n<p>The next call is the most disruptive. Fetching all 50,000 pods on the entire cluster at the same time.</p>\n<p><code>/api/v1/pods</code></p>\n<p>This happens quite commonly in the field and can be seen in the logs.</p>\n<h3><a id=\"Stopping_bad_behavior_83\"></a><strong>Stopping bad behavior</strong></h3>\n<p>How can we protect our cluster from such bad behavior? Before Kubernetes 1.20, the API server would protect itself by limiting the number of <em>inflight</em> requests processed per second. Since etcd can only handle so many requests at one time in a performant way, we need to ensure the number of requests is limited to a value per second that keeps etcd reads and writes in a reasonable latency band. Unfortunately, at the time of this writing, there is no dynamic way to do this.</p>\n<p>In the below chart we see a breakdown of read requests, which has a default maximum of 400 inflight request per API server and a default max of 200 concurrent write requests. In a default EKS cluster you will see two API servers for a total of 800 reads and 400 writes. However, caution is advised as these servers can have asymmetric loads on them at different times like right after an upgrade, etc.</p>\n<p><img src=\"https://dev-media.amazoncloud.cn/b00ac542f5ad4e9bbde767ce9823fc87_image.png\" alt=\"image.png\" /></p>\n<p>It turns out that the above was not a perfect scheme. For example, how could we keep this badly behaving new operator we just installed from taking up all the inflight write requests on the API server and potentially delaying important requests such as node keepalive messages?</p>\n<h3><a id=\"API_Priority_and_Fairness_93\"></a><strong>API Priority and Fairness</strong></h3>\n<p>Instead of worrying about how many read/write requests were open per second, what if we treated the capacity as one total number, and each application on the cluster got a fair percentage or share of that total maximum number?</p>\n<p>To do that that effectively, we would need to identify who sent the request to the API server, then give that request a name tag of sorts. With this new name tag, we could then see all these requests are coming from a new agent we will call “Chatty.” Now we can group all of Chatty’s requests into something called a flow, that identifies those requests are coming from the same DaemonSet. This concept now gives us the ability to restrict this bad agent and ensure it does not consume the whole cluster.</p>\n<p>However, not all requests are created equal. The control plane traffic that is needed to keep the cluster operational should be a higher priority than our new operator. This is where the idea of priority levels comes into play.</p>\n<p>What if, by default, we had a several “buckets” or queues for critical, high, and low priority traffic? We do not want the chatty agent flow getting a fair share of traffic in the critical traffic queue. We can however put that traffic in a low priority queue so that flow is competing with perhaps other chatty agents. We then would want to ensure that each priority level had the right number of shares or percentage of the overall maximum the API server can handle to ensure the requests were not too delayed.</p>\n<h4><a id=\"Priority_and_fairness_in_action_102\"></a><strong>Priority and fairness in action</strong></h4>\n<p>Since this is a relatively new feature, many existing dashboards will use the older model of maximum inflight reads and maximum inflight writes. Why this can be problematic?</p>\n<p>What if we were giving high priority name tags to everything in the kube-system namespace, but we then installed that bad agent into that important namespace, or even simply deployed too many applications in that namespace? We could end up having the same problem we were trying to avoid! So best to keep a close eye on such situations.</p>\n<p>I have broken out for you some of the metrics I find most interesting to track these kinds of issues.</p>\n<ul>\n<li>What percentage of a priority group’s shares are used?</li>\n<li>What is the longest time a request waited in a queue?</li>\n<li>Which flow is using the most shares?</li>\n<li>Are there unexpected delays on the system?</li>\n</ul>\n<h5><a id=\"Percent_in_use_115\"></a><strong>Percent in use</strong></h5>\n<p>Here we see the different default priority groups on the cluster and what percentage of the max is used.</p>\n<p><img src=\"https://dev-media.amazoncloud.cn/83e02912203a4c63a994ed1093f67f66_image.png\" alt=\"image.png\" /></p>\n<p><em>New metrics in Kubernetes 1.21</em></p>\n<h5><a id=\"Time_request_was_in_queue_122\"></a><strong>Time request was in queue</strong></h5>\n<p>How long in seconds the request sat in the priority queue before being processed.</p>\n<p><img src=\"https://dev-media.amazoncloud.cn/711e66a43e034b699cac0620b4368650_image.png\" alt=\"image.png\" /></p>\n<h5><a id=\"Top_executed_requests_by_flow_127\"></a><strong>Top executed requests by flow</strong></h5>\n<p>Which flow is taking up the most shares?</p>\n<p><img src=\"https://dev-media.amazoncloud.cn/7c0cac2ea3f447d4b1b66ac6a29cd076_image.png\" alt=\"image.png\" /></p>\n<h5><a id=\"Request_Execution_Time_132\"></a><strong>Request Execution Time</strong></h5>\n<p>Are there any unexpected delays in processing?</p>\n<p><img src=\"https://dev-media.amazoncloud.cn/b775360ac0054b5a88ee58d2daf45858_image.png\" alt=\"image.png\" /></p>\n<h3><a id=\"The_big_picture_137\"></a><strong>The big picture</strong></h3>\n<p>Now that we understand the nature of the things that cause API latency, we can take a step back and look at the big picture. It’s important to remember that our dashboard designs are simply trying to get a quick snapshot if there is a problem we should be investigating. For detailed analysis, we would use ad-hoc queries with PromQL—or better yet, logging queries.</p>\n<p>What are some ideas for the high-level metrics we would want to look at?</p>\n<ul>\n<li>What API call is taking the most time to complete?<br />\nWhat is the call doing? (Listing objects, deleting them, etc.)<br />\nWhat objects is it trying to do that operation on? (Pods, Secrets, ConfigMaps, etc.)</li>\n<li>Is there a latency problem on the API server itself?<br />\nIs there a delay in one of my priority queues causing a backup in requests?</li>\n<li>Does it just look like API server is slow because the etcd server is experiencing latency?</li>\n</ul>\n<h4><a id=\"Slowest_API_call_150\"></a><strong>Slowest API call</strong></h4>\n<p>In the below chart we are looking for the API calls that took the most time to complete for that period. In this case we see a custom resource definition (CRD) is calling a LIST function that is the most latent call during the 05:40 time frame. Armed with this data we can use CloudWatch Insights to pull LIST requests from the audit log in that timeframe to see which application this might be.</p>\n<p><img src=\"https://dev-media.amazoncloud.cn/0454b0e1835347e8980d1f3244ec8313_image.png\" alt=\"image.png\" /></p>\n<h5><a id=\"API_Request_Duration_155\"></a><strong>API Request Duration</strong></h5>\n<p>This API latency chart helps us to understand if any requests are approaching the timeout value of one minute. I like the histogram over time format below as I can see outliers in the data that a line graph would hide.</p>\n<p><img src=\"https://dev-media.amazoncloud.cn/afaf731005bc468295dbfe9a3320847c_image.png\" alt=\"image.png\" /></p>\n<p>Simply hovering over a bucket shows us the exact number of calls that took around 25 milliseconds.</p>\n<p><img src=\"https://dev-media.amazoncloud.cn/5c9d5c21bf7b45fbb75b4c9f8db12896_image.png\" alt=\"image.png\" /></p>\n<p>This concept is important when we are working with other systems that cache requests. Cache requests will be fast; we do not want to merge those request latencies with slower requests. Here we can see two distinct bands of latency, requests that have been cached, and those that have not.</p>\n<p><img src=\"https://dev-media.amazoncloud.cn/9cc9c6c06a304aa28ea1c09ac8ecd03d_image.png\" alt=\"image.png\" /></p>\n<h5><a id=\"etcd_Request_Duration_169\"></a><strong>etcd Request Duration</strong></h5>\n<p>etcd latency is one of the most important factors in Kubernetes performance. Amazon EKS allows you see this performance from the API server’s perspective by looking at the <code>request_duration_seconds_bucket</code> metric.</p>\n<p><img src=\"https://dev-media.amazoncloud.cn/5781530ba88f4f91b9ac48ccfca87fab_image.png\" alt=\"image.png\" /></p>\n<p>We can now start to put the things we learned together by seeing if certain events are correlated. In the below chart we see API server latency, but we also see much of this latency is coming from the etcd server. Being able to quickly move to the right problem area with just a glance is what makes a dashboard powerful.</p>\n<p><img src=\"https://dev-media.amazoncloud.cn/24a805bb937c4773905c7fe2d4801680_image.png\" alt=\"image.png\" /></p>\n<h3><a id=\"Conclusion_178\"></a><strong>Conclusion</strong></h3>\n<p>We have covered quite a bit of ground in a short period of time. There is, of course, much more to explore and discuss, but I hope this gives you a firm footing to begin your own journey of creating dashboards with information you find important. If that all sounds like a bit much right now, I would encourage you just to download the dashboard I have put together for you <a href=\"https://github.com/RiskyAdventure/Troubleshooting-Dashboards/blob/main/api-troubleshooter.json\" target=\"_blank\">here</a>.</p>\n<p>Are you a Kubernetes monitoring enthusiast? If so, you can check out some of <a href=\"https://github.com/RiskyAdventure/Troubleshooting-Dashboards\" target=\"_blank\">my other dashboards</a>. If you have strong opinions on what is important to monitor in production or have good tips and tricks you would like to share, I would love to hear from you! You can reach me at <a href=\"shancor@amazon.com\" target=\"_blank\">shancor@amazon.com</a>.</p>\n<p><img src=\"https://dev-media.amazoncloud.cn/48dc8b50444f4b9291e57f8c0a83f440_image.png\" alt=\"image.png\" /></p>\n<p><strong>Shane Corbett</strong></p>\n<p>Shane Corbett is a Senior Containers Specialist at AWS focused on helping customers with the finer points of Kubernetes large scale design and performance. When not pushing Kubernetes to extremes you will find Shane pursuing his lifelong obsession of exploring the edge of the extreme sports world.</p>\n"}
目录
亚马逊云科技解决方案 基于行业客户应用场景及技术领域的解决方案
联系亚马逊云科技专家
亚马逊云科技解决方案
基于行业客户应用场景及技术领域的解决方案
联系专家
0
目录
关闭
contact-us