Skip to content

feat(k8s): alertmanager posts critical and warning alerts to mattermost's alerts channel, and a roadmap service repository whose rounds all fail for an hour alerts #1392

Description

@dan-petty

Refreshed plan (2026-10-17, unblocking review)

This section supersedes any text below that conflicts with it.

Decisions

Scope

  • Unchanged except for the rule's grouping, its summary and Loki hint, and when check (d) can run.
  • At 0 replicas the counter has no series. The rule is therefore merged silent and starts evaluating when the Service runs again.

Delivery

Acceptance criteria
These replace the matching parts of the rule criterion and of check (d). Every other criterion below stands, including these: the hook is locked to its channel and the receiver sets no channel or username; the hook is typed at a hidden prompt and stored under its keyring key; --dry-run lists the key with no value; the mount is read-only and optional; and the 8065 path admits only Alertmanager's pods.

  • RoadmapServiceJobsFailing, severity warning, for: 30m, reads sum by (repo, lane) (increase(devops_cli_service_jobs_total{result="error"}[1h])) > 0 unless on (repo, lane) sum by (repo, lane) (increase(devops_cli_service_jobs_total{result="success"}[1h])) > 0.
  • Its summary names the repository and the lane. Its description gives {namespace="devops"} | json | repo="<repo>" | lane="<lane>".
  • test_the_baseline_rule_set lists the rule, and a test asserts that both selectors group by and match on exactly repo and lane. Whichever of this item and feat(service): one webhook router verifies each provider its own way, parses a typed payload and delivers each event only to the consumers subscribed to it #1386 lands second still adds consumer="roadmap" to both selectors.
  • The header comment of the values file describes the mattermost receiver and its Secret, and the text alertmanager-webhook no longer appears under k8s/ or tests/. The comment above AlertmanagerNotificationsFailing and the README's self-health row name the alertmanager-mattermost Secret instead of the webhook Secret.
  • Pending a person: once the Service runs again (after D2's identity work or a reinstatement lifts replicas: 0), run check (d) per repository and lane. In Grafana's Alerting page, RoadmapServiceJobsFailing shows only for a repository and lane whose rounds have all failed for 90 minutes. Compare with sum by (repo, lane) (increase(devops_cli_service_jobs_total{result="error"}[1h])) in Prometheus.

Current references (checked at 3dd7fa6)

  • k8s/monitoring/prometheus-values.yaml:36-41: the header comment. :60-65: the alertmanager-webhook mount. :73-76: the critical|warning route. :77-82: the receivers. :442-443: the comment naming the webhook Secret. :444-445: AlertmanagerNotificationsFailing and its kube_secret_info selector.
  • k8s/monitoring/networkpolicy.yaml:147-157: public egress, on 443 and 80 only. k8s/devops/networkpolicy.yaml:25-33: the namespace-only peer shape.
  • k8s/README.md:270-281: the Receiver section, with the kubectl create secret step at :277. :245-262: the alert table, whose self-health row at :262 names the webhook Secret.
  • tests/test_k8s_monitoring_alerting.py:30-75: SERVED_SERIES. :123: test_the_baseline_rule_set. :199: the receiver test.
  • tests/test_k8s_push_secrets.py:221-235: _secret_references. :270 and :275: the guard tests.
  • src/devops_cli/server/service.py:144: the repo and lane labels. :272-274: the counter. :261-267: the error log, which carries both labels (:265).
  • src/devops_cli/config/constants.py:1060: the counter's name. :1070-1072: the lanes release, model and default. feat(release): release-please makes every release from main #1952 renamed release to status, which runs only metrics.
  • k8s/devops/roadmap-service/deployment.yaml:10-12: replicas: 0 under chore(service): the roadmap service stays at 0 replicas, and its development is blocked, while its machine account is suspended #1562. :23-25: the scrape annotations.

Dependencies and order


Problem

Checked on 2026-10-08: release/v0.2.29 at 910b823, and the cluster read-only.

  • Alerts go nowhere.
    • Critical and warning alerts go to receiver webhook. It reads its url_file from the optional Secret alertmanager-webhook (k8s/monitoring/prometheus-values.yaml:56-61, :64-78).
    • The Secret doesn't exist (kubectl -n monitoring get secret <masked-token> answers NotFound).
    • In the 7 days to 2026-10-08, Alertmanager attempted 65 webhook notifications and all 65 failed. The alerts behind them were NodeNotReady (critical), NodeRebooted and TargetDown.
    • AlertmanagerNotificationsFailing waits for the Secret to exist (:437-447), so it stayed silent.
  • The generic webhook can't post to Mattermost.
    • It sends Alertmanager's own webhook JSON. A Mattermost incoming webhook takes text, or Slack-style attachments.
    • Alertmanager v0.34.1, the running image, has mattermost_configs, with webhook_url_file and default templates (docs/configuration.md, <mattermost_config>). It reads the file on every notification.
  • This Secret is the only one made by hand.
    • The README tells a person to run kubectl create secret (k8s/README.md:257-261).
    • The guard test_every_secret_referenced_under_k8s_has_a_table_row (tests/test_k8s_push_secrets.py:270-272) never saw it. _secret_references yields only secretKeyRef, secretRef and *existingSecret (:221-235), not extraSecretMounts[].secretName.
  • There is no path to Mattermost.
  • Roadmap Service failures alert no one.
    • In the 24 h to 02:30 UTC on 2026-10-08, increase(devops_cli_service_jobs_total[24h]) gave about 105 failed rounds and 797 successful ones. About 67 of the failures were this repository's, and the six other failing repositories had about 6 each.
    • From 23:51 UTC on 2026-10-07, every round for this repository stopped on the GraphQL reserve guard: "GraphQL has N points left until HH:MM UTC, and reading board #N items costs about 11 with 250 kept in reserve, so the run stopped" (src/devops_cli/roadmap/board_read.py:247, in Loki). At 04:33 UTC it had 0 successful rounds in the last 5 hours, against about 39 failed ones. Nobody was told.
    • The counter is scraped through the pod's annotations (k8s/devops/roadmap-service/deployment.yaml:21-23).
    • No rule selects it, and SERVED_SERIES (tests/test_k8s_monitoring_alerting.py:31-75) lists none of the Service's series.

Acceptance criteria

In the gate. New tests touch no network, and each one's call phase stays under 1 s, as uv run pytest tests/test_k8s_monitoring_alerting.py tests/test_k8s_push_secrets.py tests/test_k8s_network_policies.py --durations=0 shows.

  • Receiver.

    • alertmanager.config.receivers are exactly null and mattermost.
    • mattermost has one mattermost_configs entry: webhook_url_file: /etc/alertmanager-mattermost/url, send_resolved: true, Alertmanager's default templates and an empty title_link.
    • It sets no channel and no username: the hook is locked to its channel (feat(k8s): the homelab hosts mattermost, and the cluster's alerts and argo cd deploys post to its channels #1390).
    • The critical|warning route goes to it.
    • Receiver webhook and its mount are removed.
    • test_alertmanager_sends_nowhere_until_the_webhook_secret_exists (tests/test_k8s_monitoring_alerting.py:199) checks the same for the new receiver and mount.
  • Mount. extraSecretMounts mounts Secret alertmanager-mattermost at /etc/alertmanager-mattermost, read-only and optional. So Alertmanager starts before a person has created the hook.

  • The Secret's row. The push table gains monitoring/alertmanager-mattermost, stack infra.

  • The guard sees mounted Secrets. _secret_references also yields secretName, as used in extraSecretMounts and in a volume's secret. test_a_reference_without_a_row_fails_the_guard (tests/test_k8s_push_secrets.py:275) gains a case for it.

  • Self-health. AlertmanagerNotificationsFailing reads kube_secret_info{namespace="monitoring", secret="alertmanager-mattermost"}.

  • Path.

    • The monitoring perimeter gains egress to namespace mattermost on TCP 8065, as a namespace-only peer with ports:, the shape k8s/devops/networkpolicy.yaml:25-33 explains.
    • The mattermost perimeter admits only Alertmanager's pods on 8065: one peer with namespace monitoring and pod label app.kubernetes.io/name: alertmanager.
    • tests/test_k8s_network_policies.py asserts both.
  • A rule for the roadmap Service. RoadmapServiceJobsFailing, severity warning, for: 30m:
    sum by (repo) (increase(devops_cli_service_jobs_total{result="error"}[1h])) > 0 unless on (repo) sum by (repo) (increase(devops_cli_service_jobs_total{result="success"}[1h])) > 0

  • Guide. The "Receiver" section of k8s/README.md says how to wire the channel:

    1. create the incoming webhook for alerts, with "Lock to this channel" ticked;
    2. uv run devops config set mattermost.alerts_hook;
    3. uv run devops k8s push-secrets --only monitoring/alertmanager-mattermost --context <context>.

    The kubectl create secret step is removed. The alert table gains RoadmapServiceJobsFailing. The section states the limit from feat(k8s): the homelab hosts mattermost, and the cluster's alerts and argo cd deploys post to its channels #1390: no alert arrives while Mattermost, Alertmanager or the node under either is down.

  • uv run devops pr check-readiness passes.

  • uv run devops ci passes within its 5-minute budget.

Pending a person, after merge and after #1391:

  • (a) Create the alerts hook, locked to its channel, store its key and push. Within about a minute, kubectl -n monitoring exec statefulset/prometheus-alertmanager -c alertmanager -- ls /etc/alertmanager-mattermost lists url.
  • (b) Send a test alert:
    kubectl -n monitoring exec statefulset/prometheus-alertmanager -c alertmanager -- amtool --alertmanager.url=http://localhost:9093 alert add MattermostTest severity=warning --annotation=summary=test --end=<now plus 5 minutes, RFC 3339>
    • A firing message arrives in alerts within about a minute (group_wait is 30 s).
    • A resolved message arrives within about 10 minutes.
  • (c) alertmanager_notifications_total{integration="mattermost"} has risen, and alertmanager_notifications_failed_total{integration="mattermost"} has not.
  • (d) In Grafana's Alerting page (Alertmanager datasource), RoadmapServiceJobsFailing shows only for a repository whose rounds have all failed for 90 minutes. Compare with increase(devops_cli_service_jobs_total{result="error"}[1h]) in Prometheus.

Key questions

Strategic alignment

Proposed design

Problem statement

Every Alertmanager notification has failed since the receiver points to a webhook Secret that does not exist. There is no path to Mattermost: no egress on port 8065, no native receiver configured, and no network policy allowing the traffic. Additionally, no alert rule fires when a repository's roadmap Service rounds all fail for an extended period, so a person is never told that a repository has stopped producing results.

Acceptance criteria

  • Criterion 1: The receivers list contains exactly null and mattermost. The mattermost entry has one mattermost_configs with webhook_url_file set to /etc/alertmanager-mattermost/url, send_resolved true, default templates, and empty title_link. It sets no channel and no username.
    Verification: Inspect k8s/monitoring/prometheus-values.yaml receivers section. Run uv run pytest tests/test_k8s_monitoring_alerting.py -k receiver.
  • Criterion 2: The critical and warning route points to the mattermost receiver. The old webhook receiver and its extraSecretMounts entry are removed.
    Verification: grep -r 'alertmanager-webhook' k8s/ tests/ returns no matches. The route in prometheus-values.yaml lists mattermost as its receiver.
  • Criterion 3: extraSecretMounts mounts Secret at /etc/alertmanager-mattermost, read-only and optional.
    Verification: Inspect the extraSecretMounts block in k8s/monitoring/prometheus-values.yaml. Run uv run pytest tests/test_k8s_monitoring_alerting.py -k mount.
  • Criterion 4: The push table gains a row for monitoring/alertmanager-mattermost with stack infra. The key url is a derived entry using the in-cluster base URL constant, /hooks/, and the managed option mattermost.alerts_hook.
    Verification: Run uv run pytest tests/test_k8s_push_secrets.py -k mattermost. Run uv run devops k8s push-secrets --dry-run and confirm the key appears with no value.
  • Criterion 5: The option mattermost.alerts_hook has keyring key mattermost_alerts_hook and is present in SECRET_CONFIG_OPTIONS, KEYRING_KEYS, and OPTION_TO_ENV_VAR.
    Verification: Run uv run pytest tests/test_k8s_push_secrets.py -k dry_run. Inspect src/devops_cli/config/options.py and src/devops_cli/config/env.py for the three mappings.
  • Criterion 6: _secret_references also yields secretName as used in extraSecretMounts and in a volume's secret. The guard test gains a case for this reference type.
    Verification: Run uv run pytest tests/test_k8s_push_secrets.py -k 'reference_without_a_row'. Confirm the new case passes and the old alertmanager-webhook mount no longer fails the guard.
  • Criterion 7: AlertmanagerNotificationsFailing reads kube_secret_info with namespace monitoring and secret .
    Verification: Inspect the rule in k8s/monitoring/prometheus-values.yaml. Run uv run pytest tests/test_k8s_monitoring_alerting.py -k NotificationsFailing.
  • Criterion 8: The monitoring perimeter gains egress to namespace mattermost on TCP 8065 as a namespace-only peer with ports.
    Verification: Inspect k8s/monitoring/networkpolicy.yaml for the new egress rule. Run uv run pytest tests/test_k8s_network_policies.py -k mattermost.
  • Criterion 9: The mattermost perimeter admits only Alertmanager pods on 8065: one peer with namespace monitoring and pod label app.kubernetes.io/name alertmanager.
    Verification: Inspect the mattermost network policy file. Run uv run pytest tests/test_k8s_network_policies.py -k alertmanager.
  • Criterion 10: RoadmapServiceJobsFailing rule exists with severity warning, for 30m, and the PromQL expression groups by and matches on exactly repo and lane.
    Verification: Inspect the rule in k8s/monitoring/prometheus-values.yaml. Run uv run pytest tests/test_k8s_monitoring_alerting.py -k baseline_rule_set.
  • Criterion 11: The rule summary names the repository and the lane. Its description gives the Loki query with namespace devops, repo, and lane filters.
    Verification: Inspect the summary and description fields of the rule in k8s/monitoring/prometheus-values.yaml.
  • Criterion 12: SERVED_SERIES in the test file gains devops_cli_service_jobs_total with a comment naming the scrape.
    Verification: Inspect tests/test_k8s_monitoring_alerting.py SERVED_SERIES set. Run uv run pytest tests/test_k8s_monitoring_alerting.py.
  • Criterion 13: The header comment of the values file describes the mattermost receiver and its Secret. The text alertmanager-webhook no longer appears under k8s/ or tests/.
    Verification: grep -r 'alertmanager-webhook' k8s/ tests/ returns no matches. Inspect the header comment in k8s/monitoring/prometheus-values.yaml.
  • Criterion 14: The k8s/README.md Receiver section documents the three-step wiring process and removes the kubectl create secret step. The alert table gains RoadmapServiceJobsFailing. The self-health row names the alertmanager-mattermost Secret.
    Verification: Inspect k8s/README.md Receiver section and alert table. Confirm no kubectl create secret step remains and the new rule is listed.
  • Criterion 15: The receiver test is renamed to test_alertmanager_sends_nowhere_until_the_mattermost_secret_exists and checks the new receiver and mount.
    Verification: Run uv run pytest tests/test_k8s_monitoring_alerting.py -k mattermost_secret. Confirm the old test name no longer exists.
  • Criterion 16: All new tests touch no network and each call phase stays under 1 second.
    Verification: Run uv run pytest tests/test_k8s_monitoring_alerting.py tests/test_k8s_push_secrets.py tests/test_k8s_network_policies.py --durations=0. Confirm no test exceeds 1 s in its call phase.
  • Criterion 17: uv run devops pr check-readiness passes.
    Verification: Run uv run devops pr check-readiness and confirm exit code 0.
  • Criterion 18: uv run devops ci passes within its 5-minute budget.
    Verification: Run uv run devops ci and confirm all checks pass within 300 seconds.

Key questions

  • Alertmanager's native receiver, or the generic webhook through a converter, or through the Service?: Native receiver. It is in the running version, reads its URL from a file, and formats the message. A converter adds a service to run. The Service is down while its pod restarts after each release, so it cannot act on alerts. (proposed)
  • Use default templates?: Yes, with title_link empty. They give the alert's name, summary, and description. The default title links to Alertmanager's own URL, which a browser cannot reach. A reachable link would put a homelab host in git. (proposed)
  • Why an alert for Service failures rather than a post from the Service?: Alertmanager groups alerts, repeats them every 4 hours, sends a resolution, and lets a person silence them. The Service polls every 300 seconds, so a post per failed round would mean 12 posts per hour per repository. (proposed)
  • Why this threshold, and is the rule right to fire today?: One failed round is ordinary. The rule needs an hour with no successful round, then 30 more minutes. It would fire today for this repository after more than four hours of GraphQL reserve refusals. That is a true positive: the roadmap did nothing for the repository and nobody knew. (proposed)
  • Keep the generic webhook receiver too?: No. It was a placeholder that never delivered anything. Before 1.0 the codebase keeps no leftovers. (proposed)
  • Delivery from outside the cluster?: Out of scope. See feat(k8s): the homelab hosts mattermost, and the cluster's alerts and argo cd deploys post to its channels #1390. (proposed)
  • Does the rule group by repo alone or by (repo, lane)?: By (repo, lane). Issue fix(roadmap): the service runs close and reprioritize in their own lane, so a slow model-bound intake or refine round never holds up a release #1532 gave the counter a lane label. Grouping by repo alone would let a succeeding status lane hide a model lane whose every round fails. [sources: src/devops_cli/server/service.py:144, src/devops_cli/config/constants.py:1070-1072]
  • Does the chore(service): the roadmap service stays at 0 replicas, and its development is blocked, while its machine account is suspended #1562 block apply to this item?: No. Decision D1 states that chore(service): the roadmap service stays at 0 replicas, and its development is blocked, while its machine account is suspended #1562 holds the roadmap Service's deployment only. This item changes no Service code. Its one Service touch is an alert rule on a counter the Service already emits. At 0 replicas the counter has no series, so the rule merges silent and starts evaluating when the Service runs again. (proposed) [sources: k8s/devops/roadmap-service/deployment.yaml:10-12]
  • Can check (d) run now?: No. Check (d) needs a running Service. It waits for the identity work in D2 or a reinstatement to lift replicas to 0. The merge does not wait. (proposed) [sources: k8s/devops/roadmap-service/deployment.yaml:10-12]

Open questions

Fit

Fits in one pull request.

Suspected block

Issue #1391 has not landed: no mattermost namespace, no perimeter, no derived push-table entries, and no in-cluster base URL constant exist yet.

Dependencies

#1391

Activity

  1. added
    type/feature
    scope/k8s
    scope/telemetry
    on Oct 8, 2026
  2. dan-petty-bot commented on Oct 8, 2026

    @dan-petty-bot
    Collaborator

    Intake placed this item to the backlog: at intake only a critical fix goes into a release; a release start pulls Ready items in, P0 features first.

    • Priority: P1-High. Critical alerts (NodeNotReady, TargetDown) have been silently failing for at least 7 days and 67 roadmap-service failures in 24 h went unreported, leaving the team blind to outages.
    • Effort: Medium. Spans Alertmanager config, a new Secret and mount, network-policy rules, alerting rules, the push-secrets table, and updates to several test files, but each piece is well-scoped.
  3. added
    status/blocked
    on Oct 11, 2026
  4. dan-petty commented on Oct 11, 2026

    @dan-petty
    OwnerAuthor

    Blocked by #1562: the roadmap Service's machine account is suspended, and the Service is held at 0 replicas. This item develops the Service or can only be checked on it, so it waits until the account is reinstated or the jobs act as a GitHub App.


    Generated by Claude Code

  5. dan-petty commented on Oct 26, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones on the board.

    • Priority: P2-Medium. The item is important but not urgent and requires other dependencies.
    • Value: High. The change improves monitoring and alerting which is valuable to the project.
    • Effort: Medium. The effort involves multiple components including alert rules, secret handling, and service deployment.
    • Possible duplicate: feat(roadmap): the roadmap service posts each release cut, ship and start to mattermost's releases channel #1394, which may ask for the same change. The model names alertmanager posts critical and warning alerts to mattermost's alerts channel as the change that both ask for. Both items ask for alertmanager to post alerts to mattermost's alerts channel, but item 1394 is about releases and this item is about jobs failing. A person closes one of the two if that is so.
  6. dan-petty commented on Oct 28, 2026

    @dan-petty
    OwnerAuthor

    Refine cannot set this item to Ready at d509dba until a person answers the questions below. Reply in a comment or edit the body, and the next refine round looks at the item again.

  7. added
    priority/p2-medium
    status/new
    effort/medium
    value/high
    and removed
    status/blocked
    on Oct 28, 2026
  8. removed
    status/new
    on Oct 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/mediumpriority/p2-mediumscope/k8sscope/telemetrytype/featurevalue/high

    Type

    No type

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions