-
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
CustomResourceStateMetrics Gauges do not work for Kubernetes Controller Status Conditions #1962
Comments
I guess we need a case for "True" and "False" (probably also lower case) here:
Alternatively, there could be a way to provide a mapping from value (i.e. string) to float. |
/assign @rexagod |
In CAPI we do export conditions as
|
Looks like a valid workaround. Downside is probably twice (or 3x) the number of metrics and your queries become more complicated. I guess another more generic way would be a valueMap for gauges. Could look like this:
Not sure how many use cases exist for that kind of mapping though. |
From prior art: kube-state-metrics does it the same way for core resources and Examples:
From code to metric perspective: the field is a string and not typed to a boolean which is why I'm curious if the custom resource metric should get adjusted to support such cases like hardcoding the strings |
I understand your point from a CS perspective. However, in practice it (a) makes working with those metrics a lot harder, (b) increases cardinality, and (c) I have rarely seen status Unknown at all. a) Having three metrics for 1 resource where only one "exists" at a time causes issues in prometheus as they overlap due to stale timeout. We often see incorrect counts and flaky alerts because of this. One status value per resource is robust to query and easy to understand. According to the discussion in the KEP about status.conditions the format has been choosen this way to ensure compatibility with most libraries and not because it is the best way to represent the data. This is not the only implicit transformation. I documented all transformations in #1964. |
These are all indeed fair points and I also see the advantages of implementing parsing true/false to 1/0 👍 . I just tend to first take a look at what's already there and what the options we have, before rushing into an actual implementation. The only con I currently see is, that people may come over from "core condition metrics" and want to adapt their queries and may not be aware of the difference in the metric. But I also think that this should not be a blocker. Thanks for the deep dive and information from the KEP! 😃 Just one point regarding c: from UX perspective this would make it hard to guess what the config really is doing. The mapping variant seems to be the most readable to me which does not require taking a further look at the docs or actual implementation 👍 |
Fair point. Should we add that as that as well or instead? I guess it would not be hard to implement. Changing config would be ok as we would only add stuff. |
I observe that Here's the solution that I use: - name: "status_condition"
help: The condition of a foo.
each:
type: Gauge
gauge:
path: [ status, conditions ]
labelsFromPath:
condition: [ "type" ]
valueFrom: [ "status" ] |
What happened:
We are trying to export a metric based on the standard status conditions CRD for objects of our kubernetes controllers (i.e. cert-manager or custom controllers based on kubebuilder).
We defined
--custom-resource-state-config
in kube-state-metics 2.7.0:Unfortunately, by default kubernetes controllers use a string condition:
And
kube-state-metrics
yields a parse error:What you expected to happen:
I would expect it to be able to parse "True"/"False" or a way to map them to 1/0.
How to reproduce it (as minimally and precisely as possible):
Anything else we need to know?:
Environment:
kubectl version
): v1.22.17The text was updated successfully, but these errors were encountered: