{"id":13563574,"url":"https://github.com/robusta-dev/krr","last_synced_at":"2025-05-13T21:12:08.541Z","repository":{"id":154118486,"uuid":"603117527","full_name":"robusta-dev/krr","owner":"robusta-dev","description":"Prometheus-based Kubernetes Resource Recommendations","archived":false,"fork":false,"pushed_at":"2025-04-28T15:18:48.000Z","size":5490,"stargazers_count":3681,"open_issues_count":94,"forks_count":212,"subscribers_count":30,"default_branch":"main","last_synced_at":"2025-05-08T02:44:01.403Z","etag":null,"topics":["cost-control","cost-saving","finops","kubectl","kubernetes","metrics","monitoring","prometheus","rightsizing","vpa"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/robusta-dev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-02-17T16:48:52.000Z","updated_at":"2025-05-07T20:27:16.000Z","dependencies_parsed_at":"2024-04-09T08:30:43.418Z","dependency_job_id":"ae1475e8-d293-43d2-ab7a-5750e9b6929d","html_url":"https://github.com/robusta-dev/krr","commit_stats":{"total_commits":507,"total_committers":42,"mean_commits":"12.071428571428571","dds":0.5305719921104537,"last_synced_commit":"1515b3d96f50c2b116236739fd157af893a69f2f"},"previous_names":[],"tags_count":76,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robusta-dev%2Fkrr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robusta-dev%2Fkrr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robusta-dev%2Fkrr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robusta-dev%2Fkrr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/robusta-dev","download_url":"https://codeload.github.com/robusta-dev/krr/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254029008,"owners_count":22002284,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cost-control","cost-saving","finops","kubectl","kubernetes","metrics","monitoring","prometheus","rightsizing","vpa"],"created_at":"2024-08-01T13:01:20.825Z","updated_at":"2025-05-13T21:12:03.530Z","avatar_url":"https://github.com/robusta-dev.png","language":"Python","funding_links":[],"categories":["Python","monitoring","Repositories"],"sub_categories":[],"readme":"\u003c!-- @format --\u003e\n\n\u003ca name=\"readme-top\"\u003e\u003c/a\u003e\n\n\u003c!-- [![Contributors][contributors-shield]][contributors-url]\n[![Forks][forks-shield]][forks-url]\n[![Stargazers][stars-shield]][stars-url]\n[![Issues][issues-shield]][issues-url]\n[![MIT License][license-shield]][license-url]\n[![LinkedIn][linkedin-shield]][linkedin-url] --\u003e\n\n![Product Name Screen Shot][product-screenshot]\n\n\u003cdiv align=\"center\"\u003e\n  \u003ch1 align=\"center\"\u003eKubernetes Resource Recommendations Based on Historical Data\u003c/h1\u003e\n  \u003ch2 align=\"center\"\u003eGet recommendations based on your existing data in Prometheus/Coralogix/Thanos/Mimir and more!\u003c/h2\u003e\n  \u003cp align=\"center\"\u003e    \n    \u003ca href=\"#installation\"\u003e\u003cstrong\u003eInstallation\u003c/strong\u003e\u003c/a\u003e\n    .\n    \u003ca href=\"#how-krr-works\"\u003e\u003cstrong\u003eHow KRR works\u003c/strong\u003e\u003c/a\u003e\n    .\n    \u003ca href=\"#slack-integration\"\u003e\u003cstrong\u003eSlack Integration\u003c/strong\u003e\u003c/a\u003e\n    .\n    \u003ca href=\"#free-krr-ui-on-robusta-saas\"\u003e\u003cstrong\u003eFree KRR UI\u003c/strong\u003e\u003c/a\u003e\n    \u003cbr /\u003e\n    \u003ca href=\"#usage\"\u003eUsage\u003c/a\u003e\n    ·\n    \u003ca href=\"https://github.com/robusta-dev/krr/issues\"\u003eReport Bug\u003c/a\u003e\n    ·\n    \u003ca href=\"https://github.com/robusta-dev/krr/issues\"\u003eRequest Feature\u003c/a\u003e\n    ·\n    \u003ca href=\"#support\"\u003eSupport\u003c/a\u003e\n    \u003cbr /\u003e Like KRR? Please ⭐ this repository to show your support!\n  \u003c/p\u003e\n\u003c/div\u003e\n\u003c!-- TABLE OF CONTENTS --\u003e\n\u003c!-- \u003cdetails\u003e\n  \u003csummary\u003eTable of Contents\u003c/summary\u003e\n  \u003col\u003e\n    \u003cli\u003e\n      \u003ca href=\"#about-the-project\"\u003eAbout The Project\u003c/a\u003e\n      \u003cul\u003e\n        \u003cli\u003e\u003ca href=\"#built-with\"\u003eBuilt With\u003c/a\u003e\u003c/li\u003e\n      \u003c/ul\u003e\n    \u003c/li\u003e\n    \u003cli\u003e\n      \u003ca href=\"#getting-started\"\u003eGetting Started\u003c/a\u003e\n      \u003cul\u003e\n        \u003cli\u003e\u003ca href=\"#prerequisites\"\u003ePrerequisites\u003c/a\u003e\u003c/li\u003e\n        \u003cli\u003e\u003ca href=\"#installation\"\u003eInstallation\u003c/a\u003e\u003c/li\u003e\n      \u003c/ul\u003e\n    \u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#usage\"\u003eUsage\u003c/a\u003e\u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#roadmap\"\u003eRoadmap\u003c/a\u003e\u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#contributing\"\u003eContributing\u003c/a\u003e\u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#license\"\u003eLicense\u003c/a\u003e\u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#contact\"\u003eContact\u003c/a\u003e\u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#acknowledgments\"\u003eAcknowledgments\u003c/a\u003e\u003c/li\u003e\n  \u003c/ol\u003e\n\u003c/details\u003e --\u003e\n\u003c!-- ABOUT THE PROJECT --\u003e\n\n## About The Project\n\nRobusta KRR (Kubernetes Resource Recommender) is a CLI tool for **optimizing resource allocation** in Kubernetes clusters. It gathers pod usage data from Prometheus and **recommends requests and limits** for CPU and memory. This **reduces costs and improves performance**.\n\n### Data Integrations\n\n[![Used to send data to KRR](./images/krr-datasources.svg)](#data-source-integrations)\n\n\n_View Instructions for: [Prometheus](#prometheus-victoria-metrics-and-thanos-auto-discovery), [Thanos](#prometheus-victoria-metrics-and-thanos-auto-discovery), [Victoria Metrics](#prometheus-victoria-metrics-and-thanos-auto-discovery), [Google Managed Prometheus](./docs/google-cloud-managed-service-for-prometheus.md), [Amazon Managed Prometheus](#amazon-managed-prometheus), [Azure Managed Prometheus](#azure-managed-prometheus), [Coralogix](#coralogix-managed-prometheus),[Grafana Cloud](#grafana-cloud-managed-prometheus) and [Grafana Mimir](#grafana-mimir-auto-discovery)_\n\n\n\n### Reporting Integrations\n\n[![Used to receive information from KRR](./images/krr-other-integrations.svg)](#integrations)\n\n_View instructions for: [Seeing recommendations in a UI](#free-ui-for-krr-recommendations), [Sending recommendations to Slack](#slack-notification), [Setting up KRR as a k9s plugin](#k9s-plugin)_\n\n### Features\n\n- **No Agent Required**: Run a CLI tool on your local machine for immediate results. (Or run in-cluster for weekly [Slack reports](#slack-integration).)\n- **Prometheus Integration**: Get recommendations based on the data you already have\n- **Explainability**: [Understand how recommendations were calculated with explanation graphs](#free-krr-ui-on-robusta-saas)\n- **Extensible Strategies**: Easily create and use your own strategies for calculating resource recommendations.\n- **Free SaaS Platform**: See why KRR recommends what it does, by using the [free Robusta SaaS platform](https://platform.robusta.dev/signup/?benefits=krr\u0026utm_source=github\u0026utm_medium=krr-readme\u0026utm_content=features-free-saas-platform).\n- **Future Support**: Upcoming versions will support custom resources (e.g. GPUs) and custom metrics.\n\n### How Much Can I Expect to Save with KRR?\n\nAccording to a recent [Sysdig study](https://sysdig.com/blog/millions-wasted-kubernetes/), on average, Kubernetes clusters have:\n\n- 69% unused CPU\n- 18% unused memory\n\nBy right-sizing your containers with KRR, you can save an average of 69% on cloud costs.\n\nRead more about [how KRR works](#how-krr-works)\n\n## Difference with Kubernetes VPA\n\n| Feature 🛠️                  | Robusta KRR 🚀                                                                                             | Kubernetes VPA 🌐                                           |\n| --------------------------- | ---------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------- |\n| Resource Recommendations 💡 | ✅ CPU/Memory requests and limits                                                                          | ✅ CPU/Memory requests and limits                           |\n| Installation Location 🌍    | ✅ Not required to be installed inside the cluster, can be used on your own device, connected to a cluster | ❌ Must be installed inside the cluster                     |\n| Workload Configuration 🔧   | ✅ No need to configure a VPA object for each workload                                                     | ❌ Requires VPA object configuration for each workload      |\n| Immediate Results ⚡         | ✅ Gets results immediately (given Prometheus is running)                                                  | ❌ Requires time to gather data and provide recommendations |\n| Reporting 📊                | ✅ Json, CSV, Markdown, [Web UI](#free-ui-for-krr-recommendations), and more!                              | ❌ Not supported                                            |\n| Extensibility 🔧            | ✅ Add your own strategies with few lines of Python                                                        | :warning: Limited extensibility                             |\n| Explainability 📖           | ✅ [See graphs explaining the recommendations](#free-krr-ui-on-robusta-saas)                               | ❌ Not supported                                            |\n| Custom Metrics 📏           | 🔄 Support in future versions                                                                              | ❌ Not supported                                            |\n| Custom Resources 🎛️         | 🔄 Support in future versions (e.g., GPU)                                                                  | ❌ Not supported                                            |\n| Autoscaling 🔀              | 🔄 Support in future versions                                                                              | ✅ Automatic application of recommendations                 |\n| Default History 🕒          | 14 days                                                                                                    | 8 days                                                     |\n| Supports HPA 🔥             | ✅ Enable using `--allow-hpa` flag                                                                         | ❌ Not supported                                            |\n\n\n\u003c!-- GETTING STARTED --\u003e\n\n## Installation\n\n### Requirements\n\nKRR requires Prometheus 2.26+, [kube-state-metrics](https://github.com/kubernetes/kube-state-metrics) \u0026 [cAdvisor](https://github.com/google/cadvisor).\n\n\u003cdetails\u003e\n  \u003csummary\u003eWhich metrics does KRR need?\u003c/summary\u003e\nNo setup is required if you use kube-prometheus-stack or \u003ca href=\"https://docs.robusta.dev/master/configuration/alertmanager-integration/embedded-prometheus.html\"\u003eRobusta's Embedded Prometheus\u003c/a\u003e.\n\nIf you have a different setup, make sure the following metrics exist:\n\n- `container_cpu_usage_seconds_total`\n- `container_memory_working_set_bytes`\n- `kube_replicaset_owner`\n- `kube_pod_owner`\n- `kube_pod_status_phase`\n\n_Note: If one of last three metrics is absent KRR will still work, but it will only consider currently-running pods when calculating recommendations. Historic pods that no longer exist in the cluster will not be taken into consideration._\n\u003c/details\u003e\n\n\n### Installation Methods\n\n\u003cdetails\u003e\n  \u003csummary\u003eBrew (Mac/Linux)\u003c/summary\u003e\n\n1. Add our tap:\n\n```sh\nbrew tap robusta-dev/homebrew-krr\n```\n\n2. Install KRR:\n\n```sh\nbrew install krr\n```\n\n3. Check that installation was successful:\n\n```sh\nkrr --help\n```\n\n4. Run KRR (first launch might take a little longer):\n\n```sh\nkrr simple\n```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003eWindows\u003c/summary\u003e\n\nYou can install using brew (see above) on [WSL2](https://docs.brew.sh/Homebrew-on-Linux), or install from source (see below).\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003eDocker image, binaries, and airgapped installation (offline environments)\u003c/summary\u003e\n\nYou can download pre-built binaries from \u003ca href=\"https://github.com/robusta-dev/krr/releases\"\u003eReleases\u003c/a\u003e or use the prebuilt Docker container. For example, the container for version 1.8.3 is:\n\n```\nus-central1-docker.pkg.dev/genuine-flight-317411/devel/krr:v1.8.3\n```\n\nWe do **not** recommend installing KRR from source in airgapped environments due to the headache of installing Python dependencies. Use one of the above methods instead and contact us (via Slack, GitHub issues, or email) if you need assistance.\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003eIn-Cluster\u003c/summary\u003e\n\nApart from running KRR as a CLI tool you can also run KRR inside your cluster. We suggest installing KRR via the \u003ca href=\"https://platform.robusta.dev/signup/?benefits=krr\u0026utm_source=github\u0026utm_medium=krr-readme\u0026utm_content=in-cluster-robusta-platform\"\u003eRobusta Platform\u003c/a\u003e\n. It gives you a \u003ca href=\"https://platform.robusta.dev/signup/?benefits=krr\u0026utm_source=github\u0026utm_medium=krr-readme\u0026utm_content=in-cluster-free-ui\"\u003efree UI\u003c/a\u003e with some features like the following\n* View application usage history graphs on which recommendations are based.\n* Get application, namespace and cluster level recommendations.\n* YAML configuration to apply the suggested recommendation and more\n\n\u003cimg src=\"./images/ui_screenshot_new.png\"\u003e\n\n\u003cimg src=\"./images/ui_recommendation.png\"\u003e\n\nYou can also run KRR in-cluster as a Kubernetes Job, if you don't want to view results easily in a \u003ca href=\"https://platform.robusta.dev/signup/?benefits=krr\u0026utm_source=github\u0026utm_medium=krr-readme\u0026utm_content=in-cluster-ui\"\u003eUI\u003c/a\u003e. \n\n```\nkubectl apply -f https://raw.githubusercontent.com/robusta-dev/krr/refs/heads/main/docs/krr-in-cluster/krr-in-cluster-job.yaml\n\n```\n\u003c/details\u003e\n\n\n\u003cdetails\u003e\n  \u003csummary\u003eFrom Source\u003c/summary\u003e\n\n1. Make sure you have [Python 3.9](https://www.python.org/downloads/) (or greater) installed\n2. Clone the repo:\n\n```sh\ngit clone https://github.com/robusta-dev/krr\n```\n\n3. Navigate to the project root directory (`cd ./krr`)\n4. Install requirements:\n\n```sh\npip install -r requirements.txt\n```\n\n5. Run the tool:\n\n```sh\npython krr.py --help\n```\n\nNotice that using source code requires you to run as a python script, when installing with brew allows to run `krr`.\nAll above examples show running command as `krr ...`, replace it with `python krr.py ...` if you are using a manual installation.\n\n\u003c/details\u003e\n\n### Additional Options\n\n- [View KRR Reports in a Web UI](#free-ui-for-krr-recommendations)\n- [Receive KRR Reports Weekly in Slack](#slack-notification)\n\n### Environment-Specific Instructions\nSetup KRR for...\n- [Google Cloud Managed Prometheus](./docs/google-cloud-managed-service-for-prometheus.md)\n- [Azure Managed Prometheus](#azure-managed-prometheus)\n- [Amazon Managed Prometheus](#amazon-managed-prometheus)\n- [Coralogix Managed Prometheus](#coralogix-managed-prometheus)\n- [Grafana Cloud Managed Prometheus](#grafana-cloud-managed-prometheus)\n- [Grafana Mimir](#grafana-mimir-auto-discovery)\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\n**Trusting custom Certificate Authority (CA) certificate:**\n\nIf your llm provider url uses a certificate from a custom CA, in order to trust it, base-64 encode the certificate, and store it in an environment variable named ``CERTIFICATE``\n\n## Free KRR UI on Robusta SaaS\n\nWe highly recommend using the [free Robusta SaaS platform](https://platform.robusta.dev/signup/?benefits=krr\u0026utm_source=github\u0026utm_medium=krr-readme\u0026utm_content=free-krr-ui-robusta-saas-platform). You can:\n\n- Understand individual app recommendations with app usage history\n- Sort and filter recommendations by namespace, priority, and more\n- Give devs a YAML snippet to fix the problems KRR finds\n- Analyze impact using KRR scan history\n\n  \u003ca href=\"https://www.loom.com/share/49ea188f67c545f0ae98508b448d1a8b\"\u003e\n      \u003cimg src=\"https://cdn.loom.com/sessions/thumbnails/49ea188f67c545f0ae98508b448d1a8b-with-play.gif\"\u003e\n  \u003c/a\u003e\n\n\u003c!-- USAGE EXAMPLES --\u003e\n\n\n## Usage\n\n\u003cdetails\u003e\n  \u003csummary\u003eBasic usage\u003c/summary\u003e\n\n```sh\nkrr simple\n```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003eTweak the recommendation algorithm (strategy)\u003c/summary\u003e\n\nMost helpful flags:\n\n- `--cpu-min` Sets the minimum recommended cpu value in millicores\n- `--mem-min` Sets the minimum recommended memory value in MB\n- `--history_duration` The duration of the Prometheus history data to use (in hours)\n\nMore specific information on Strategy Settings can be found using\n\n```sh\nkrr simple --help\n```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003eGiving an Explicit Prometheus URL\u003c/summary\u003e\n\nIf your Prometheus is not auto-connecting, you can use `kubectl port-forward` for manually forwarding Prometheus.\n\nFor example, if you have a Prometheus Pod called `kube-prometheus-st-prometheus-0`, then run this command to port-forward it:\n\n```sh\nkubectl port-forward pod/kube-prometheus-st-prometheus-0 9090\n```\n\nThen, open another terminal and run krr in it, giving an explicit Prometheus url:\n\n```sh\nkrr simple -p http://127.0.0.1:9090\n```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003eRun on specific namespaces\u003c/summary\u003e\n\nList as many namespaces as you want with `-n` (in this case, `default` and `ingress-nginx`)\n\n```sh\nkrr simple -n default -n ingress-nginx\n```\n\nThe -n flag also supports regex matches like -n kube-.*. To use regexes, you must have permissions to list namespaces in the target cluster.\n\n```sh\nkrr simple -n default -n 'ingress-.*'\n```\n\nSee [example ServiceAccount and RBAC permissions](./tests/single_namespace_permissions.yaml)\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003eRun on workloads filtered by label\u003c/summary\u003e\n\nUse a \u003ca href=\"https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#api\"\u003elabel selector\u003c/a\u003e\n\n```sh\npython krr.py simple --selector 'app.kubernetes.io/instance in (robusta, ingress-nginx)'\n```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003eOverride the kubectl context\u003c/summary\u003e\n\nBy default krr will run in the current context. If you want to run it in a different context:\n\n```sh\nkrr simple -c my-cluster-1 -c my-cluster-2\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003eOutput formats for reporting (JSON, YAML, CSV, and more)\u003c/summary\u003e\n\nCurrently KRR ships with a few formatters to represent the scan data:\n\n- `table` - a pretty CLI table used by default, powered by [Rich](https://github.com/Textualize/rich) library\n- `json`\n- `yaml`\n- `pprint` - data representation from python's pprint library\n- `csv` - export data to a csv file in the current directory\n- `csv-raw` - csv with raw data for calculation\n- `html`\n\nTo run a strategy with a selected formatter, add a `-f` flag. Usually this should be combined with `--fileoutput \u003cfilename\u003e` to write clean output to file without logs:\n\n```sh\nkrr simple -f json --fileoutput krr-report.json\n```\n\nIf you prefer, you can also use `--logtostderr` to get clean formatted output in one file and error logs in another:\n\n```sh\nkrr simple --logtostderr -f json \u003e result.json 2\u003e logs-and-errors.log\n```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003eCentralized Prometheus (multi-cluster)\u003c/summary\u003e\n  \u003cp \u003e\u003ca href=\"#scanning-with-a-centralized-prometheus\"\u003eSee below on filtering output from a centralized prometheus, so it matches only one cluster\u003c/a\u003e\u003c/p\u003e\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003ePrometheus Authentication\u003c/summary\u003e\n\nKRR supports all known authentication schemes for Prometheus, VictoriaMetrics, Coralogix, and other Prometheus compatible metric stores.\n\nRefer to `krr simple --help`, and look at the flags `--prometheus-url`, `--prometheus-auth-header`, `--prometheus-headers` `--prometheus-ssl-enabled`, `--coralogix-token`, and the various `--eks-*` flags.\n\nIf you need help, contact us on Slack, email, or by opening a GitHub issue.\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003eDebug mode\u003c/summary\u003e\nIf you want to see additional debug logs:\n\n```sh\nkrr simple -v\n```\n\n\u003c/details\u003e\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n## How KRR works\n\n### Metrics Gathering\n\nRobusta KRR uses the following Prometheus queries to gather usage data:\n\n- CPU Usage:\n\n  ```\n  sum(irate(container_cpu_usage_seconds_total{{namespace=\"{object.namespace}\", pod=\"{pod}\", container=\"{object.container}\"}}[{step}]))\n  ```\n\n- Memory Usage:\n\n  ```\n  sum(container_memory_working_set_bytes{job=\"kubelet\", metrics_path=\"/metrics/cadvisor\", image!=\"\", namespace=\"{object.namespace}\", pod=\"{pod}\", container=\"{object.container}\"})\n  ```\n\n[_Need to customize the metrics? Tell us and we'll add support._](https://github.com/robusta-dev/krr/issues/new)\n\nGet a free breakdown of KRR recommendations in the [Robusta SaaS](#free-krr-ui-on-robusta-saas).\n\n### Algorithm\n\nBy default, we use a _simple_ strategy to calculate resource recommendations. It is calculated as follows (_The exact numbers can be customized in CLI arguments_):\n\n- For CPU, we set a request at the 95th percentile with no limit. Meaning, in 95% of the cases, your CPU request will be sufficient. For the remaining 5%, we set no limit. This means your pod can burst and use any CPU available on the node - e.g. CPU that other pods requested but aren’t using right now.\n\n- For memory, we take the maximum value over the past week and add a 15% buffer.\n\n### Prometheus connection\n\nFind about how KRR tries to find the default Prometheus to connect \u003ca href=\"#prometheus-victoria-metrics-and-thanos-auto-discovery\"\u003ehere\u003c/a\u003e.\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\n\u003c!-- ADVANCED USAGE EXAMPLES --\u003e\n\n\n\n## Data Source Integrations\n\u003cdetails id=\"prometheus-victoria-metrics-and-thanos-auto-discovery\"\u003e\u003csummary\u003e Prometheus, Victoria Metrics and Thanos auto-discovery\u003c/summary\u003e\n\nBy default, KRR will try to auto-discover the running Prometheus Victoria Metrics and Thanos.\nFor discovering Prometheus it scans services for those labels:\n\n```python\n\"app=kube-prometheus-stack-prometheus\"\n\"app=prometheus,component=server\"\n\"app=prometheus-server\"\n\"app=prometheus-operator-prometheus\"\n\"app=rancher-monitoring-prometheus\"\n\"app=prometheus-prometheus\"\n```\n\nFor Thanos its these labels:\n\n```python\n\"app.kubernetes.io/component=query,app.kubernetes.io/name=thanos\",\n\"app.kubernetes.io/name=thanos-query\",\n\"app=thanos-query\",\n\"app=thanos-querier\",\n```\n\nAnd for Victoria Metrics its the following labels:\n\n```python\n\"app.kubernetes.io/name=vmsingle\",\n\"app.kubernetes.io/name=victoria-metrics-single\",\n\"app.kubernetes.io/name=vmselect\",\n\"app=vmselect\",\n```\n\nIf none of those labels result in finding Prometheus, Victoria Metrics or Thanos, you will get an error and will have to pass the working url explicitly (using the `-p` flag).\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\u003c/details\u003e\n\n\u003cdetails id=\"scanning-with-a-centralized-prometheus\"\u003e\n\u003csummary\u003eScanning with a Centralized Prometheus\u003c/summary\u003e\n\nIf your Prometheus monitors multiple clusters we require the label you defined for your cluster in Prometheus.\n\nFor example, if your cluster has the Prometheus label `cluster: \"my-cluster-name\"`, then run this command:\n\n```sh\nkrr.py simple --prometheus-label cluster -l my-cluster-name\n```\n\nYou may also need the `-p` flag to explicitly give Prometheus' URL.\n\n\u003c/details\u003e\n\n\n\u003cdetails id=\"azure-managed-prometheus\"\u003e\n\u003csummary\u003eAzure Managed Prometheus\u003c/summary\u003e\n\nFor Azure managed Prometheus you need to generate an access token, which can be done by running the following command:\n\n```sh\n# If you are not logged in to Azure, uncomment out the following line\n# az login\nAZURE_BEARER=$(az account get-access-token --resource=https://prometheus.monitor.azure.com  --query accessToken --output tsv); echo $AZURE_BEARER\n```\n\nThan run the following command with PROMETHEUS_URL substituted for your Azure Managed Prometheus URL:\n\n```sh\npython krr.py simple --namespace default -p PROMETHEUS_URL --prometheus-auth-header \"Bearer $AZURE_BEARER\"\n```\n\n\u003cp \u003e\u003ca href=\"#scanning-with-a-centralized-prometheus\"\u003eSee here about configuring labels for centralized prometheus\u003c/a\u003e\u003c/p\u003e\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\u003c/details\u003e\n\n\u003cdetails id=\"google-managed-prometheus\"\u003e\n\u003csummary\u003eGoogle Managed Prometheus (GMP)\u003c/summary\u003e\n\nPlease find the detailed GMP usage instructions [here](https://github.com/robusta-dev/krr/blob/main/docs/google-cloud-managed-service-for-prometheus.md)\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\u003c/details\u003e\n\n\u003cdetails id=\"amazon-managed-prometheus\"\u003e\n\u003csummary\u003eAmazon Managed Prometheus\u003c/summary\u003e\n\nFor Amazon Managed Prometheus you need to add your Prometheus link and the flag --eks-managed-prom and krr will automatically use your aws credentials\n\n```sh\npython krr.py simple -p \"https://aps-workspaces.REGION.amazonaws.com/workspaces/...\" --eks-managed-prom\n```\n\nAdditional optional parameters are:\n\n```sh\n--eks-profile-name PROFILE_NAME_HERE # to specify the profile to use from your config\n--eks-access-key ACCESS_KEY # to specify your access key\n--eks-secret-key SECRET_KEY # to specify your secret key\n--eks-service-name SERVICE_NAME # to use a specific service name in the signature\n--eks-managed-prom-region REGION_NAME # to specify the region the Prometheus is in\n```\n\n\u003cp \u003e\u003ca href=\"#scanning-with-a-centralized-prometheus\"\u003eSee here about configuring labels for centralized prometheus\u003c/a\u003e\u003c/p\u003e\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\u003c/details\u003e\n\n\n\u003cdetails id=\"coralogix-managed-prometheus\"\u003e\n\u003csummary\u003eCoralogix Managed Prometheus\u003c/summary\u003e\n\nFor Coralogix managed Prometheus you need to specify your Prometheus link and add the flag coralogix_token with your Logs Query Key\n\n```sh\npython krr.py simple -p \"https://prom-api.coralogix...\" --coralogix_token\n```\n\n\u003cp \u003e\u003ca href=\"#scanning-with-a-centralized-prometheus\"\u003eSee here about configuring labels for centralized prometheus\u003c/a\u003e\u003c/p\u003e\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\u003c/details\u003e\n\n\u003cdetails id=\"grafana-cloud-managed-prometheus\"\u003e\n\u003csummary\u003eGrafana Cloud Managed Prometheus\u003c/summary\u003e\n\nFor Grafana Cloud managed Prometheus you need to specify Prometheus link, Prometheus user, and an access token of your Grafana Cloud stack. The Prometheus link and user for the stack can be found on the Grafana Cloud Portal. An access token with a `metrics:read` scope can also be created using Access Policies on the same portal.\n\nNext, run the following command, after setting the values of PROM_URL, PROM_USER, and PROM_TOKEN variables with your Grafana Cloud stack's Prometheus link, Prometheus user, and access token.\n\n```sh\npython krr.py simple -p $PROM_URL --prometheus-auth-header \"Bearer ${PROM_USER}:${PROM_TOKEN}\" --prometheus-ssl-enabled\n```\n\n\u003cp \u003e\u003ca href=\"#scanning-with-a-centralized-prometheus\"\u003eSee here about configuring labels for centralized prometheus\u003c/a\u003e\u003c/p\u003e\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\u003c/details\u003e\n\n\u003cdetails id=\"grafana-mimir-auto-discovery\"\u003e\n\u003csummary\u003e Grafana Mimir auto-discovery\u003c/summary\u003e\n\nBy default, KRR will try to auto-discover the running Grafana Mimir.\n\nFor discovering Prometheus it scans services for those labels:\n```python\n  \"app.kubernetes.io/name=mimir,app.kubernetes.io/component=query-frontend\"\n```\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\u003c/details\u003e\n\n## Integrations\n\n\u003cdetails id=\"free-ui-for-krr-recommendations\"\u003e\n\u003csummary\u003eFree UI for KRR recommendations\u003c/summary\u003e\n\nWe highly recommend using the [free Robusta SaaS platform](https://platform.robusta.dev/signup/?benefits=krr\u0026utm_source=github\u0026utm_medium=krr-readme\u0026utm_content=integrations-free-robusta-saas-platform). You can:\n\n- Understand individual app recommendations with app usage history\n- Sort and filter recommendations by namespace, priority, and more\n- Give dev's a YAML snippet to fix the problems KRR finds\n- Analyze impact using KRR scan history\n\n  \u003ca href=\"https://www.loom.com/share/49ea188f67c545f0ae98508b448d1a8b\"\u003e\n      \u003cimg src=\"https://cdn.loom.com/sessions/thumbnails/49ea188f67c545f0ae98508b448d1a8b-with-play.gif\"\u003e\n  \u003c/a\u003e\n\n\u003c/details\u003e\n\n\u003cdetails id=\"slack-notification\"\u003e\n\u003csummary\u003eSlack Notification\u003c/summary\u003e\n\nPut cost savings on autopilot. Get notified in Slack about recommendations above X%. Send a weekly global report, or one report per team.\n\n![Slack Screen Shot][slack-screenshot]\n\n### Prerequisites\n\n- A Slack workspace\n\n### Setup\n\n1. [Install Robusta with Helm to your cluster and configure slack](https://docs.robusta.dev/master/installation.html)\n2. Create your KRR slack playbook by adding the following to `generated_values.yaml`:\n\n```\ncustomPlaybooks:\n# Runs a weekly krr scan on the namespace devs-namespace and sends it to the configured slack channel\ncustomPlaybooks:\n- triggers:\n  - on_schedule:\n      fixed_delay_repeat:\n        repeat: -1 # number of times to run or -1 to run forever\n        seconds_delay: 604800 # 1 week\n  actions:\n  - krr_scan:\n      args: \"--namespace devs-namespace\" ## KRR args here\n  sinks:\n      - \"main_slack_sink\" # slack sink you want to send the report to here\n```\n\n3. Do a Helm upgrade to apply the new values: `helm upgrade robusta robusta/robusta --values=generated_values.yaml --set clusterName=\u003cYOUR_CLUSTER_NAME\u003e`\n\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\u003c/details\u003e\n\n\u003cdetails id=\"k9s-plugin\"\u003e\n\u003csummary\u003ek9s Plugin\u003c/summary\u003e\n\n  Install our k9s Plugin to get recommendations directly in deployments/daemonsets/statefulsets views.\n\n  Plugin: [resource recommender](https://github.com/derailed/k9s/blob/master/plugins/resource-recommendations.yaml)\n\n  Installation instructions: [k9s docs](https://k9scli.io/topics/plugins/)\n\u003c/details\u003e\n\n## Creating a Custom Strategy/Formatter\n\nLook into the [examples](https://github.com/robusta-dev/krr/tree/main/examples) directory for examples on how to create a custom strategy/formatter.\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\u003c!-- TESTING --\u003e\n\n## Testing\n\n_We use pytest to run tests._\n\n1. Install the project manually (see above)\n2. Navigate to the project root directory\n3. Install [poetry](https://python-poetry.org/docs/#installing-with-the-official-installer)\n4. Install dev dependencies:\n\n```sh\npoetry install --group dev\n```\n\n5. Install robusta_krr as editable dependency:\n\n```sh\npip install -e .\n```\n\n6. Run the tests:\n\n```sh\npoetry run pytest\n```\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\u003c!-- CONTRIBUTING --\u003e\n\n## Contributing\n\nContributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**.\n\nIf you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag \"enhancement\".\nDon't forget to give the project a star! Thanks again!\n\n1. Fork the Project\n2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)\n3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)\n4. Push to the Branch (`git push origin feature/AmazingFeature`)\n5. Open a Pull Request\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\u003c!-- LICENSE --\u003e\n\n## License\n\nDistributed under the MIT License. See [LICENSE.txt](https://github.com/robusta-dev/krr/blob/main/LICENSE) for more information.\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\u003c!-- CONTACT --\u003e\n\n## Support\n\nIf you have any questions, feel free to contact **support@robusta.dev** or message us on [robustacommunity.slack.com](https://bit.ly/robusta-slack)\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\u003c!-- MARKDOWN LINKS \u0026 IMAGES --\u003e\n\u003c!-- https://www.markdownguide.org/basic-syntax/#reference-style-links --\u003e\n\n[contributors-shield]: https://img.shields.io/github/contributors/othneildrew/Best-README-Template.svg?style=for-the-badge\n[contributors-url]: https://github.com/othneildrew/Best-README-Template/graphs/contributors\n[forks-shield]: https://img.shields.io/github/forks/othneildrew/Best-README-Template.svg?style=for-the-badge\n[forks-url]: https://github.com/othneildrew/Best-README-Template/network/members\n[stars-shield]: https://img.shields.io/github/stars/othneildrew/Best-README-Template.svg?style=for-the-badge\n[stars-url]: https://github.com/othneildrew/Best-README-Template/stargazers\n[issues-shield]: https://img.shields.io/github/issues/othneildrew/Best-README-Template.svg?style=for-the-badge\n[issues-url]: https://github.com/othneildrew/Best-README-Template/issues\n[license-shield]: https://img.shields.io/github/license/othneildrew/Best-README-Template.svg?style=for-the-badge\n[license-url]: https://github.com/othneildrew/Best-README-Template/blob/master/LICENSE.txt\n[linkedin-shield]: https://img.shields.io/badge/-LinkedIn-black.svg?style=for-the-badge\u0026logo=linkedin\u0026colorB=555\n[linkedin-url]: https://linkedin.com/in/othneildrew\n[product-screenshot]: images/screenshot.jpeg\n[slack-screenshot]: images/krr_slack_example.png\n[ui-screenshot]: images/ui_video.gif\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobusta-dev%2Fkrr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobusta-dev%2Fkrr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobusta-dev%2Fkrr/lists"}