Skip to content
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

Updated rules using deprecated metrics with new versions. #556

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

shubhambhattar
Copy link
Contributor

Refer this changelog: https://github.com/kubernetes/kube-state-metrics/blob/33db2356bf1f0a1f51ddaaeb165bce04ab5aa0df/CHANGELOG.md#v200-alpha--2020-09-16

kube_pod_container_resource_requests_cpu_cores and kube_pod_container_resource_requests_memory_bytes are deprecated.

@@ -64,7 +68,7 @@
sum by (namespace) (
sum by (namespace, pod) (
max by (namespace, pod, container) (
kube_pod_container_resource_requests_memory_bytes{%(kubeStateMetricsSelector)s}
kube_pod_container_resource_requests{%(kubeStateMetricsSelector)s, %(memorySelector)s, %(byteSelector)s}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason why we don't just include the memorySelector and byteSelector directly in this query? We try to keep configuration minimal if there aren't really any other ways to configure something.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can. I thought this was the preferred way of doing it. I'll change that.

@brancz
Copy link
Member

brancz commented Mar 1, 2021

CI is failing, looks like our tests need some changes to the inputs since we're using different metrics with these changes. I think you should be fine just adapting the inputs of this test:

kubernetes-mixin/tests.yaml

Lines 113 to 156 in 3152600

- interval: 1m
input_series:
- series: 'kube_pod_container_resource_requests_cpu_cores{container="kube-apiserver-67",endpoint="https-main",instance="ksm-1",job="kube-state-metrics",namespace="kube-apiserver",node="node-1",pod="pod-1",service="ksm"}'
values: '0.15+0x10'
- series: 'kube_pod_container_resource_requests_cpu_cores{container="kube-apiserver-67",endpoint="https-main",instance="ksm-1",job="kube-state-metrics",namespace="kube-apiserver",node="node-1",pod="pod-2",service="ksm"}'
values: '0.15+0x10'
- series: 'kube_pod_container_resource_requests_cpu_cores{container="kube-apiserver-67",endpoint="https-main",instance="ksm-2",job="kube-state-metrics",namespace="kube-apiserver",node="node-1",pod="pod-1",service="ksm"}'
values: '0.1+0x10'
- series: 'kube_pod_container_resource_requests_memory_bytes{container="kube-apiserver-67",endpoint="https-main",instance="ksm-1",job="kube-state-metrics",namespace="kube-apiserver",node="node-1",pod="pod-1",service="ksm"}'
values: '1E9+0x10'
- series: 'kube_pod_container_resource_requests_memory_bytes{container="kube-apiserver-67",endpoint="https-main",instance="ksm-1",job="kube-state-metrics",namespace="kube-apiserver",node="node-1",pod="pod-2",service="ksm"}'
values: '1E9+0x10'
- series: 'kube_pod_container_resource_requests_memory_bytes{container="kube-apiserver-67",endpoint="https-main",instance="ksm-2",job="kube-state-metrics",namespace="kube-apiserver",node="node-1",pod="pod-1",service="ksm"}'
values: '0.5E9+0x10'
# Duplicate kube_pod_status_phase timeseries for the same pod.
- series: 'kube_pod_status_phase{endpoint="https-main",instance="ksm-1",job="kube-state-metrics",namespace="kube-apiserver",phase="Running",pod="pod-1",service="ksm"}'
values: '1 stale'
- series: 'kube_pod_status_phase{endpoint="https-main",instance="ksm-1",job="kube-state-metrics",namespace="kube-apiserver",phase="Pending",pod="pod-1",service="ksm"}'
values: '1+0x10'
- series: 'kube_pod_status_phase{endpoint="https-main",instance="ksm-1",job="kube-state-metrics",namespace="kube-apiserver",phase="Completed",pod="pod-2",service="ksm"}'
values: '1+0x10'
- series: 'kube_pod_status_phase{endpoint="https-main",instance="ksm-2",job="kube-state-metrics",namespace="kube-apiserver",phase="Running",pod="pod-1",service="ksm"}'
values: '1+0x10'
promql_expr_test:
- eval_time: 0m
expr: namespace:kube_pod_container_resource_requests_cpu_cores:sum
exp_samples:
- value: 0.15
labels: 'namespace:kube_pod_container_resource_requests_cpu_cores:sum{namespace="kube-apiserver"}'
- eval_time: 0m
expr: namespace:kube_pod_container_resource_requests_memory_bytes:sum
exp_samples:
- value: 1.0e+9
labels: 'namespace:kube_pod_container_resource_requests_memory_bytes:sum{namespace="kube-apiserver"}'
- eval_time: 1m
expr: namespace:kube_pod_container_resource_requests_cpu_cores:sum
exp_samples:
- value: 0.15
labels: 'namespace:kube_pod_container_resource_requests_cpu_cores:sum{namespace="kube-apiserver"}'
- eval_time: 1m
expr: namespace:kube_pod_container_resource_requests_memory_bytes:sum
exp_samples:
- value: 1.0e+9
labels: 'namespace:kube_pod_container_resource_requests_memory_bytes:sum{namespace="kube-apiserver"}'

@brancz
Copy link
Member

brancz commented Mar 2, 2021

Since these metrics have existed pretty much forever in kube-state-metrics, I'm happy with moving ahead right away with this.

Wdyt @paulfantom ?

Copy link
Member

@paulfantom paulfantom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have similar PR in #534 and the result of discussion from it was to wait for a stable KSM release. Without such release, this PR is breaking compatibility for all users, and merging it will result in requiring mixed metrics coming from KSM v1 and v2.

I wouldn't have much objections if there would be any guarantee that stable KSM v2 would be released soon. However, as it is right now, the first alpha release of kube-state-metrics was on 2020-09-16 and this doesn't reassure me that stable release is going to be released in the next days.

@brancz
Copy link
Member

brancz commented Mar 3, 2021

I'm not sure I understand as the metrics as they are used in this PR have been around for years in kube-state-metric 1.x, only the ones currently used in the mixin are being dropped in 2.0. Am I missing something else?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants