-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Missing replacement config for VPA collector in CRM #2041
Comments
/triage accepted |
Hi @QuentinBisson, I would like to work on this issue. I am new to Kubernetes repo, can you help me where i can get started for this issue? |
@samyakjain10 I would first check the existing VPA metrics and read about the CRM exporter to try and reproduce the metrics :) |
Do you have any update on this?
tried with labelFromPath: containerName and valueFrom but I only got nil or kube-state-metrics crash/panic |
I'm a novice with CustomResourceStateMetrics but this worked for me:
If you have multiple containers in a pod you will need to duplicate the above for each container and increment the path, you can use the same name for the metric. I've stuck with this for now until CEL is implemented as wildcards aren't supported. |
@benhodgkiss thank you, that works. |
@benhodgkiss unfortunately this does not work all the time. E0620 09:39:22.228995 1 registry_factory.go:649] "kube_customresource_vpa_cpu_recommendations" err="[status,recommendation,containerRecommendations,0,target,cpu]: []: strconv.ParseFloat: parsing "3136m": invalid syntax" Did you face the same error? |
I'm not seeing this error and I do have containers with targets over 1000m. Are you running the latest version of KSM? |
I had one cluster with an older version of ksm. |
I am trying to resolve this one to. - name: "containerrecommendations_target"
help: "VPA container recommendations for memory."
each:
type: Gauge
gauge:
path:
- status
- recommendation
- containerRecommendations
- "0"
- target
- memory
labelsFromPath:
container:
- status
- recommendation
- containerRecommendations
- "0"
- containerName
commonLabels:
resource: "memory"
unit: "byte"
- name: "containerrecommendations_target"
help: "VPA container recommendations for cpu."
each:
type: Gauge
gauge:
path:
- status
- recommendation
- containerRecommendations
- "0"
- target
- cpu
labelsFromPath:
container:
- status
- recommendation
- containerRecommendations
- "0"
- containerName
commonLabels:
resource: "cpu"
unit: "core" Result: But it still has some issues like: It only get's the first entry, of the container list when using "0". I couldn't find a way to do a "for each". status:
conditions:
- lastTransitionTime: "2022-06-13T13:52:07Z"
status: "True"
type: RecommendationProvided
recommendation:
containerRecommendations:
- containerName: grafana
lowerBound:
cpu: 10m
memory: "144644419"
target:
cpu: 11m
memory: "163378051"
uncappedTarget:
cpu: 11m
memory: "163378051"
upperBound:
cpu: 11m
memory: "164136870"
- containerName: grafana-sc-dashboard
lowerBound:
cpu: 10m
memory: "109813731"
target:
cpu: 11m
memory: "126805489"
uncappedTarget:
cpu: 11m
memory: "126805489"
upperBound:
cpu: 11m
memory: "127394175"
- containerName: grafana-sc-datasources
lowerBound:
cpu: 10m
memory: "93632226"
target:
cpu: 11m
memory: "109814751"
uncappedTarget:
cpu: 11m
memory: "109814751"
upperBound:
cpu: 11m
memory: "110324558" And the pod value is Update: Can confirm that the following works fine in the prometheus-community/kube-prometheus-stack chart :) - kube-state-metrics:
customResourceState:
enabled: true
config:
spec:
resources:
- groupVersionKind:
group: autoscaling.k8s.io
kind: "VerticalPodAutoscaler"
version: "v1"
labelsFromPath:
verticalpodautoscaler:
- metadata
- name
namespace:
- metadata
- namespace
target_api_version:
- apiVersion
target_kind:
- spec
- targetRef
- kind
target_name:
- spec
- targetRef
- name
metricNamePrefix: kube_customresource_vpa_containerrecommendations
metrics:
- name: "target"
help: "VPA container recommendations for memory."
commonLabels:
resource: "memory"
unit: "byte"
each:
type: Gauge
gauge:
path:
- status
- recommendation
- containerRecommendations
valueFrom:
- target
- memory
labelsFromPath:
container:
- containerName
- name: "target"
help: "VPA container recommendations for cpu."
commonLabels:
resource: "cpu"
unit: "core"
each:
type: Gauge
gauge:
path:
- status
- recommendation
- containerRecommendations
valueFrom:
- target
- cpu
labelsFromPath:
container:
- containerName
rbac:
extraRules:
- apiGroups:
- customresourcedefinitions.apiextensions.k8s.io
resources:
- customresourcedefinitions
verbs:
- list
- watch
- apiGroups:
- autoscaling.k8s.io
resources:
- verticalpodautoscalers
verbs:
- list
- watch |
Unfortunately I don't think it's possible to get the target for all containers in a pod without duplicating the config as I mentioned in my first comment until CEL is added. Also, you can't get the pod name but you shouldn't need to, the target or vpa name should be enough as you will know which pods that is targeting. |
I am on the latest KSM and struggling to get this to work... every config I try for this ends up with
And then I get a long error log like this:
|
@jeisen probably you forgot the RBAC Rules required?! Here you go with my custom yaml configs to the ## Configuration for kube-state-metrics subchart
##
kube-state-metrics:
rbac:
extraRules:
- apiGroups: ["autoscaling.k8s.io"]
resources: ["verticalpodautoscalers"]
verbs: ["list", "watch"]
prometheus:
monitor:
enabled: true
# https://github.com/kubernetes/kube-state-metrics/blob/main/docs/customresourcestate-metrics.md#verticalpodautoscaler
# https://github.com/kubernetes/kube-state-metrics/issues/2041#issuecomment-1614327806
customResourceState:
enabled: true
config:
kind: CustomResourceStateMetrics
spec:
resources:
- groupVersionKind:
group: autoscaling.k8s.io
kind: "VerticalPodAutoscaler"
version: "v1"
labelsFromPath:
verticalpodautoscaler: [metadata, name]
namespace: [metadata, namespace]
target_api_version: [apiVersion]
target_kind: [spec, targetRef, kind]
target_name: [spec, targetRef, name]
metrics:
- name: "vpa_containerrecommendations_target"
help: "VPA container recommendations for memory."
each:
type: Gauge
gauge:
path: [status, recommendation, containerRecommendations, "0", target, memory]
labelsFromPath:
container: [status, recommendation, containerRecommendations, "0", containerName]
commonLabels:
resource: "memory"
unit: "byte"
- name: "vpa_containerrecommendations_target"
help: "VPA container recommendations for cpu."
each:
type: Gauge
gauge:
path: [status, recommendation, containerRecommendations, "0", target, cpu]
labelsFromPath:
container: [status, recommendation, containerRecommendations, "0", containerName]
commonLabels:
resource: "cpu"
unit: "core"
selfMonitor:
enabled: true With that config I get a new metric Hints on my versions:
|
@sherifkayad Hmm, I'm not using the operator, but otherwise my config is the same. Maybe that's the missing piece... |
Use valueFrom works for me to get all containers metrics - name: "verticalpodautoscaler_status_recommendation_containerrecommendations_target_memory"
each:
type: Gauge
gauge:
path: [status, recommendation, containerRecommendations]
valueFrom: [target, memory]
labelsFromPath:
container: [containerName]
commonLabels:
resource: "memory"
unit: "byte" Result: kube_customresource_verticalpodautoscaler_status_recommendation_containerrecommendations_target_memory{container="busybox",customresource_group="autoscaling.k8s.io",customresource_kind="VerticalPodAutoscaler",customresource_version="v1",namespace="default",target_api_version="apps/v1",target_kind="Deployment",target_name="nginx-deployment",verticalpodautoscaler="test-vpa"} 1.31072e+08
kube_customresource_verticalpodautoscaler_status_recommendation_containerrecommendations_target_memory{container="nginx1",customresource_group="autoscaling.k8s.io",customresource_kind="VerticalPodAutoscaler",customresource_version="v1",namespace="default",target_api_version="apps/v1",target_kind="Deployment",target_name="nginx-deployment",verticalpodautoscaler="test-vpa"} 1.31072e+08 |
I can confirm this is working for me.
Thanks! |
Hi, just wanted to say thanks to all for this thread, helped me a lot 🙇♂️ |
@wcgomes that works like a charm for me as well! Thanks a lot |
Sorry for the inconvenience caused by that breaking change. Based on all the improvements that have been made through this issue, would anyone be interested in udpating the doc from https://github.com/kubernetes/kube-state-metrics/blob/main/docs/customresourcestate-metrics.md#verticalpodautoscaler to help others? |
/remove-kind feature |
@dgrisonnet I can happily submit a PR as soon as tomorrow to address that. No problems 👍 |
Awesome! Thank you :) /assign @sherifkayad |
@dgrisonnet PR submitted and linked to the issue |
Since the upgrade I missed the metrics for the lowerBound, upperBound and uncappedTarget
|
@drisbee thanks it works! |
I have installed vpa as follows
With the following enabled in the kub-prometheus-stack
Which grafana dashboard are you using for getting metrics? https://grafana.com/grafana/dashboards/14588-vpa-recommendations/ I am following this link |
I'm using this one: https://grafana.com/grafana/dashboards/14588-vpa-recommendations/ |
@drisbee That one I authored .. let me know if you need anything with it |
@sherifkayad I imported the dashboard but i do not see any data. I only see the below metrics in prometheus. |
@linuxbsdfreak The names of the metrics you have are different from the ones configured in the dashboard. The dashboard is expecting e.g. a metric with the name |
Hi, I am the author of the last dashboard and old blog post. I will update both as I have now the "new" kube-state-metrics on my platforms. Please find here my configuration : https://gist.github.com/rverchere/780bd988b8f385a00644a1ec9f425be3 |
What would you like to be added:
I would like to have a complete replacement example for VPA CRM configuration here instead of a simple example defining how to create vpa annotation metrics when most useful metrics (basically any of the resource) are complex to define for people starting out with CRM
Why is this needed:
Current documentation is not really usable. It more or less feels like users have to do the replacement themselves, are forced to learn how CRM works and dig into the code of KSM when a sufficient documentation could help users get started faster.
Describe the solution you'd like
Have a full example of a crm config to have the same vpa metrics as before.
Some metrics might change (because the VPA collected does some calculation to change the unit that is currently not supported by CRM) but at least having the same information (labelset and values) would help people upgrade to 2.9.0.
Additional context
Coming from this #1718 (comment)
The text was updated successfully, but these errors were encountered: