Commit Graph

26 Commits

Author SHA1 Message Date
Manuel Rüger c67f02f0f3
Apply suggestions from code review 2024-11-05 10:58:10 +01:00
leiwingqueen 37f10f0602 fix lint 2024-11-04 23:33:53 +08:00
leiwingqueen f94ef65cc7 fix overflow in other occasion 2024-11-04 10:09:18 +08:00
Pranshu Srivastava b382da615a
Adhere to OTel-Prometheus standard for labels
Adhere to OTel-Prometheus standard for generated labels in CRS.

Ref.: 8946dfc6a2/specification/compatibility/prometheus_and_openmetrics.md?plain=1#L224-L229
Additional info.: OSM has a hardcoded approach for doing this right now: https://github.com/openshift/openshift-state-metrics/blob/master/pkg/collectors/utils.go#L29

Signed-off-by: Pranshu Srivastava <rexagod@gmail.com>
2023-04-22 19:45:48 +05:30
Sherif Abdel-Naby a229e1b67f
Update internal/store/utils.go
Co-authored-by: Filip Petkovski <filip.petkovsky@gmail.com>
2022-02-10 14:19:12 +02:00
Sherif Abdel-Naby 8c9476d2d1
Update internal/store/utils.go
Co-authored-by: Filip Petkovski <filip.petkovsky@gmail.com>
2022-02-10 14:18:59 +02:00
Sherif Abdel-Naby 5766f80bd2
Add Comment 2022-02-10 04:32:19 +02:00
Sherif Abdel-Naby aa44127adb
Optimize by Allocating in one contiguous block 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 517b46cf1d
Fix use of wrong var
Signed-off-by: Sylvain Rabot <sylvain@abstraction.fr>
2021-07-13 17:41:23 +02:00
Sylvain Rabot 0e045365f4
Factorize some code
Signed-off-by: Sylvain Rabot <sylvain@abstraction.fr>
2021-07-13 11:51:39 +02:00
Sylvain Rabot 65bc62af5c
Add kube_*_annotations metrics
Signed-off-by: Sylvain Rabot <sylvain@abstraction.fr>
2021-04-29 16:04:16 +02:00
Mikulas (Mike) Dite 70d039b140 Add wildcard option to labels-metric-allow-list 2021-03-30 14:26:12 +01:00
Lili Cosic 0b76e7d4f4 internal/store: Rework label allow list for label metrics 2020-11-20 15:31:35 +01:00
Quentin Bisson 7250bc2b5c
Update go module path to k8s.io/kube-state-metrics/v2
Signed-off-by: Quentin Bisson <quentin@giantswarm.io>
2020-09-21 10:58:08 +02:00
Joel Whittaker-Smith 908f87b2cd apply boundaries to metrics and allow via flag what labels to include
Signed-off-by: Joel Whittaker-Smith <jdws.dev@gmail.com>
2020-08-26 12:42:30 +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
Lili Cosic 17eac3c7ec internal/store/utils.go: Add helper func for resource version metrics 2019-12-20 15:55:30 +01:00
Jens Erat 4e637854a2
add VolumeAttachment collector
Kubernetes has a new resource type: `VolumeAttachments`. They provide
helpful information on where a volume is attached and to alert on
unexpected attachment status (for example, differences between
information scraped from node-exporter and kube-state-metrics).

The collector adds a bunch of new metrics. Each VolumeAttachment (ie.,
each CSI-attached volume) will have one of each, so we do not overly
pollute the metrics space. Most metrics are rather unsurprising.

- `kube_volumeattachment_status_attachment_metadata`: provides a
  label-like export of the attachment metadata map. Generalizing the
  label-conversion function slightly helps at providing this metric.
- `kube_volumeattachment_created`: as VolumeAttachments are
  automatically created and we already suffered from duplicate
  `VolumeAttachments`, this can be invaluable for debugging
  misattachments.
- `kube_volumeattachment_spec_source_persistentvolume`: will only be
  generated when the volume source is of `PersistentVolume` type. The
  other type `inlineVolumeSpec` is still alpha-level and hard to map to
  metrics.

No end-to-end test manifest was added, as `VolumeAttachment`s are
automatically generated when mounting volumes.

Signed-off-by: Jens Erat <email@jenserat.de>
2019-10-13 21:36:50 +02:00
Ben Wells 816b5b3fec Enable unconvert linter 2019-10-04 21:39:21 +01:00
Tariq Ibrahim 1b42e7c450
lint: enforce goimports local prefixes 2019-08-20 10:33:05 -07: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