Alerting on the DigitalOcean and NUC clusters
Last updated: 2026-07-07 Author: Castis Ops Scope: VictoriaMetrics stack (vmagent, vmalert, vmalertmanager, vmsingle/vmcluster) alerting and metrics pipeline fixes across two clusters.
1. Overview¶
Two separate Kubernetes clusters run the victoria-metrics-k8s-stack Helm chart for metrics and alerting:
| Cluster | Context | Chart Version | Cluster Label |
|---|---|---|---|
| Public / Production | ubuntu-mashup-gitlab-haproxy (DigitalOcean, HA) |
victoria-metrics-k8s-stack-0.63.3 |
digital-ocean-cluster |
| Private / NUC | NUC-B (on-prem, single-node style) |
victoria-metrics-k8s-stack-0.59.3 |
nuc-cluster |
Both clusters had non-functional or dead-end alerting — alerts were firing internally but never reaching a human. This work fixed email delivery, added cluster/node identification to alerts, and cleaned up configuration drift so fixes survive future deployments.
2. Initial Problem: VerneMQ Investigation (Public/DO context, separate cluster)¶
Before the alerting work, a related investigation covered a different cluster (playtelly-iac, k3s nodes nuc-a/nuc-b/castis-desktop/mac-mini) running VerneMQ:
- Symptom: Recurring
vmq_swc_exchangesupervisor crashes andnot_readycluster-connect warnings forvernemq-1. - Root cause:
vernemq-1periodically became unreachable to other cluster nodes (likely pod restarts/rejoin timing), causing metadata-sync (SWC) workers to crash and restart repeatedly. - Resolution: Confirmed via
vmq-admin cluster showthat all three VerneMQ nodes were healthy and running — the flapping was transient and self-healed. - Side finding: A separate
erl_stdlib_errorscrash was traced to a malformedvmq-admin cluster join/showCLI command run by a colleague — unrelated to any external data push, purely a CLI parsing issue. - Node resource check:
kubectl top nodesshowed high memory % (80-86%) onnuc-a/nuc-b, butMemoryPressure: Falseon both nodes confirmed this was normal steady-state load, not a crisis. - Separate restart-storm finding: Longhorn CSI plugin (515 restarts) and VictoriaMetrics operator (329 restarts) pods had very high restart counts, but exit codes (255/Unknown, 2, 1) confirmed these were not OOM kills — a separate, lower-priority stability issue to monitor.
3. Alertmanager — Public (DigitalOcean) Cluster¶
3.1 Problem found¶
# Original live config (via raw secret, later found to be Helm-managed)
receivers:
- name: default
- name: critical
- name: warning
email_configs — alerts were routed correctly by severity but silently dropped with nowhere to go.
3.2 Root cause of "config not persisting"¶
Initial fix was applied via kubectl apply directly to the Secret. This did not persist — the VMAlertmanager CR's configSecret is Helm-managed (meta.helm.sh/release-name: vm-stack), so the secret is regenerated from helm get values on every helm upgrade, silently reverting manual edits.
3.3 Correct fix — persisted via Helm values¶
Final alertmanager.config block (applied via helm upgrade -f <values-file>):
alertmanager:
config:
global:
resolve_timeout: 5m
smtp_smarthost: 'smtp.gmail.com:587'
smtp_from: '<ALERTS_SENDER_GMAIL>'
smtp_auth_username: '<ALERTS_SENDER_GMAIL>'
smtp_auth_password: '<ROTATED_APP_PASSWORD>'
smtp_require_tls: true
smtp_hello: 'gmail.com'
route:
group_by: ['alertname', 'cluster', 'service']
group_interval: 10s
group_wait: 10s
receiver: null-receiver
repeat_interval: 12h
routes:
- continue: true
match: { severity: critical }
receiver: critical
- match: { severity: warning }
receiver: warning
receivers:
- name: null-receiver # catches info/none/unlabeled — no email sent
- name: critical
email_configs:
- to: '<ALERTS_RECIPIENT_EMAIL>'
send_resolved: true
headers:
Subject: ' [CRITICAL] {{ .GroupLabels.alertname }} Cluster: {{ .GroupLabels.cluster }} | {{ .GroupLabels.service }}'
html: |
<h2 style="color:#cc0000"> Critical Alert</h2>
{{ range .Alerts }}
<p><b>Alert:</b> {{ .Labels.alertname }}<br>
<b>Cluster:</b> {{ .Labels.cluster }}<br>
<b>Node:</b> {{ if .Labels.node }}{{ .Labels.node }}{{ else }}{{ .Labels.instance }}{{ end }}<br>
<b>Summary:</b> {{ .Annotations.summary }}<br>
<b>Severity:</b> {{ .Labels.severity }}<br>
<b>Started:</b> {{ .StartsAt }}</p><hr>
{{ end }}
- name: warning
email_configs:
- to: '<ALERTS_RECIPIENT_EMAIL>'
send_resolved: true
headers:
Subject: ' [WARNING] {{ .GroupLabels.alertname }} Cluster: {{ .GroupLabels.cluster }} | {{ .GroupLabels.service }}'
html: |
<h2 style="color:#e6a817"> Warning Alert</h2>
{{ range .Alerts }}
<p><b>Alert:</b> {{ .Labels.alertname }}<br>
<b>Cluster:</b> {{ .Labels.cluster }}<br>
<b>Node:</b> {{ if .Labels.node }}{{ .Labels.node }}{{ else }}{{ .Labels.instance }}{{ end }}<br>
<b>Summary:</b> {{ .Annotations.summary }}<br>
<b>Severity:</b> {{ .Labels.severity }}<br>
<b>Started:</b> {{ .StartsAt }}</p><hr>
{{ end }}
Design decisions:
- Only critical and warning severities generate email. info, none, and unlabeled alerts route to null-receiver (matched, acknowledged internally, but no notification sent).
- Subject line includes cluster and service so the source is identifiable without opening the email.
- Email body includes node with fallback to instance if the node label isn't present on a given alert.
3.4 Cluster identification label¶
vmagent:
spec:
externalLabels:
cluster: digital-ocean-cluster # renamed from "k3s-ha"
environment: production
cluster="k3s-ha" value is not retroactively relabeled. Any dashboards/queries filtering on the old value need updating.
3.5 Apply method¶
helm repo add victoria-metrics https://victoriametrics.github.io/helm-charts/
helm repo update
helm upgrade vm-stack victoria-metrics/victoria-metrics-k8s-stack \
-n monitoring --version 0.63.3 \
-f services/monitoring/vm-alert/Do/vm-stack-values.yaml
3.6 Post-apply gotcha¶
After helm upgrade, vmalertmanager pods (3 replicas) restarted automatically and picked up the config. vmagent pods did not restart automatically for the externalLabels change — required a manual:
kubectl rollout restart deployment -n monitoring vmagent-vm-stack-victoria-metrics-k8s-stack-0
kubectl rollout restart deployment -n monitoring vmagent-vm-stack-victoria-metrics-k8s-stack-1
4. Alertmanager — Private (NUC) Cluster¶
4.1 Problem found¶
Every alert routed to a dead webhook pointing atlocalhost:5001 inside the Alertmanager pod itself — nothing was listening there. All alerts fired into a void with no error surfaced.
4.2 Correct fix — same email pattern as public cluster¶
Same alertmanager.config structure as Section 3.3, applied via Helm values this time (not raw kubectl apply, which was the initial — non-persistent — attempt).
4.3 Cluster identification label¶
(This cluster had noexternalLabels set at all previously — added fresh, not renamed.)
4.4 Configuration drift discovered mid-fix¶
Before applying via Helm, a live-vs-Helm-values diff revealed significant prior drift on this cluster — fields changed directly via kubectl that were never reflected in Helm values. Applying the "naive" values file (based on original Helm values alone) would have reverted working production behavior. Drift found and preserved:
vmagent:
| Field | Original Helm values | Actual live (kept) |
|---|---|---|
| remoteWrite | https://vm.castis.io/api/v1/write + basicAuth | http://vmsingle-...:8428/api/v1/write (local, no auth) |
| extraArgs | none | promscrape.dropOriginalLabels, promscrape.streamParse |
| staticScrapeConfigs (apisix) | present | removed — confirmed redundant; Apisix already covered by a proper VMServiceScrape (apisix-monitoring in monitoring namespace, using auto-discovery + correct /apisix/prometheus/metrics path) |
vmalert:
| Field | Original Helm values | Actual live (kept) |
|---|---|---|
| evaluationInterval | not set | 20s |
| extraArgs | none | external.alert.source, external.url, http.pathPrefix, remoteWrite.disablePathAppend |
| notifiers | not set | points to vmalertmanager-...-0 |
| remoteRead/remoteWrite | not set | local vmsingle |
4.5 Bug found and fixed: vmalert querying wrong datasource¶
vmalert.spec.datasource was still pointing at the external https://vm.castis.io (with basicAuth), while vmagent had already been switched to write metrics locally to vmsingle. This meant vmalert was evaluating alert rules against a datasource that was no longer receiving fresh data from this cluster — alerts may not have been firing correctly at all.
Fix:
vmalert:
spec:
datasource:
url: http://vmsingle-vm-stack-victoria-metrics-k8s-stack.monitoring.svc.cluster.local:8428
# basicAuth removed — not needed for in-cluster endpoint
4.6 Helm template rendering bug and fix¶
First upgrade attempt failed:
Cause:vmalert.spec.extraArgs.external.alert.source contains vmalert's own Go template syntax ({{ .Expr|jsonEscape|queryEscape }}), meant to be evaluated by vmalert at runtime — but Helm's tpl function tried to evaluate it during chart rendering and failed since those functions don't exist in Helm's context.
Fix — escape the braces so Helm treats them as literal text:
external.alert.source: explore?left={"datasource":"VictoriaMetrics","queries":[{"expr":{{"{{"}} .Expr|jsonEscape|queryEscape {{"}}"}},"refId":"A"}],"range":{"from":"{{"{{"}} .ActiveAt.UnixMilli {{"}}"}}","to":"now"}}
4.7 Duplicate notifiers bug and fix¶
After first successful upgrade, vmalert's rendered notifiers list showed the same Alertmanager URL twice — the chart auto-generates one notifier (since alertmanager.enabled: true) and our manually-specified one in values got appended on top.
Fix: removed the manual notifiers: key from values entirely, letting the chart's own auto-wiring handle it (single entry, matching original pre-drift behavior).
4.8 Apply method¶
helm repo add victoria-metrics https://victoriametrics.github.io/helm-charts/
helm repo update
helm upgrade vm-stack victoria-metrics/victoria-metrics-k8s-stack \
-n monitoring --version 0.59.3 \
-f services/monitoring/vm-alert/nuc/vm-stack-values.yaml
4.9 vmagent restart required¶
Same as public cluster — vmagent's externalLabels change required a manual rollout restart to take effect (config-reload alone did not apply it):
5. VMSingle — Full Configuration Record (NUC Cluster)¶
Investigated separately after noticing resources was missing from kubectl get vmsingle -o yaml output.
5.1 Finding¶
The resources field (limits 1200m/1500Mi, requests 150m/500Mi) is actually applied and enforced — confirmed on the running pod/Deployment — but does not echo back in the CR's own spec: output on this operator version. The CR-level omission is a display quirk, not a real gap.
5.2 Source of the resource sizing: useDefaultResources¶
Traced to a CRD-level field, not Helm or user config:
CRD: vmsingles.operator.victoriametrics.com
Field: useDefaultResources (boolean, defined in CRD schema)
Description: "UseDefaultResources controls resource settings.
By default, operator sets built-in resource requirements"
useDefaultResources defaulting to true
2. Operator's controller reads this at reconcile time
3. Since no explicit resources: was set by the user/Helm, the operator injects its own built-in preset directly into the generated Deployment
This is standard operator behavior, not a bug. Applies to all VM component types (VMSingle, VMAgent, VMAlert, VMAlertmanager, etc.) unless explicitly overridden with a resources: block in values.
5.3 vmalert.proxyURL — already correctly configured¶
extraArgs:
vmalert.proxyURL: http://vmalert-vm-stack-victoria-metrics-k8s-stack.monitoring.svc.cluster.local.:8080
vmsingle as a proxy — no separate reverse-proxy setup needed. Correct namespace (monitoring) and service name confirmed. No changes required — already working correctly (found to be pre-existing, not something this session configured).
5.4 Storage¶
- PVC:
vmsingle-vm-stack-victoria-metrics-k8s-stack, 20Gi,storageClassName: longhorn-retain(note: differs from plainlonghornused by most other PVCs in this cluster — likely intentional for data retention on deletion, worth confirming).
5.5 Open items (not yet actioned)¶
retentionPeriod: "1"(1 day) — short for production; consider extending if historical/incident review data is needed.vmsingleconfig is not yet persisted in the Helm values file — currently running on a mix of chart defaults + un-persisted drift (same risk pattern found and fixed forvmagent/vmalert). A ready-to-use values block was drafted but not yet applied:vmsingle: enabled: true spec: retentionPeriod: "1" extraArgs: vmalert.proxyURL: http://vmalert-vm-stack-victoria-metrics-k8s-stack.monitoring.svc.cluster.local.:8080 resources: limits: { cpu: 1200m, memory: 1500Mi } requests: { cpu: 150m, memory: 500Mi } storage: accessModes: [ReadWriteOnce] resources: requests: { storage: 20Gi } storageClassName: longhorn-retain
6. Data Retention Reference¶
| Cluster | retentionPeriod |
Notes |
|---|---|---|
| Public (DO) | 1d (vmcluster.spec.retentionPeriod) |
Very short for production; extending significantly increases vmstorage disk usage (current PVC: 7Gi/replica) |
| Private (NUC) | "1" (day, vmsingle.spec.retentionPeriod) |
Same short-retention pattern |
Important distinction: retention controls how long raw metrics data is stored/queryable. It does not affect whether an alert notification is sent — that's controlled purely by Alertmanager routing (Section 3.3/4.2). Silencing info-severity alerts from email does not stop them from being evaluated or stored; they remain visible via Alertmanager's own UI/API until the retention window rolls them off.
7. Verification Commands Reference¶
# Confirm Alertmanager's live config (either cluster)
kubectl exec -n monitoring vmalertmanager-vm-stack-victoria-metrics-k8s-stack-0 -c alertmanager \
-- wget -qO- http://localhost:9093/api/v2/status | jq '.config.original'
# Send a test alert
kubectl exec -n monitoring vmalertmanager-vm-stack-victoria-metrics-k8s-stack-0 -c alertmanager \
-- wget -qO- --header="Content-Type: application/json" \
--post-data='[{"labels":{"alertname":"TestAlert","severity":"critical","service":"test","cluster":"<cluster-name>","node":"test-node"},"annotations":{"summary":"Test"}}]' \
http://localhost:9093/api/v2/alerts
# Confirm externalLabels applied
kubectl get vmagent -n monitoring -o yaml | grep -A3 externalLabels
kubectl get vmalert -n monitoring -o yaml | grep -A3 externalLabels
# Safety diff before any helm upgrade — always run this first
helm get values vm-stack -n monitoring > /tmp/current-values.yaml
diff /tmp/current-values.yaml <path-to-new-values-file>
8. Outstanding Action Items¶
- ** Rotate the Gmail app password.** It was pasted in plaintext multiple times across chat/terminal output during this work and must be rotated before (or immediately after) the values files are committed to git, since git history retains it permanently otherwise.
- Confirm Grafana's datasource (both clusters) points at the correct local metrics source (
vmsingle/vmselect) rather than any stale external endpoint — not yet fully verified for the NUC cluster's Grafana instance. - Decide whether to persist
vmsingleconfig into Helm values on the NUC cluster (Section 5.5) to prevent future drift loss. - Decide whether to extend
retentionPeriodon either cluster for better historical/incident data (Section 6). - Investigate the separate Longhorn CSI / VictoriaMetrics-operator restart-storm finding from Section 2 (515 / 329 restarts) — confirmed not memory-related, root cause not yet identified.
- Commit both values files to
playtelly-iacgit repo so fixes survive futurehelm upgrade/ ArgoCD syncs: services/monitoring/vm-alert/Do/vm-stack-values.yaml(public/DO cluster)services/monitoring/vm-alert/nuc/vm-stack-values.yaml(private/NUC cluster)