Cost monitoring - Amazon EKS
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Cost monitoring

Important

Amazon Billing split cost allocation data for Amazon EKS is not available in China Regions.

Cost monitoring is an essential aspect of managing your Kubernetes clusters on Amazon EKS. By gaining visibility into your cluster costs, you can optimize resource utilization, set budgets, and make data-driven decisions about your deployments. Amazon EKS provides two cost monitoring solutions, each with its own unique advantages, to help you track and allocate your costs effectively:

Amazon Billing split cost allocation data for Amazon EKS — This native feature integrates seamlessly with the Amazon Billing Console, allowing you to analyze and allocate costs using the same familiar interface and workflows you use for other Amazon services. With split cost allocation, you can gain insights into your Kubernetes costs directly alongside your other Amazon spend, making it easier to optimize costs holistically across your Amazon environment. You can also leverage existing Amazon Billing features like Cost Categories and Cost Anomaly Detection to further enhance your cost management capabilities. For more information, see Understanding split cost allocation data in the Amazon Billing User Guide.

Kubecost — Amazon EKS supports Kubecost, an open source cost monitoring tool optimized for Amazon. Kubecost offers a feature-rich, Kubernetes-native approach to cost monitoring, providing granular cost breakdowns by Kubernetes resources, cost optimization recommendations, and out-of-the-box dashboards and reports. As an open source tool, Kubecost benefits from a vibrant community actively contributing to its development and offering support through various channels. Kubecost also retreives accurate pricing data by integrating with the Amazon Cost and Usage Report, ensuring you get a precise view of your Amazon EKS costs. Learn how to Install Kubecost.

Amazon Billing — Split Cost Allocation

Cost monitoring using Amazon split cost allocation data for Amazon EKS

You can use Amazon split cost allocation data for Amazon EKS to get granular cost visibility for your Amazon EKS clusters. This enables you to analyze, optimize, and chargeback cost and usage for your Kubernetes applications. You allocate application costs to individual business units and teams based on Amazon EC2 CPU and memory resources consumed by your Kubernetes application. Split cost allocation data for Amazon EKS gives visibility into cost per Pod, and enables you to aggregate the cost data per Pod using namespace, cluster, and other Kubernetes primitives. The following are examples of Kubernetes primitives that you can use to analyze Amazon EKS cost allocation data.

  • Cluster name

  • Deployment

  • Namespace

  • Node

  • Workload Name

  • Workload Type

For more information about using split cost allocation data, see Understanding split cost allocation data in the Amazon Billing User Guide.

Set up Cost and Usage Reports

You can turn on Split Cost Allocation Data for EKS in the Cost Management Console, Amazon Command Line Interface, or the Amazon SDKs.

Use the following for Split Cost Allocation Data:

  1. Opt in to Split Cost Allocation Data. For more information, see Enabling split cost allocation data in the Amazon Cost and Usage Report User Guide.

  2. Include the data in a new or existing report.

  3. View the report. You can use the Billing and Cost Management console or view the report files in Amazon Simple Storage Service.

Kubecost

Amazon EKS supports Kubecost, which you can use to monitor your costs broken down by Kubernetes resources including Pods, nodes, namespaces, and labels. As a Kubernetes platform administrator and finance leader, you can use Kubecost to visualize a breakdown of Amazon EKS charges, allocate costs, and charge back organizational units such as application teams. You can provide your internal teams and business units with transparent and accurate cost data based on their actual Amazon bill. Moreover, you can also get customized recommendations for cost optimization based on their infrastructure environment and usage patterns within their clusters. For more information about Kubecost, see the Kubecost documentation.

Amazon EKS provides an Amazon optimized bundle of Kubecost for cluster cost visibility. You can use your existing Amazon support agreements to obtain support.

Prerequisites
  • An existing Amazon EKS cluster. To deploy one, see Getting started with Amazon EKS. The cluster must have Amazon EC2 nodes because you can't run Kubecost on Fargate nodes.

  • The kubectl command line tool is installed on your device or Amazon CloudShell. The version can be the same as or up to one minor version earlier or later than the Kubernetes version of your cluster. For example, if your cluster version is 1.28, you can use kubectl version 1.27, 1.28, or 1.29 with it. To install or upgrade kubectl, see Installing or updating kubectl.

  • Helm version 3.9.0 or later configured on your device or Amazon CloudShell. To install or update Helm, see Using Helm with Amazon EKS.

  • If your cluster is version 1.23 or later, you must have the Amazon EBS CSI driver installed on your cluster.

