Skip to content

initializer: fix the Operator DM master all-down alert - #1286

Merged
ti-chi-bot[bot] merged 1 commit into
pingcap:masterfrom
csuzhangxc:codex/fix-operator-dm-master-alert
Nov 24, 2026
Merged

ti-chi-bot[bot] merged 1 commit into
pingcap:masterfrom
csuzhangxc:codex/fix-operator-dm-master-alert

Conversation

@csuzhangxc

@csuzhangxc csuzhangxc commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

What changed

TiDB Operator assigns DM master scrape jobs names such as ns1-target-dm-master. The existing job="dm_master" selector returns no series for those targets, so the all-down alert cannot fire under the default Operator scrape configuration.

  • Override the generated Operator rule with max by (tidb_cluster) (up{component="dm-master"}) == 0 and update the master snapshot.
  • Keep the upstream TiFlow expression in the Ansible output.

Related 8.5 backport: #1285.

Validation

  • go test cmd/monitoring.go cmd/dm_rules_test.go passed. The test verifies the generated Operator rule matches the checked-in snapshot and the Ansible rule matches the upstream fixture.
  • A local PromQL test checked that one failed master does not alert and all discovered masters failing alerts only for the affected cluster.

Summary by CodeRabbit

  • Bug Fixes
    • Updated the DM master down alert to detect when all DM master instances for a cluster are down, using component-level monitoring data. The alert continues to require the condition to persist for five minutes, helping ensure the alert reflects the status of each cluster accurately.

Use the component and tidb_cluster scrape labels for the generated Operator rule. Preserve the upstream TiFlow expression in the Ansible output.
@ti-chi-bot
ti-chi-bot Bot requested a review from asddongmen November 24, 2026 09:46
@coderabbitai

coderabbitai Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The DM_master_all_down rule now checks the dm-master up metric grouped by tidb_cluster. The monitoring configuration defines the replacement expression, and the generation test checks the generated Ansible and Operator outputs against expected content.

Changes: DM master alert

Layer / File(s) Summary
Alert expression and generation validation
monitoring.yaml, monitor-snapshot/master/operator/rules/dm_worker.rules.yml, cmd/dm_rules_test.go
The replacement expression and alert rule check whether the maximum up value for component="dm-master" is zero, grouped by tidb_cluster. The test loads configured replacements, checks the Ansible output against its fixture, verifies the expression appears twice in the Operator output, and compares that output with the master snapshot.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: Minimal · up to 95882

This fixes the DM master all-down alert for Operator-generated scrape job names and updates the snapshot and test to match. No concrete merge-blocking risk was established. Whether tidb_cluster values are distinct across namespaces depends on the external Operator scrape configuration, which this repository does not contain.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the fix and the affected alert, "DM master all-down alert" in the Operator output, which matches the changes to the rule expression in monitor-snapshot, monitoring.yaml, and cmd/dm_rul…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the fix and the affected alert, "DM master all-down alert" in the Operator output, which matches the changes to the rule expression in monitor-snapshot, monitoring.yaml, and cmd/dm_rules_test.go. The title is specific and does not describe unrelated work. The scope is narrow, but the title covers the primary change.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

A rabbit checks the master’s light
By cluster, counting up just right
The rule now watches dm-master
Test snapshots check each rendered part
Then hops away beneath the moon

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 836357fe-3e9d-46fa-b1e6-ec32cd63f163
Commits

Reviewing files that changed from the base of the PR and between 0cc7e54 and 95882b8.

Files selected for processing: 3

  • cmd/dm_rules_test.go
  • monitor-snapshot/master/operator/rules/dm_worker.rules.yml
  • monitoring.yaml

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@ti-chi-bot ti-chi-bot Bot added the size/M label Nov 24, 2026
@ti-chi-bot

ti-chi-bot Bot commented Nov 24, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: fgksgf

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot Bot added the lgtm label Nov 24, 2026
@ti-chi-bot

ti-chi-bot Bot commented Nov 24, 2026

Copy link
Copy Markdown

[LGTM Timeline notifier]

Timeline:

  • 2026-11-24 09:51:14.26685732 +0000 UTC m=+2338.944439310: ☑️ agreed by fgksgf.

@ti-chi-bot ti-chi-bot Bot added the approved label Nov 24, 2026
@ti-chi-bot
ti-chi-bot Bot merged commit c2146f5 into pingcap:master Nov 24, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants