Repository navigation
Allow overriding ruleSelector on cloud Prometheus - #1097
Open
methylDragon wants to merge 1 commit into
Open
methylDragon wants to merge 1 commit into
methylDragon wants to merge 1 commit into
Conversation
Why: During the VictoriaMetrics transition, legacy cloud Prometheus forwards scraped metrics to VictoriaMetrics-Robots via remoteWrite, so it needs a configurable ruleSelector to stop evaluating and forwarding cloud PrometheusRule recording rules.
**TL;DR:** Expose `.Values.prometheus.prometheusSpec.ruleSelector` via `$CR_PROMETHEUS_RULE_SELECTOR_OBJECT` in the cloud Prometheus chart and align selector map indentation to 4 spaces.
<details>
<summary><b>📖 Detailed Review Guide</b> (click to expand)</summary>
### Problem
- Cloud `prometheus-cloud.values.yaml` hardcodes a universal `ruleSelector`, so even when service and pod monitor selectors are restricted to legacy targets, cloud Prometheus still evaluates all cloud recording rules and forwards them into `VictoriaMetrics-Robots`.
### Changes
- Make `ruleSelector` configurable in the cloud Prometheus chart.
- Replaces the hardcoded rule selector with `$CR_PROMETHEUS_RULE_SELECTOR_OBJECT` and injects `.Values.prometheus.prometheusSpec.ruleSelector` (`$prometheusRuleSelectorMap`).
- Align `serviceMonitorSelector`, `podMonitorSelector`, and `ruleSelector` YAML substitution to 4 spaces.
- Uses `nindent 4` and 4-space prefix trimming to match the placeholder column in `Prometheus.spec` (`$formattedPrometheusRuleSelectorObject`).
### Review Focus
#### Where to Look
- Check `$prometheusRuleSelectorMap` in `src/app_charts/prometheus/cloud/prometheus-operator.yaml`.
- Verify `ruleSelector` defaults to `{}` (selecting all rules in matched namespaces) when `.Values.prometheus.prometheusSpec.ruleSelector` is unset.
#### Gotchas
- We replace `$CR_PROMETHEUS_RULE_SELECTOR_OBJECT: REMOVE_ME` with `{}` when `.Values.prometheus.prometheusSpec.ruleSelector` is omitted.
- Because in `prometheus-operator`, an empty `{}` label selector matches all `PrometheusRule` objects in the selected namespaces, preserving the existing default behavior.
### Tested
- Built all `//src/app_charts/prometheus:all` targets and verified `ruleSelector` indentation in `prometheus-operator-chart.cloud.yaml`.
```bash
bazel build //src/app_charts/prometheus:all
```
</details>
Signed-off-by: methylDragon <methylDragon@intrinsic.ai>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why: During the VictoriaMetrics transition, legacy cloud Prometheus forwards scraped metrics to VictoriaMetrics-Robots via remoteWrite, so it needs a configurable ruleSelector to stop evaluating and forwarding cloud PrometheusRule recording rules.
TL;DR: Expose
.Values.prometheus.prometheusSpec.ruleSelectorvia$CR_PROMETHEUS_RULE_SELECTOR_OBJECTin the cloud Prometheus chart and align selector map indentation to 4 spaces.📖 Detailed Change Description (click to expand)
Problem
prometheus-cloud.values.yamlhardcodes a universalruleSelector, so even when service and pod monitor selectors are restricted to legacy targets, cloud Prometheus still evaluates all cloud recording rules and forwards them intoVictoriaMetrics-Robots.Changes
ruleSelectorconfigurable in the cloud Prometheus chart.$CR_PROMETHEUS_RULE_SELECTOR_OBJECTand injects.Values.prometheus.prometheusSpec.ruleSelector($prometheusRuleSelectorMap).serviceMonitorSelector,podMonitorSelector, andruleSelectorYAML substitution to 4 spaces.nindent 4and 4-space prefix trimming to match the placeholder column inPrometheus.spec($formattedPrometheusRuleSelectorObject).Review Focus
Where to Look
$prometheusRuleSelectorMapinsrc/app_charts/prometheus/cloud/prometheus-operator.yaml.ruleSelectordefaults to{}(selecting all rules in matched namespaces) when.Values.prometheus.prometheusSpec.ruleSelectoris unset.Gotchas
$CR_PROMETHEUS_RULE_SELECTOR_OBJECT: REMOVE_MEwith{}when.Values.prometheus.prometheusSpec.ruleSelectoris omitted.prometheus-operator, an empty{}label selector matches allPrometheusRuleobjects in the selected namespaces, preserving the existing default behavior.Tested
//src/app_charts/prometheus:alltargets and verifiedruleSelectorindentation inprometheus-operator-chart.cloud.yaml.