{"id":19417815,"url":"https://github.com/gocrane/fadvisor","last_synced_at":"2025-08-22T08:31:18.398Z","repository":{"id":38401756,"uuid":"446279026","full_name":"gocrane/fadvisor","owner":"gocrane","description":"Fadvisor(FinOps Advisor) is a collection of exporters which collect cloud resource pricing and billing data guided by FinOps, insight cost allocation for containers and kubernetes resource","archived":false,"fork":false,"pushed_at":"2024-06-18T13:23:06.000Z","size":4164,"stargazers_count":70,"open_issues_count":11,"forks_count":26,"subscribers_count":8,"default_branch":"main","last_synced_at":"2024-12-13T10:26:58.944Z","etag":null,"topics":["billing","cloud-native","cost-insight","cost-optimization","finops","kubernetes"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gocrane.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}},"created_at":"2022-01-10T04:23:22.000Z","updated_at":"2024-12-02T02:20:09.000Z","dependencies_parsed_at":"2024-11-10T13:11:37.658Z","dependency_job_id":"98f4b946-758e-4614-8cf4-a6016bd5aa2e","html_url":"https://github.com/gocrane/fadvisor","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gocrane%2Ffadvisor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gocrane%2Ffadvisor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gocrane%2Ffadvisor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gocrane%2Ffadvisor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gocrane","download_url":"https://codeload.github.com/gocrane/fadvisor/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230575851,"owners_count":18247484,"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":["billing","cloud-native","cost-insight","cost-optimization","finops","kubernetes"],"created_at":"2024-11-10T13:11:30.517Z","updated_at":"2024-12-20T11:06:06.141Z","avatar_url":"https://github.com/gocrane.png","language":"Go","funding_links":[],"categories":["Repositories"],"sub_categories":[],"readme":"# Fadvisor: FinOps Advisor\n\n[![Go Report Card](https://goreportcard.com/badge/github.com/gocrane/fadvisor)](https://goreportcard.com/report/github.com/gocrane/fadvisor)\n[![GoDoc](https://godoc.org/github.com/gocrane/fadvisor?status.svg)](https://godoc.org/github.com/gocrane/fadvisor)\n[![License](https://img.shields.io/github/license/gocrane/fadvisor)](https://www.apache.org/licenses/LICENSE-2.0.html)\n![GoVersion](https://img.shields.io/github/go-mod/go-version/gocrane/fadvisor)\n\n\u003cimg src=\"docs/images/fadvisor.png\"\u003e\n\n---\n\nFadvisor(FinOps Advisor) provides capability of `FinOps Observalibility`, it can be integrated with Crane to help users to improve the `cost visualization` and `cost optimization`. Also, it can be integrated with your monitoring system as a metric exporter.\n\n\nFadvisor has a collection of exporters to collect metrics about cost and other metrics. \n\n - `exporters` collects metrics guided by `FinOps`.\n   - now a cost-exporter is available, and other exporters can be integrated\n - [`comparator`](./docs/tutorials/comparator.zh.md) compare different container platform costing crossing different cloud providers. Provide best purchase and migration policy of workloads for crane.\n \n\n# Concept\nFadvisor Cost model provides a way to estimate and breakdown the resource price of each container, pod, or other resources in kubernetes. Then, users can have cost insight by viewing cost grouped by labels or other dimensions.\n\nPlease note that Cost model is to **estimate cost**, not to replace the billing, because real billing depends on the billing system.\n\nCost model is an implementation of the cost allocation and showback \u0026 chargeback from the FinOps.\n\t  \n\t1. The simplest cost model is to estimate a resource price of all nodes or pods by the same price.\n\t   For example, when compute costs, you can assume all container's cpu \u0026 ram unit price is the same, 2$ Core/Hour, 0.3$ Gib/Hour\n\n\t2. Advanced cost model is to estimate a resource price by cost breakdown.\n\t   This theory is based on that price of each cloud machine instance with different instance type and charge type is different.\n\t   So the containers price in different node type is different.\n\n# Tutorial\nFadvisor is a metrics exporter which collects cloud instance price information by calling Cloud Billing API and exports the price information as metrics. \nAny cloud provider can implement the API and Crane will work for the specific Cloud, Tencent Cloud is supported in current release.\n\n## PreRequests\nInstall Prometheus\n```\nhelm repo add prometheus-community https://prometheus-community.github.io/helm-charts\nhelm install prometheus -n crane-system --set pushgateway.enabled=false --set alertmanager.enabled=false --set server.persistentVolume.enabled=false -f https://raw.githubusercontent.com/gocrane/helm-charts/main/integration/prometheus/override_values.yaml --create-namespace  prometheus-community/prometheus\n\n```\nInstall Grafana\n```\nhelm repo add grafana https://grafana.github.io/helm-charts\nhelm install grafana -f https://raw.githubusercontent.com/gocrane/helm-charts/main/integration/grafana/override_values.yaml -n crane-system --create-namespace grafana/grafana\n```\n\n## Deploy fadvisor \n### Deploy on local\nInstall on local such as mac desktop, it will use default config. you can also deploy on cloud by this way, but it will use default config.\n\n```\nhelm repo add crane https://gocrane.github.io/helm-charts\nhelm install fadvisor -n crane-system --create-namespace crane/fadvisor\n```\n\n### Deploy on cloud\nIf you deploy fadvisor on cloud, now it support tencent cloud. you need provide a qcloud config file which include cloud credentials as following, make sure you specify your `clusterId`,`secretId`,`secretKey`,`region`\n\n```\n[credentials]\nclusterId={your cluster id}\nappId=app1\nsecretId={your cloud provider credential secret id}\nsecretKey={your cloud provider credential secret key}\n[clientProfile]\ndefaultLimit=100\ndefaultLanguage=zh-CN\ndefaultTimeoutSeconds=10\nregion={your cluster region, such as ap-beijing、ap-shanghai、ap-guangzhou、ap-shenzhen and so on, you can find region name in your cloud provider console}\ndomainSuffix=internal.tencentcloudapi.com\nscheme=\n```\nthen execute following commands, suppose your config file name is qcloud-config.ini in your current directory:\n```\nhelm repo add crane https://gocrane.github.io/helm-charts\nhelm install fadvisor --set-file cloudConfigFile=qcloud-config.ini --set extraArgs.provider=qcloud  -n crane-system --create-namespace crane/fadvisor\n```\nExcept Fadvisor, it will install following components in your system by default.\n\n - kube-state-metrics\n - node-exporter\n - prometheus\n - grafana\n\n\n## Integrated with existing monitoring components\nIf you have Prometheus and Grafana installed, you can just deploy fadvisor and change related configuration.\n\nYou can deploy the fadvisor to your tke cluster to collect the metric, use prometheus to scrape the metric, and following dashboards can be used;\n\n### 1. Deploy fadvisor\n#### Install by helm\n```\nhelm repo add crane https://gocrane.github.io/helm-charts\nhelm install fadvisor -n crane-system --create-namespace crane/fadvisor\n```\n\n#### Install by kubectl\n**NOTE**  you must specify your k8s secret id and secret key in `config` file, this is used to access Tencent Cloud Cvm API.\n\n```\n[credentials]\nclusterId={your cluster id}\nappId=app1\nsecretId={your cloud provider credential secret id}\nsecretKey={your cloud provider credential secret key}\n[clientProfile]\ndefaultLimit=100\ndefaultLanguage=zh-CN\ndefaultTimeoutSeconds=10\nregion={your cluster region, such as ap-beijing、ap-shanghai、ap-guangzhou、ap-shenzhen and so on, you can find region name in your cloud provider console}\ndomainSuffix=internal.tencentcloudapi.com\nscheme=\n```\nthen execute `cat config | base64`, paste the secret to following secret.yaml's config.\n```\napiVersion: v1\nkind: Secret\nmetadata:\n  name: fadvisor\ndata:\n  config: W2NyZWRlbnRpYWxzXQpjbHVzdGVySWQ9Y2x1c3RlcjEKYXBwSWQ9YXBwMQpzZWNyZXRJZD1pZDEKc2VjcmV0S2V5PWtleTEKW2NsaWVudFByb2ZpbGVdCmRlYnVnPXRydWUKZGVmYXVsdExpbWl0PTEKZGVmYXVsdExhbmd1YWdlPUNICmRlZmF1bHRUaW1lb3V0U2Vjb25kcz0xMApyZWdpb249c2hhbmdoYWkKZG9tYWluU3VmZml4PWNsb3VkLnRlbmNlbnQuY29tCnNjaGVtZT1odHRwCg==\n```\nthen deploy by kubectl.\n```\nkubectl create -f deploy/fadvisor/ -n crane-system\n```\n\n### 2. Configure the prometheus scrape config and rules\nConfigure following scrape target to your prometheus. \n\n```\n- job_name: \"fadvisor\"\n    honor_timestamps: true\n    scrape_interval: 5m\n    scheme: http\n    metrics_path: /metrics\n    static_configs:\n      - targets: ['fadvisor.crane-system.svc.cluster.local:8081']\n```\n**NOTE**, except cost-exporter, your prometheus must have scraped the kubernetes metrics including:\n - `kubelet-cadvisor` metrics.\n - `node-exporter` metrics. need to install node-exporter.\n - `kube-state-metrics` metrics. need to install kube-state-metrics.\n\n\nConfigure some recording rules to your prometheus.\n```\nrecording_rules.yml:\n  groups:\n    - name: costs.rules\n      interval: 3600s\n      rules:\n        - expr: |\n            sum(label_replace(irate(container_cpu_usage_seconds_total{container!=\"POD\", container!=\"\",image!=\"\"}[1h]), \"node\", \"$1\", \"instance\",  \"(.*)\")) by (container, pod, node, namespace) * on (node) group_left() avg(avg_over_time(node_cpu_hourly_cost[1h])) by (node)\n          record: namespace:container_cpu_usage_costs_hourly:sum_rate\n        - expr: |\n            sum(label_replace(avg_over_time(container_memory_working_set_bytes{container!=\"POD\",container!=\"\",image!=\"\"}[1h]), \"node\", \"$1\", \"instance\",  \"(.*)\")) by (container, pod, node, namespace) / 1024.0 / 1024.0 / 1024.0 * on (node) group_left() avg(avg_over_time(node_ram_hourly_cost[1h])) by (node)\n          record: namespace:container_memory_usage_costs_hourly:sum_rate\n        - expr: |\n            avg(avg_over_time(node_cpu_hourly_cost[1h])) by (node)\n          record: node:node_cpu_hourly_cost:avg\n        - expr: |\n            avg(avg_over_time(node_ram_hourly_cost[1h])) by (node)\n          record: node:node_ram_hourly_cost:avg\n        - expr: |\n            avg(avg_over_time(node_total_hourly_cost[1h])) by (node)\n          record: node:node_total_hourly_cost:avg\n\n```\n\n### 3. Import following grafana dashboards to your grafana\nAnd there are some available grafana dashboards for you if you has installed grafana already.\n```\n./deploy/helm/fadvisor/charts/grafana/dashboards/cluster-costs.json\n./deploy/helm/fadvisor/charts/grafana/dashboards/costs-dimension.json\n./deploy/helm/fadvisor/charts/grafana/dashboards/namespace-costs.json\n\n```\n\n#### Estimated cluster costs\n\u003cimg src=\"docs/images/cluster-costs.png\"\u003e\n\n#### Namespace costs \n\u003cimg src=\"docs/images/namespace-costs.png\"\u003e\n\n#### Topk container costs\n\u003cimg src=\"docs/images/costs-dimension.png\"\u003e\n\n\n# Dependency\n - kube-state-metrics\n - node-exporter\n - prometheus\n - grafana\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgocrane%2Ffadvisor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgocrane%2Ffadvisor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgocrane%2Ffadvisor/lists"}