-
Notifications
You must be signed in to change notification settings - Fork 224
PMM-14956 HA alert templates #5730
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
4nte
wants to merge
5
commits into
main
Choose a base branch
from
PMM-14956-ha-alert-templates
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
9bbd9a5
PMM-14956 Add pmm_ha_expected_nodes metric
4nte dababa2
PMM-14956 Harden PMM_HA_PEERS parsing
4nte 16ecd35
PMM-14956 Add HA cluster alert templates
4nte 8b2a681
PMM-14956 Document HA alert templates
4nte 24a1e8f
Merge branch 'main' into PMM-14956-ha-alert-templates
theTibi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| --- | ||
| templates: | ||
| - name: pmm_ha_leader_flapping | ||
| version: 1 | ||
| summary: PMM HA leader is flapping | ||
| queries: | ||
| - ref_id: A | ||
| expr: |- | ||
| max by(node_id) (changes(pmm_ha_raft_term[10m])) | ||
| expressions: | ||
| - ref_id: C | ||
| type: math | ||
| expression: "$A > [[ .threshold ]]" | ||
| condition: C | ||
| params: | ||
| - name: threshold | ||
| summary: Number of Raft term changes within 10 minutes | ||
| type: float | ||
| range: [1, 100] | ||
| value: 5 | ||
| for: 5m | ||
| severity: warning | ||
| annotations: | ||
| summary: PMM HA leader is flapping | ||
| description: |- | ||
| The Raft term changed more than [[ .threshold ]] times in the last 10 minutes. | ||
| Frequent re-elections indicate an unstable network, an overloaded leader, or a leader that keeps restarting. | ||
|
|
||
| Remediation steps: | ||
| 1. Check network latency and packet loss between PMM Server nodes on the configured Raft port (PMM_HA_RAFT_PORT). | ||
| 2. Check whether pmm-managed is restarting on any node. | ||
| 3. Check CPU, memory and disk I/O saturation on the PMM Server nodes. A starved leader misses its heartbeats. | ||
| 4. Review the pmm-managed logs for repeated transitions between the candidate and follower states. |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| --- | ||
| templates: | ||
| - name: pmm_ha_no_leader | ||
| version: 1 | ||
| summary: PMM HA cluster has no active leader | ||
| # last_over_time bounds how long a departed leader's final sample can mask a leaderless | ||
| # cluster, narrowing the lookback to 2m. max by(node_id) collapses any duplicate series | ||
| # for one node, so a node is counted once no matter what labels the scrape adds. | ||
| expr: 'sum(max by(node_id) (last_over_time(pmm_ha_leader_status[2m]))) == bool 0' | ||
| for: 3m | ||
| severity: critical | ||
| annotations: | ||
| summary: PMM HA cluster has no active leader | ||
| description: |- | ||
| No node in the PMM High Availability cluster currently holds the Raft leader lease. | ||
| Leader-only background work such as advisor checks, backups, telemetry and scheduled tasks is not running. | ||
|
|
||
| Remediation steps: | ||
| 1. Check that a majority of PMM Server nodes are running and reachable. | ||
| 2. Check network connectivity between nodes on the configured Raft and gossip ports (PMM_HA_RAFT_PORT and PMM_HA_GOSSIP_PORT). | ||
| 3. Inspect the pmm-managed logs on each node for repeated election attempts or 'no known peers' messages. | ||
| 4. If the cluster has lost a majority of its nodes, restore them. Raft cannot elect a leader without quorum. |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| --- | ||
| templates: | ||
| - name: pmm_ha_node_unreachable | ||
| version: 1 | ||
| summary: PMM HA node unreachable | ||
| # A node that goes down stops emitting pmm_ha_up entirely, so it cannot be named from a | ||
| # live series. The first term names nodes seen in the last 6h but not the last 2m. The | ||
| # second is the count-versus-expected check, guarded by absent() so it only reports when | ||
| # no node can be named: one that never reported, or has been gone longer than 6h. | ||
| expr: |- | ||
| (max by(node_id) (last_over_time(pmm_ha_up[6h])) unless max by(node_id) (last_over_time(pmm_ha_up[2m]))) | ||
| or | ||
| ((count(max by(node_id) (last_over_time(pmm_ha_up[2m]))) < bool max(last_over_time(pmm_ha_expected_nodes[2m]))) | ||
| and absent(max by(node_id) (last_over_time(pmm_ha_up[6h])) unless max by(node_id) (last_over_time(pmm_ha_up[2m])))) | ||
| for: 5m | ||
| severity: warning | ||
| annotations: | ||
| summary: "{{ if $labels.node_id }}PMM HA node '{{ $labels.node_id }}' is unreachable{{ else }}A PMM HA node is unreachable, fewer nodes are reporting than configured{{ end }}" | ||
| description: |- | ||
| {{ if $labels.node_id }}PMM Server node '{{ $labels.node_id }}' has stopped reporting HA metrics.{{ else }}Fewer PMM Server nodes are reporting HA metrics than the number configured for this cluster.{{ end }} | ||
| A node is down, restarting repeatedly, or unable to reach the shared metrics storage. | ||
|
|
||
| Remediation steps: | ||
| 1. Open the High Availability page to see which nodes are still reporting. | ||
| 2. Check the status of the PMM Server container or pod on every node. | ||
| 3. Check that the missing node can still write metrics to the shared VictoriaMetrics storage. | ||
| 4. Check network connectivity between nodes on the configured Raft and gossip ports (PMM_HA_RAFT_PORT and PMM_HA_GOSSIP_PORT). | ||
| 5. If the node was removed on purpose, update PMM_HA_PEERS on the remaining nodes so that the expected node count matches. |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| --- | ||
| templates: | ||
| - name: pmm_ha_quorum_at_risk | ||
| version: 1 | ||
| summary: PMM HA quorum at risk | ||
| # last_over_time drops nodes that stopped reporting out of the voter count, instead of | ||
| # waiting out the metrics database's longer staleness window. | ||
| expr: |- | ||
| (count(max by(node_id) (last_over_time(pmm_ha_up{role="voter"}[2m]))) <= bool floor(max(last_over_time(pmm_ha_expected_nodes[2m])) / 2 + 1)) | ||
| and on() (max(last_over_time(pmm_ha_expected_nodes[2m])) > 2) | ||
| for: 3m | ||
| severity: critical | ||
| annotations: | ||
| summary: PMM HA quorum at risk, the cluster has no spare voters left | ||
| description: |- | ||
| The number of live Raft voters has fallen to or below the smallest majority that still forms a quorum. | ||
| At the boundary the cluster still works, but one more node failure will make it impossible to elect a | ||
| leader. Below the boundary leader election has already stopped, and leader-only work such as advisor | ||
| checks, backups and scheduled tasks has stopped with it. The High Availability page shows which of the | ||
| two applies. | ||
|
|
||
| Remediation steps: | ||
| 1. If a PMM_HA_PEERS change is being rolled out, this alert can fire while the nodes still disagree on the cluster size. Confirm the rollout has finished before treating it as a failure. | ||
| 2. Restore the failed nodes now. Do not restart or drain any of the remaining nodes until the cluster has a spare again. | ||
| 3. Check the status of the PMM Server container or pod and the pmm-managed logs on every node. | ||
| 4. Check network connectivity between nodes on the configured Raft and gossip ports (PMM_HA_RAFT_PORT and PMM_HA_GOSSIP_PORT). | ||
| 5. Check that the shared PostgreSQL, VictoriaMetrics and ClickHouse storage is reachable from the surviving nodes. | ||
| 6. Confirm recovery on the High Availability page once all nodes are back. |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| --- | ||
| templates: | ||
| - name: pmm_ha_split_brain | ||
| version: 1 | ||
| summary: PMM HA split-brain detected | ||
| # last_over_time stops a departing leader's final sample being counted alongside the | ||
| # new leader. Keep this window shorter than 'for', or an ordinary failover will fire. | ||
| # max by(node_id) collapses any duplicate series for one node, so a single node cannot | ||
| # be counted twice and raise a split brain on its own. | ||
| expr: 'sum(max by(node_id) (last_over_time(pmm_ha_leader_status[2m]))) > bool 1' | ||
| for: 3m | ||
| severity: critical | ||
| annotations: | ||
| summary: PMM HA split-brain detected, more than one node claims leadership | ||
| description: |- | ||
| More than one PMM Server node reports itself as the Raft leader at the same time. | ||
| Raft never allows two leaders within one cluster, so this means the nodes have formed | ||
| separate clusters instead of one. Every node bootstraps its own single-node cluster at | ||
| startup and then relies on peer discovery to merge into the others; when that discovery | ||
| fails, each node stays the leader of a cluster of one. | ||
| Leader-only work may run more than once and diverging writes are possible. | ||
|
|
||
| Remediation steps: | ||
| 1. Open the High Availability page to see which nodes claim leadership, and compare the peers each one knows about. A node that formed its own cluster lists only itself. | ||
| 2. Check that PMM_HA_PEERS is identical on every node and that PMM_HA_NODE_ID is unique. A node missing from the peer lists is never discovered. | ||
| 3. Check that the nodes could reach each other at startup on the configured gossip and Raft ports (PMM_HA_GOSSIP_PORT and PMM_HA_RAFT_PORT; the Helm chart sets these to values other than the defaults), and look for firewall, security group, iptables or network policy rules blocking them. | ||
| 4. Inspect the pmm-managed logs on each node from startup onwards, for failures to join the peer list and for nodes entering the leader state. | ||
| 5. Separate Raft clusters do not merge on their own. Once the cause is fixed, restart pmm-managed on the nodes that should not be leaders so they rejoin. If a node keeps re-forming its own cluster, stop it and remove its Raft state directory (/srv/ha/<node_id>) before restarting; that directory holds only cluster membership state. |
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win
Use a structured
logrus.Entryfor duplicate-peer warnings.Line 1255 uses the package-level
logrus.Warnf. Pass the existingmainentry toparseHAPeers. Log the peer as a field so the message retains component context and supports structured filtering.As per coding guidelines, use “structured logging, such as
s.l.WithField("key", value).Error("message"), and pass*logrus.Entryrather than*logrus.Logger.”Proposed fix
📝 Committable suggestion
🤖 Prompt for AI Agents
Source: Coding guidelines