> For the complete documentation index, see [llms.txt](https://developer.harness.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.harness.io/service-reliability-management/use-srm/manage-slo/automated-deployment-rollback.md).

# Automated Deployment Rollbacks

Harness Service Reliability Management (SRM) allows you to configure Service Level Objectives (SLOs) to automatically rollback deployments when predefined conditions are breached (e.g., exceeding your error budget). This feature helps maintain service reliability by quickly reverting problematic deployments before they significantly impact your users.

With SLO-driven automated rollbacks, you can:

* Automatically roll back deployments when predefined conditions are breached
* Prevent service degradation by quickly reverting to a stable version
* Maintain error budgets by minimizing the impact of failed deployments
* Implement progressive delivery practices with safety mechanisms

This topic explains how to configure automated deployment rollbacks based on SLO violations in your Harness pipelines.

### Prerequisites <a href="#prerequisites" id="prerequisites"></a>

Before configuring automated deployment rollbacks with SLOs, ensure you have:

* [Configured your CD service](/continuous-delivery/use-continuous-delivery/cd-building-blocks/services/services-overview.md). Set up your CD service and provide the necessary deployment configuration.

Here is an example of a sample NGINX Kubernetes Deployment:

![NGINX Kubernetes Deployment](/files/OmwcfFxH5B2D0BE7nYKw)

![NGINX in Service definition](/files/gd8VxDISAFNC1bUQ2EVB)

* [Set up your CD Environment and Infrastructure](/continuous-delivery/use-continuous-delivery/cd-building-blocks/environments/create-environments.md). Create the required environment and configure the underlying infrastructure for that environment.

  ![CD Environment](/files/rPf2SgbtWonMJyLnsXlu)
* Set up your **Deployment Pipeline**. Utilize the previously created CD service and environment to configure your deployment pipeline.

  ![CD Pipeline](/files/4Nhm9dAp5IXbSqdjL5JE)

### Configure automated rollbacks with SLOs <a href="#configure-automated-rollbacks-with-slos" id="configure-automated-rollbacks-with-slos"></a>

To set up automated rollbacks with SLOs, follow these steps:

#### Step 1: Setup a monitored service <a href="#step-1-setup-a-monitored-service" id="step-1-setup-a-monitored-service"></a>

Create a monitored service using service and environment pair created above. For more information, see [Create a monitored service](/service-reliability-management/use-srm/monitored-services/create-monitored-service.md).

![Setup monitored service](/files/NpaCLMRnwUrMdBp3W4Fz)

#### Step 2: Configure health source <a href="#step-2-configure-health-source" id="step-2-configure-health-source"></a>

1. Define a [health source](/service-reliability-management/use-srm/monitored-services/health-source/prometheus.md) for your monitored service. Here's an example of how to configure a Prometheus query:

![Configure health source](/files/qDvwKGFOGFO5lv2PcN6I)

2. Assign SLIs to the health source by mapping the metrics to service level indicators:

<figure><img src="/files/QBrsON0eZPnd14biWWvp" alt=""><figcaption></figcaption></figure>

#### Step 3: Set up SLO <a href="#step-3-set-up-slo" id="step-3-set-up-slo"></a>

[Configure your SLO](/service-reliability-management/use-srm/slo-types/request-based-slo.md) using the monitored service and the Prometheus metric you've set up.

<figure><img src="/files/BCRVYbwmK3R4UvRMOqEc" alt=""><figcaption></figcaption></figure>

### Setup the rollback policy <a href="#setup-the-rollback-policy" id="setup-the-rollback-policy"></a>

As part of your error budget policy, you can add a rollback policy.

To set up the rollback policy:

* Create a new **notification rule**.
* Select **Rollback Deployment** as the **Notification Method**.
* Specify the **Rollback Window**. This defines the valid time frame between a recent deployment and an SLO condition breach during which an automatic rollback will be triggered.
* Provide the **Environment** and **Infrastructure** details.

  <div data-gb-custom-block data-tag="hint" data-style="info" class="hint hint-info"><p>Providing the correct <strong>Environment</strong> and <strong>Infrastructure</strong> is crucial for a successful rollback.</p></div>

  ![Setup rollback policy](/files/cpaMUgHJS0dRL18z9S27)
* Create new notification rule, and select the Notification Method as **Rollback Deployment**, provide the rollback Window, this determines the validity of rollback if the SLO breaches the given condition. Provide the environment and Infrastructure.

  ![New notification rule](/files/noq13IjiZzJVguwQuCJC)

  <div data-gb-custom-block data-tag="hint" data-style="info" class="hint hint-info"><p>Providing correct Environment/Infrastructure is important to carry out the rollback successfully.</p></div>

#### Verifying rollback <a href="#verifying-rollback" id="verifying-rollback"></a>

If everything is configured correctly and your SLO notification conditions are met, you will observe that the deployment has been automatically rolled back.

![Verify Rollback](/files/DGbBMFhwzPS7BKoruDTx)

### Related Content <a href="#related-content" id="related-content"></a>

For more information about SLOs and verification, see [Create and manage SLOs](/service-reliability-management/new-to-srm/get-started/create-first-slo.md) and [Verification overview](/continuous-delivery/use-continuous-delivery/verify-deployments/verify-deployments-with-the-verify-step.md).

FEEDBACK\_BUTTON