To install Kubecost
  1. Determine the version of Kubecost to install. You can see the available versions at kubecost/cost-analyzer in the Amazon ECR Public Gallery. For more information about the compability of Kubecost versions and Amazon EKS, see the Environment Requirements in the Kubecost documentation.

  2. Install Kubecost with the following command. Replace kubecost-version with the value retreived from ECR, such as 1.108.1.

    helm upgrade -i kubecost oci://public.ecr.aws/kubecost/cost-analyzer --version kubecost-version \ --namespace kubecost --create-namespace \ -f https://raw.githubusercontent.com/kubecost/cost-analyzer-helm-chart/develop/cost-analyzer/values-eks-cost-monitoring.yaml

    Kubecost releases new versions regularly. You can update your version using helm upgrade. By default, the installation includes a local Prometheus server and kube-state-metrics. You can customize your deployment to use Amazon Managed Service for Prometheus by following the documentation in Integrating with Amazon EKS cost monitoring. For a list of all other settings that you can configure, see the sample configuration file on GitHub.

  3. Make sure the required Pods are running.

    kubectl get pods -n kubecost

    An example output is as follows.

    NAME READY STATUS RESTARTS AGE kubecost-cost-analyzer-b9788c99f-5vj5b 2/2 Running 0 3h27m kubecost-kube-state-metrics-99bb8c55b-bn2br 1/1 Running 0 3h27m kubecost-prometheus-server-7d9967bfc8-9c8p7 2/2 Running 0 3h27m
  4. On your device, enable port-forwarding to expose the Kubecost dashboard.

    kubectl port-forward --namespace kubecost deployment/kubecost-cost-analyzer 9090

    Alternatively, you can use the Amazon Load Balancer Controller to expose Kubecost and use Amazon Cognito for authentication, authorization, and user management. For more information, see How to use Application Load Balancer and Amazon Cognito to authenticate users for your Kubernetes web apps.

  5. On the same device that you completed the previous step on, open a web browser and enter the following address.

    http://localhost:9090

    You see the Kubecost Overview page in your browser. It might take 5–10 minutes for Kubecost to gather metrics. You can see your Amazon EKS spend, including cumulative cluster costs, associated Kubernetes asset costs, and monthly aggregated spend.

    
                        Kubecost dashboard
  6. To track costs at a cluster level, tag your Amazon EKS resources for billing. For more information, see Tagging your resources for billing.

You can also view the following information by selecting it in the left pane of the dashboard:
  • Cost allocation – View monthly Amazon EKS costs and cumulative costs for each of your namespaces and other dimensions over the past seven days. This is helpful for understanding which parts of your application are contributing to Amazon EKS spend.

  • Assets – View the costs of the Amazon infrastructure assets that are associated with your Amazon EKS resources.

Additional features
  • Export cost metrics – Amazon EKS optimized cost monitoring is deployed with Kubecost and Prometheus, which is an open-source monitoring system and time series database. Kubecost reads metric from Prometheus and then performs cost allocation calculations and writes the metrics back to Prometheus. The Kubecost front-end reads metrics from Prometheus and shows them on the Kubecost user interface. The architecture is illustrated in the following diagram.

    
                        Kubecost architecture

    With Prometheus pre-installed, you can write queries to ingest Kubecost data into your current business intelligence system for further analysis. You can also use it as a data source for your current Grafana dashboard to display Amazon EKS cluster costs that your internal teams are familiar with. To learn more about how to write Prometheus queries, see the Prometheus Configuration readme file on GitHub or use the example Grafana JSON models in the Kubecost Github repository as references.

  • Amazon Cost and Usage Report integration – To perform cost allocation calculations for your Amazon EKS cluster, Kubecost retrieves the public pricing information of Amazon Web Services and Amazon resources from the Amazon Price List API. You can also integrate Kubecost with Amazon Cost and Usage Report to enhance the accuracy of the pricing information specific to your Amazon Web Services account. This information includes enterprise discount programs, reserved instance usage, savings plans, and spot usage. To learn more about how the Amazon Cost and Usage Report integration works, see Amazon Cloud Billing Integration in the Kubecost documentation.

Remove Kubecost

You can remove Kubecost from your cluster with the following commands.

helm uninstall kubecost --namespace kubecost kubectl delete ns kubecost

Frequently asked questions

See the following common questions and answers about using Kubecost with Amazon EKS.

Amazon and Kubecost collaborated to offer a customized version of Kubecost. This version includes a subset of commercial features at no additional charge. See the following table for features that are included with in the custom bundle of Kubecost.

