Skip to content

Allow overriding ruleSelector on cloud Prometheus - #1097

Open
methylDragon wants to merge 1 commit into
ch3/victoriametrics-robotmetrics-fixesfrom
ch3/prometheus-rule-selector
Open

methylDragon wants to merge 1 commit into
ch3/victoriametrics-robotmetrics-fixesfrom
ch3/prometheus-rule-selector

Conversation

@methylDragon

@methylDragon methylDragon commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

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.

📖 Detailed Change Description (click to expand)

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.
bazel build //src/app_charts/prometheus:all

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>
@methylDragon
methylDragon requested a review from liyin00 October 20, 2026 14:55
@methylDragon methylDragon added the enhancement New feature or request label Oct 20, 2026
@methylDragon
methylDragon added this pull request to stack #1098 October 20, 2026 15:21

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant