Open mlubanski opened 1 month ago
/assign @rexagod /triage accepted
Hi! We encountered the same issue in version 2.12.0
and 2.13.0
. It works with version 2.11.0
.
After a quick look, we found out that pkg/metrics_store/metrics_writer.go:120
(SanitizeHeaders
) is causing the problem.
In 2.12.0+, it removes the header from the slice.
// Nullify duplicate headers after the sanitization to not miss out on any new candidates.
if header == lastHeader {
writer.stores[0].headers = append(writer.stores[0].headers[:i], writer.stores[0].headers[i+1:]...)
// Do not increment the index, as the next header is now at the current index.
continue
}
In 2.11.0, it is set to an empty string.
writer.stores[0].headers[i] = ""
I suppose that this change probably further affects the behavior of the below loop in WriteAll
function of MetricsWriter
, causing that some metrics are missed in writing.
for i, help := range m.stores[0].headers {
...
for _, s := range m.stores {
for _, metricFamilies := range s.metrics {
_, err := w.Write(metricFamilies[i])
...
}
}
}
As suggested in this workaround https://github.com/kubernetes/kube-state-metrics/issues/2366#issuecomment-2058901252, just make help
text unique.
What happened:
I defined configuration for Custom Resource State Metrics for my three CRD's (
ReplicationGroup
,ClusterInstance
,RDSInstance
)After deploying it to cluster where I have kubernetes objects of all above types kube-state-metric is producing me expected
crossplane_engine_version
metricBut when I deploy same configuration to the cluster where I have only objects of
RDSInstance
type,crossplane_engine_version
metric is missingWhat you expected to happen:
Metric should be produced by kube-state-metric even if there are no real Objects of one type/kind listed in configuration below
How to reproduce it (as minimally and precisely as possible):
Environment:
2.12.0
v1.28.9
AWS