Support for Unknown status condition in Custom Resources
What would you like to be added:
Improve support for producing a gauge for the status conditions of a custom resource, when the condition status is Unknown. Today, the data point cannot be produced due to a parse error:
[status,conditions]: [1]: [status]: strconv.ParseFloat: parsing \"Unknown\": invalid syntax
The gauge definition is:
- name: "foo_status"
help: "status condition "
each:
type: Gauge
gauge:
path: [status, conditions]
labelsFromPath:
type: ["type"]
valueFrom: ["status"]
Why is this needed:
This is needed to round out the support for status conditions. Unknown is a legit status value and should be supported.
Describe the solution you'd like it isn't totally clear what the gauge value should be. Here's a couple of options:
- Don't report an error message and skip reporting the data point. This means that
Unknownwould translate into the absence of a data point. - Consider adding a
valueMapstructure to map the status values to a numerical value, e.g.
- name: "foo_status"
help: "status condition "
each:
type: Gauge
gauge:
path: [status, conditions]
labelsFromPath:
type: ["type"]
valueFrom: ["status"]
valueMap:
- {from: "Unknown", to: 0}
- {from: "True", to: 1}
- {from: "False", to: 0}
A related issue https://github.com/kubernetes/kube-state-metrics/issues/1978, so that you can use cel to extract what you want.
/triage accepted /assign @CatherineF-dev
I just ran into this issue and was able to workaround it by using a StateSet
- name: status_condition
each:
type: StateSet
stateSet:
path: [status, conditions]
labelName: status
valueFrom: [status]
list: [True, False, Unknown]
labelsFromPath:
type: [type]
I just ran into this issue and was able to workaround it by using a StateSet
- name: status_condition each: type: StateSet stateSet: path: [status, conditions] labelName: status valueFrom: [status] list: [True, False, Unknown] labelsFromPath: type: [type]
I feel like this suggestion should go into the docs here. Currently suggests using a Gauge for the status.conditions but this doesn't capture the 'unknown' status as suggested.