4 min read

Auto Remediation 101

Auto Remediation 101
Photo by Jefferson Santos / Unsplash

Have you ever been on call and you get woken up by the same alert, an alert that you can't do anything about it, and the only way to make it go away is to restart the system responsible.

Auto remediation is an approach that SREs apply for these types of alerts and many other different ones. it makes our life easier, and it helps us focus on more critical tasks. Auto remediation is the process of automatically identifying and resolving issues in software systems without human intervention. It enables our systems to self-heal and recover from failures, minimizing downtime and ensuring continuous operation.

In this blog post, we'll explore what auto remediation is, its benefits, and how to implement it effectively.

What is Auto Remediation?

Auto remediation refers to the automated process of identifying and resolving issues in software systems without human intervention. It ensures that systems stays up and have a smooth continuous operation through auto recovering from failures.

Common Scenarios for Auto Remediation

Auto remediation can be applied to various scenarios, including:

  • Infrastructure failures: Automatically provisioning backup resources or restarting failed components.
  • Application errors and exceptions: Identifying and resolving common application issues.
  • Security vulnerabilities: Automatically patching known vulnerabilities.
  • Performance issues: Dynamically scaling resources based on workload.

Benefits of Auto Remediation

Implementing auto remediation offers several benefits:

  • Faster recovery times: Issues are resolved quickly, minimizing downtime.
  • Reduced manual intervention: Automated remediation reduces the need for manual troubleshooting.
  • Improved system reliability and availability: Systems become more resilient and self-healing.
  • Cost savings: Automated remediation reduces the cost associated with manual intervention and downtime.

Key Components of an Auto Remediation System

An effective auto remediation system consists of the following components:

  1. Monitoring and Alerting: Continuously monitor system metrics and logs to detect anomalies and trigger alerts.
    1. For example tools like Prometheus and AlertManger.
  2. Incident Detection and Analysis: Analyze alerts and correlate data to identify the root cause of incidents.
  3. Remediation Policies and Rules: Define a set of predefined policies and rules to determine the appropriate remediation actions.
  4. Automation and Orchestration Tools: Utilize automation tools to execute remediation actions and orchestrate the overall process.

Here's a simple example of a remediation webhook for AlertManager using Golang:

package main

import (

type AlertMessage struct {
    Alerts []Alert `json:"alerts"`

type Alert struct {
    Status      string            `json:"status"`
    Labels      map[string]string `json:"labels"`
    Annotations map[string]string `json:"annotations"`
    StartsAt    time.Time         `json:"startsAt"`
    EndsAt      time.Time         `json:"endsAt"`

func handleWebhook(w http.ResponseWriter, r *http.Request) {
    if r.Method != http.MethodPost {
        http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)

    var alertMessage AlertMessage
    err := json.NewDecoder(r.Body).Decode(&alertMessage)
    if err != nil {
        http.Error(w, "Invalid request payload", http.StatusBadRequest)

    for _, alert := range alertMessage.Alerts {
        if alert.Status == "firing" {
            if alert.Labels["alertname"] == "HighCPUUsage" || alert.Labels["alertname"] == "HighMemoryUsage" {
                duration := time.Since(alert.StartsAt)
                if duration >= 30*time.Minute {
                    nodeName := alert.Labels["instance"]


func restartNode(nodeName string) {
    // Implement the logic to restart the node based on the nodeName
    fmt.Printf("Restarting node: %s\n", nodeName)
    // ...

func main() {
    http.HandleFunc("/webhook", handleWebhook)
    fmt.Println("Webhook server is running on :8080")
    http.ListenAndServe(":8080", nil)

In this code:

  1. We define the necessary structs (AlertMessage and Alert) to represent the JSON payload received from Alertmanager.
  2. The handleWebhook function is the HTTP handler for the webhook endpoint. It expects a POST request with the alert payload.
  3. We decode the JSON payload into the AlertMessage struct.
  4. We iterate over each alert in the Alerts array.
  5. For each alert, we check if the alert status is "firing" and if the alert name is either HighCPUUsage or HighMemoryUsage.
  6. If the alert has been firing for at least 30 minutes (we can adjust the duration as needed), we extract the instance label, which represents the node name.
  7. We call the restartNode function, passing the node name as an argument. This function should contain the logic to restart the node (e.g., making an API call to a cloud provider or executing a system command).
  8. Finally, we set up the webhook server to listen on port 8080 and handle incoming requests.

To use this webhook, we need to configure Alertmanager to send alerts to the webhook URL (e.g., http://your-server:8080/webhook) when the specified conditions are met.

Implementing Auto Remediation

To implement auto remediation effectively:

  1. Identify critical systems and failure scenarios.
  2. Define remediation workflows and playbooks.
  3. Select appropriate automation tools and technologies.
  4. Test and validate auto remediation processes.
Auto remediation steps
Auto remediation steps

By following these guidelines and leveraging the power of automation, we can build resilient and self-healing software systems that minimize downtime and ensure optimal performance.


Auto remediation is crucial for every engineer that run and operate systems. It empowers SREs to focus on more strategic tasks while ensuring the reliability and availability of software systems. Keep in mind that you should continuously refine and optimize your processes to build truly resilient and self-healing systems.