From e964e639274efff359de78b65c261c9a9cf981be Mon Sep 17 00:00:00 2001 From: Michele Mancioppi Date: Wed, 30 Mar 2022 07:06:20 +0200 Subject: [PATCH] Explain rationale for not using some prometheus scrape settings in charms (#255) Co-authored-by: sed-i <82407168+sed-i@users.noreply.github.com> --- .../prometheus_k8s/v0/prometheus_scrape.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/lib/charms/prometheus_k8s/v0/prometheus_scrape.py b/lib/charms/prometheus_k8s/v0/prometheus_scrape.py index b3553343..ba1bdef1 100644 --- a/lib/charms/prometheus_k8s/v0/prometheus_scrape.py +++ b/lib/charms/prometheus_k8s/v0/prometheus_scrape.py @@ -126,7 +126,7 @@ def __init__(self, *args): not with fully qualified targets. Multiple jobs with different metrics paths and labels are allowed, but -each job must be given a unique name. For example +each job must be given a unique name: ``` [ @@ -162,14 +162,10 @@ def __init__(self, *args): the continuity of the metrics time series gathered by Prometheus when the leader unit changes (e.g. on upgrade or rescale). -It is also possible to configure other scrape related parameters using -these job specifications as described by the Prometheus -[documentation](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#scrape_config). -The permissible subset of job specific scrape configuration parameters -supported in a `MetricsEndpointProvider` job specification are: +Additionally, it is also technically possible, but **strongly discouraged**, to +configure the following scrape-related settings, which behave as described by the +[Prometheus documentation](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#scrape_config): -- `job_name` -- `metrics_path` - `static_configs` - `scrape_interval` - `scrape_timeout` @@ -181,6 +177,11 @@ def __init__(self, *args): - `label_name_length_limit` - `label_value_length_limit` +The settings above are supported by the `prometheus_scrape` library only for the sake of +specialized facilities like the [Prometheus Scrape Config](https://charmhub.io/prometheus-scrape-config-k8s) +charm. Virtually no charms should use these settings, and charmers definitely **should not** +expose them to the Juju administrator via configuration options. + ## Consumer Library Usage The `MetricsEndpointConsumer` object may be used by Prometheus @@ -308,7 +309,7 @@ def _on_scrape_targets_changed(self, event): `scrape_jobs` and `alert_rules` keys in application relation data of Metrics provider charms hold eponymous information. -""" +""" # noqa: W505 import json import logging