{"id":24518556,"url":"https://github.com/rexagod/resource-state-metrics","last_synced_at":"2025-03-15T11:12:52.630Z","repository":{"id":263914274,"uuid":"891757038","full_name":"rexagod/resource-state-metrics","owner":"rexagod","description":"Resource State Metrics controller's source.","archived":false,"fork":false,"pushed_at":"2025-01-20T22:41:50.000Z","size":17364,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-20T23:26:31.696Z","etag":null,"topics":["sig-instrumentation"],"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/rexagod.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"code-of-conduct.md","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":"2024-11-20T22:41:08.000Z","updated_at":"2025-01-20T22:41:53.000Z","dependencies_parsed_at":"2025-01-20T23:23:56.690Z","dependency_job_id":"68e8c027-857d-40fe-bfad-b3fe16628aca","html_url":"https://github.com/rexagod/resource-state-metrics","commit_stats":null,"previous_names":["rexagod/resource-state-metrics"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rexagod%2Fresource-state-metrics","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rexagod%2Fresource-state-metrics/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rexagod%2Fresource-state-metrics/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rexagod%2Fresource-state-metrics/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rexagod","download_url":"https://codeload.github.com/rexagod/resource-state-metrics/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243719398,"owners_count":20336607,"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":["sig-instrumentation"],"created_at":"2025-01-22T01:43:12.822Z","updated_at":"2025-03-15T11:12:52.607Z","avatar_url":"https://github.com/rexagod.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `resource-state-metrics`\n\n[![CI](https://github.com/rexagod/resource-state-metrics/actions/workflows/continuous-integration.yaml/badge.svg)](https://github.com/rexagod/resource-state-metrics/actions/workflows/continuous-integration.yaml) [![Go Report Card](https://goreportcard.com/badge/github.com/rexagod/resource-state-metrics)](https://goreportcard.com/report/github.com/rexagod/resource-state-metrics) [![Go Reference](https://pkg.go.dev/badge/github.com/rexagod/resource-state-metrics.svg)](https://pkg.go.dev/github.com/rexagod/resource-state-metrics)\n\n## Summary\n\n`resource-state-metrics` is a Kubernetes controller that builds on Kube-State-Metrics' Custom Resource State's ideology and generates metrics for custom resources based on the configuration specified in its managed resource, `ResourceMetricsMonitor`.\n\nThe project's [conformance benchmarking](./tests/bench/bench.sh) shows 3x faster RTT for `resource-state-metrics` as compared to Kube-State-Metrics' Custom Resource Definition Metrics ([ea5826a](https://github.com/kubernetes/kube-state-metrics/commit/ea5826a92cde206fc6784d2cb6b7c2548d2b2290)) feature-set:\n\n```\nThu Nov 21 05:06:09 IST 2024\n[RESOURCESTATEMETRICS]\nBUILD:\t1059ms\nRTT:\t1107ms\n[CUSTOMRESOURCESTATE]\nBUILD:\t1116ms\nRTT:\t3196ms\n```\n\n## Development\n\nStart developing by following these steps:\n\n- Set up dependencies with `make setup`.\n- Test out your changes with `make apply apply-testdata local`.\n  - Telemetry metrics, by default, are exposed on `:9998/metrics`.\n  - Resource metrics, by default, are exposed on `:9999/metrics`.\n- Start a `pprof` interactive session with `make pprof`.\n\nFor more details, take a look at the [Makefile](Makefile) targets.\n\n## Notes\n\n- Garbage in, garbage out: Invalid configurations will generate invalid metrics. The exception to this being that certain checks that ensure metric structure are still present (for e.g., `value` should be a `float64`).\n- Library support: The module is **never** intended to be used as a library, and as such, does not export any functions or types, with `pkg/` being an exception (for managed types and such).\n- Metrics stability: There are no metrics [stability](https://kubernetes.io/blog/2021/04/23/kubernetes-release-1.21-metrics-stability-ga/) guarantees, as the metrics are user-generated.\n- No middle-ware: The configuration is `unmarshal`led into a set of stores that the codebase directly operates on. There is no middle-ware that processes the configuration before it is used, in order to avoid unnecessary complexity. However, the expression(s) within the `value` and `labelValues` may need to be evaluated before being used, and as such, are exceptions.\n\u003c!-- vale off --\u003e\n- The managed resource, `ResourceMetricsMonitor` is namespace-scoped, but, to keep in accordance with Kube-State-Metrics' `CustomResourceState`, which allows for collecting metrics from cluster-wide resources, it is possible to omit any `field` or `label` selectors to achieve that result. Similarly, to isolate metrics between namespaces (or teams), the selectors may be levied, and a utility such as [`prom-label-proxy`](https://github.com/prometheus-community/prom-label-proxy) to enforce selective namespace(s) or custom label(s).\n  - Enforce namespaced-collection behind a flag (for cluster admins)?\n\u003c!-- vale on --\u003e\n\n## TODO\n\nIn the order of priority:\n\n- [X] CEL expressions for metric generation (or [*unstructured.Unstructured](https://github.com/kubernetes/apimachinery/issues/181), if that suffices).\n- [X] Conformance test(s) for Kube-State-Metrics' [Custom Resource State API](https://github.com/kubernetes/kube-state-metrics/blob/main/docs/metrics/extend/customresourcestate-metrics.md#multiple-metricskitchen-sink).\n- [X] Benchmark(s) for Kube-State-Metrics' [Custom Resource State API](https://github.com/kubernetes/kube-state-metrics/blob/main/docs/metrics/extend/customresourcestate-metrics.md#multiple-metricskitchen-sink).\n- [X] E2E tests covering the controller's basic functionality.\n- [X] `s/CRSM/CRDMetrics`.\n- [X] [Draft out a KEP](https://github.com/kubernetes/enhancements/issues/4785).\n- [X] `s/CRDMetrics/ResourceStateMetrics`.\n- [X] Make `ResourceMetricsMonitor` namespaced-scope. This allows for:\n  - [X] per-namespace configuration (separate configurations between teams), and,\n  - [ ] garbage collection (without `finalizers`), since currently the namespace-scoped deployment manages its cluster-scoped resources.\n- [ ] Meta-metrics for metric generation failures.\n- [ ] Dynamic admission control for `ResourceMetricsMonitor` CRD.\n\n###### [License](./LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frexagod%2Fresource-state-metrics","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frexagod%2Fresource-state-metrics","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frexagod%2Fresource-state-metrics/lists"}