Comments (5)
You generally want to keep the number of 1:1 labels to a minimum. Otherwise, over time, you would basically enrich every metrics with all transitive and static label dimensions. If then something changes unexpectedly after all, you break all time series, as their identity is given by the full combination of all labels.
Generally speaking, you want your metrics to normalized.
What we probably want here are metrics that express the relation from pod to deployment and pod to node. In your queries, you can then connect the time series along them.
So the node name could probably be attached to the kube_pod_info
metric as a label: https://github.com/kubernetes/kube-state-metrics/blob/master/pod.go#L26-L30
We could have a metric on the created-by
relation (currently living as a SerializedRef
type in the kubernetes.io/created-by
annotation. For example (creator_namespace
would be redundant):
kube_pod_created_by{pod="my-app-aef242",namespace="prod",creator_kind="ReplicaSet", creator_name="my-app-12341"} 1
Unfortunately, relation from ReplicaSet to Deployment is not yet accessible in a similar way, but we can just use regex matching below to express it via ReplicaSets.
Your PromQL query could then look like:
count(
count by(node_name) (
kube_pod_info
and on(pod,namespace) kube_pod_status_phase{phase="Running"}
and on(pod,namespace) kube_pod_created_by{creator_kind="ReplicaSet", creator_name=~"my-app-[0-9]+"})
)
)
/ count(kube_node_info)
I know this is not a trivial but imagine that this is just one use case of many to incorporate relationships between components into your queries. So hard cording it into the exposed metrics does solve just a single use case of many.
Recording rules can help you here to break these parts out into separate metrics, which can be useful for other alerts and dashboards as well.
I think a pull request for metric additions/changes as described above would be welcome.
from kube-state-metrics.
I am unsure if we are able to get these upward and cross linking references from a pod. I'll take a little time to investigate.
from kube-state-metrics.
Issues go stale after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale
.
Stale issues rot after an additional 30d of inactivity and eventually close.
Prevent issues from auto-closing with an /lifecycle frozen
comment.
If this issue is safe to close now please do so with /close
.
Send feedback to sig-testing, kubernetes/test-infra and/or @fejta
.
/lifecycle stale
from kube-state-metrics.
Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten
.
Rotten issues close after an additional 30d of inactivity.
If this issue is safe to close now please do so with /close
.
Send feedback to sig-testing, kubernetes/test-infra and/or @fejta
.
/lifecycle rotten
/remove-lifecycle stale
from kube-state-metrics.
Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen
.
Mark the issue as fresh with /remove-lifecycle rotten
.
Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close
from kube-state-metrics.
Related Issues (20)
- Request to support ASLR in Kube-state-metrics HOT 2
- Using k8s labels in prometheus rules expr HOT 1
- v2.11.0 docker image doesn't exist on registry.k8s.io/kube-state-metrics/kube-state-metrics HOT 2
- Kube Node Status NotReady detection HOT 2
- Chart missing for v2.11.0 HOT 3
- Allow Custom Resource State mode to filter on resource labels HOT 1
- CVE in v2.11.0 Image HOT 8
- sharding with a deployment with '--resources=pods' and '--node=""' does not fetch pending pods HOT 10
- [regression] /metrics port down when not existing CRD are listed in config file HOT 5
- kube-state-metrics with autosharding stops updating shards when the labels of the statefulset are updated HOT 20
- Generated Prometheus metrics output not meet with the requirements HOT 4
- Parse Nested Arrays does not work HOT 1
- Some kube-state-metrics shards are serving up stale metrics HOT 5
- Node selection for fully qualified node-names fails (--node=ip-xx-xx-xx-xx.myzone.com) HOT 2
- Cut 2.12.1 HOT 2
- Purpose of `kube_pod_status_ready{condition="unknown"}` HOT 13
- `kube_job_failed` should have `reason` label HOT 5
- Image link in README is outdated HOT 2
- Custom resource state metrics wildcard not working HOT 1
- Flux custom metrics monitoring broken in 2.12 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kube-state-metrics.