Commit Graph

10 Commits

Author SHA1 Message Date
Manuel Rüger 0c029b690e chore: Migrate to golangci-lint v2 2025-03-31 14:52:47 +02:00
Sherif Abdel-Naby c8ac409365
Lint 2022-02-10 04:26:47 +02:00
Sherif Abdel-Naby e205fee343
Extract mergeKeyValue logic into a central function 2022-02-10 04:12:35 +02:00
Sylvain Rabot 0e045365f4
Factorize some code
Signed-off-by: Sylvain Rabot <sylvain@abstraction.fr>
2021-07-13 11:51:39 +02:00
Damien Grisonnet 2483d78a1b internal/store: convert k8s labels to snake case
According to Prometheus best practices, labels should be written in
snake_case.

Signed-off-by: Damien Grisonnet <dgrisonn@redhat.com>
2020-07-06 15:23:31 +02:00
George Miroshnykov 6c9b7ff8ca Avoid conflicts when mapping Kubernetes labels to Prometheus labels
Prometheus 2.16.0 introduced a breaking change that prevents
_any_ metrics from being ingested from a target in case
_even a single_ metric has duplicate labels.

See https://github.com/prometheus/prometheus/pull/6664

This becomes a problem for ksm as Kubernetes label naming is less restrictive
than Prometheus label naming, so we have a "sanitization" process that replaces
unsupported characters with an underscore.

A side effect of this process is that it can produce duplicate labels, e.g.
Kubernetes labels "foo.bar", "foo-bar" and "foo_bar" are mapped to the same
Prometheus label "foo_bar".

Based on the discussion in #1141, we've decided to sort and then automatically
rename conflicting labels, so "foo-bar" and "foo_bar" will become
"label_foo_bar_conflict1" and "label_foo_bar_conflict2" correspondingly.

If you'd like to have more control over how this conflict is resolved,
you should consider addressing this on a different level of the stack,
e.g. by standardizing Kubernetes labels using Admission Webhook that
ensures that there are no possible conflicts.
2020-06-12 00:04:54 +03:00
Tariq Ibrahim 9799ac0e61
Merge release-1.7 into upstream/master 2019-08-05 10:46:00 -07:00
Frederic Branczyk 45b762614c
internal/store: Render labels and annotations in deterministic order
Previously metrics containing the annotations or labels of an object
rendered in the metrics endpoint in a non-deterministic way, as it
relied on the order of the map these were initialized in, since a map
has non-deterministic ordering.

Prometheus caches the byte representation of time-series for
fast-path inserts, so having this be deterministic causes lower cache
misses for Prometheus, hence better performance. Additionally
deterministic ordering allows for better testability.
2019-07-21 13:46:08 -07:00
Tariq Ibrahim 5c5a8932ab
rename kubeAnnotationsToPrometheusAnnotations to kubeAnnotationsToPrometheusLabels 2019-06-28 00:15:57 -07:00
Lili Cosic 68aea02d26 Makefile,internal/collector: Rename collector -> store
Since the removal of collector, this introduces both the concept of the
store and the resources instead of collectors that the user passes in.

The user facing logs and flags were not changed as that would be a
regression.
2019-06-11 16:18:53 +02:00