Feature Kubecost free tier Amazon EKS optimized Kubecost custom bundle Kubecost Enterprise
Deployment User hosted User hosted User hosted or Kubecost hosted (SaaS)
Number of clusters supported Unlimited Unlimited Unlimited
Databases supported Local Prometheus Local Prometheus or Amazon Managed Service for Prometheus Prometheus, Amazon Managed Service for Prometheus, Cortex, or Thanos
Database retention support 15 days Unlimited historical data Unlimited historical data
Kubecost API retention (ETL) 15 days 15 days Unlimited historical data
Cluster cost visibility Single clusters Unified multi-cluster Unified multi-cluster
Hybrid cloud visibility - Amazon EKS and Amazon EKS Anywhere clusters Multi-cloud and hybrid-cloud support
Alerts and recurring reports - Efficiency alerts, budget alerts, spend change alerts, and more supported Efficiency alerts, budget alerts, spend change alerts, and more supported
Saved reports - Reports using 15 days data Reports using unlimited historical data
Cloud billing integration Required for each individual cluster Custom pricing support for Amazon (including multiple clusters and multiple accounts) Custom pricing support for Amazon (including multiple clusters and multiple accounts)
Savings recommendations Single cluster insights Single cluster insights Multi-cluster insights
Governance: Audits - - Audit historical cost events
Single sign-on (SSO) support - Amazon Cognito supported Okta, Auth0, PingID, KeyCloak
Role-based access control (RBAC) with SAML 2.0 - - Okta, Auth0, PingID, Keycloak
Enterprise training and onboarding - - Full-service training and FinOps onboarding
What is the Kubecost API retention (ETL) feature?

The Kubecost ETL feature aggregates and organizes metrics to surface cost visibility at various levels of granularity (such as namespace-level, pod-level, and deployment-level). For the custom Kubecost bundle, customers get data and insights from metrics for the last 15 days.

What is the alerts and recurring reports feature? What alerts and reports does it include?

Kubecost alerts allow teams to receive updates on real-time Kubernetes spend as well as cloud spend. Recurring reports enable teams to receive customized views of historical Kubernetes and cloud spend. Both are configurable using the Kubecost UI or Helm values. They support email, Slack, and Microsoft Teams.

What do saved reports include?

Kubecost saved reports are predefined views of cost and efficiency metrics. They include cost by cluster, namespace, label, and more.

What is cloud billing integration?

Integration with Amazon billing APIs allows Kubecost to display out-of-cluster costs (such as Amazon S3). Additionally, it allows Kubecost to reconcile Kubecost's in-cluster predictions with actual billing data to account for spot usage, savings plans, and enterprise discounts.

What do savings recommendations include?

Kubecost provides insights and automation to help users optimize their Kubernetes infrastructure and spend.

No. You can use this version of Kubecost at no additional charge. If you want additional Kubecost capabilities that aren't included in this bundle, you can buy an enterprise license of Kubecost through the Amazon Web Services Marketplace, or from Kubecost directly.

Yes. You can open a support case with the Amazon Web Services Support team at Contact Amazon.

No.

Yes. You can configure Kubecost to ingest data from Amazon Cost and Usage Report to get accurate cost visibility, including discounts, Spot pricing, reserved instance pricing, and others. For more information, see Amazon Cloud Billing Integration in the Kubecost documentation.

No. This version is only compatible with Amazon EKS clusters.

Kubecost provides best effort to show cluster cost visibility for Amazon EKS on Fargate, but with lower accuracy than with Amazon EKS on Amazon EC2. This is primarily due to the difference in how you're billed for your usage. With Amazon EKS on Fargate, you're billed for consumed resources. With Amazon EKS on Amazon EC2 nodes, you're billed for provisioned resources. Kubecost calculates the cost of an Amazon EC2 node based on the node specification, which includes CPU, RAM, and ephemeral storage. With Fargate, costs are calculated based on the requested resources for the Fargate Pods.

You can upgrade your Kubecost version using standard Helm upgrade procedures. The latest versions are in the Amazon ECR Public Gallery.

Yes. Kubectl-cost is an open source tool by Kubecost (Apache 2.0 License) that provides CLI access to Kubernetes cost allocation metrics. To install kubectl-cost, see Installation on GitHub.

Kubecost provides a web dashboard that you can access through kubectl port forwarding, an ingress, or a load balancer. You can also use the Amazon Load Balancer Controller to expose Kubecost and use Amazon Cognito for authentication, authorization, and user management. For more information, see How to use Application Load Balancer and Amazon Cognito to authenticate users for your Kubernetes web apps on the Amazon blog.

No.