Limiting Portainer-related alerts to actionable events without notification noise
0 reputation · 04 Mar 2022, 13:11 UTC
0 reputation · 04 Mar 2022, 13:11 UTC
We manage several Docker hosts through Portainer CE and want alerting on container and endpoint health. Since CE has no built-in notification engine, we plan to use external tooling (Prometheus/Alertmanager or a lightweight health-check script polling the Portainer API) against the same endpoints Portainer already inventories.
The unresolved decision is severity mapping. Alerting on every container start/stop would flood us given frequent deployments, but we are unsure which state changes are genuinely actionable: non-zero exits, restart loops, sustained unhealthy status, agent/endpoint down, and host resource thresholds all seem candidates, yet the line between self-healing noise and page-worthy events is unclear.
Which container and endpoint events do you treat as page-worthy versus log-only in a Portainer-managed fleet? Is polling the Portainer API for endpoint/container status a reasonable low-volume health check, or is scraping Docker events/cAdvisor metrics strictly better? What deduplication or grouping strategy keeps restart-loop alerts to a single notification?
To avoid notification fatigue in a Portainer CE environment, distinguish between state changes (which are often expected during deployments) and failure states (which require human intervention). Treat the following as the baseline for your alerting logic:
| Event Type | Severity | Action |
|---|---|---|
| Non-zero Exit Code | Critical/Page | Investigate crash logs immediately. |
| Sustained Unhealthy Status | Warning/Page | Check application health check endpoints. |
| Agent/Endpoint Down | Critical/Page | Verify host connectivity and Portainer Agent status. |
| Host Resource Thresholds | Warning | Scale resources or optimize container limits. |
| Container Start/Stop | Info/Log | Audit trail only; ignore during deploy windows. |
| Single Restart | Info/Log | Allow Docker's restart policy to handle self-healing. |
Polling the Portainer API is reasonable for inventory discovery (e.g., finding which containers exist on which endpoint), but it is inefficient for high-frequency health monitoring. For actionable alerting, scraping cAdvisor or direct Docker engine metrics is strictly better for three reasons:
container_restarts_total and memory/CPU spikes that the Portainer API does not expose in real-time.To prevent a flapping container from paging your team repeatedly, move the logic from the event level to the metric level. Instead of alerting on a "Stop" event, alert on the rate of change of restarts.
If using Prometheus and Alertmanager, implement the following strategy:
increase(container_restarts_total[15m]) > 5. This ensures you only page when a container is in a genuine restart loop, not a single crash.group_by: ['alertname', 'container_name', 'instance']. This collapses multiple alerts for the same container into a single notification.group_wait (e.g., 30s) to allow multiple related events to batch together before the first notification is sent.Missing Diagnostic: Are your containers using custom Docker HEALTHCHECK instructions in their Dockerfiles, or are you relying solely on the container process remaining active?
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.