diff options
author | Jasper Ras <jras@hostnet.nl> | 2025-03-20 11:07:49 +0100 |
---|---|---|
committer | Jasper Ras <jras@hostnet.nl> | 2025-03-20 11:07:49 +0100 |
commit | 80ccf68f55dbb70d7e5ed52ee95b3c9d1b6ce264 (patch) | |
tree | 93e28e85ab70052aa6f577998ec7dc1f413b40c0 /4 Archives/Backup service metrics | |
parent | 9642cd7ae24f0ba79ce5647c709b35ae8f06a285 (diff) |
vault backup: 2025-03-20 11:07:48
Diffstat (limited to '4 Archives/Backup service metrics')
-rw-r--r-- | 4 Archives/Backup service metrics/Prometheus metrics.md | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/4 Archives/Backup service metrics/Prometheus metrics.md b/4 Archives/Backup service metrics/Prometheus metrics.md new file mode 100644 index 0000000..d41a80c --- /dev/null +++ b/4 Archives/Backup service metrics/Prometheus metrics.md @@ -0,0 +1,22 @@ +--- +tags: + - gobs + - metrics + - prometheus +--- +Prometheus' main thing is to scrape endpoints for metrics. Thus instead of exposing alot of data via the API that keystone would query and create relevant metrics, we can just expose a /metrics endpoint ourselves. This is alot faster because we can directly query all data structures and we have all the domain knowledge here to know what is relevant. + +A hack to clear gauges in an older version of prometheus_client: +```python + def update_gauge(self, gauge, stats): + # Ensure that if a stat combination is gone, because it is resolved, we actually remove it from the Gauge. + # Same as clear() which is available in a later version of prometheus_client but not in the one available + # through apt at the time of writing. + with gauge._lock: + gauge._metrics = {} + + for stat, count in stats.items(): + gauge.labels(*stat).set(count) +``` + +According to Rutger labels aren't deleted on the Thanos/Prometheus side, so we don't want to be "too flexible" with our labelling. Rather create specific metrics. This is exactly the cardinality problem of labels.
\ No newline at end of file |