---
title: "Configure auto-apply | Grafana Cloud documentation"
description: "Configure auto-apply Note Auto-apply is currently in public preview. Grafana Labs offers limited support, and breaking changes might occur prior to the feature being made generally available."
---

# Configure auto-apply

> Note
> 
> Auto-apply is currently in [public preview](/docs/release-life-cycle/). Grafana Labs offers limited support, and breaking changes might occur prior to the feature being made generally available.

Auto-apply automatically applies recommendations for you, eliminating manual effort and enabling your environment to be continuously fine-tuned for optimal cost and observability outcomes. Auto-apply optionally works with segmentation; subdivide your recommendations to manage on a per-team basis, and choose to auto-apply at a segment level.

> Note
> 
> It is recommended to use the Exemptions feature before turning on auto-apply, to ensure any critical metrics are not aggregated inadvertently.

## Auto-apply workflow

Enable auto-apply using the UI by updating the default segment. As a result, rule recommendations are applied without requiring any manual review or approval.

If you are using segmentation, you can enable auto-apply on a per-segment basis or edit existing segments to enable auto-apply.

1. Update the default segment to enable auto-apply.
   
   If using segmentation, you can add a segment or edit an existing segment to enable auto-apply.
2. The system analyzes the metrics within the specific segment and generates optimization recommendations based on the analysis.
3. The system automatically applies the recommendations.

> Note
> 
> Custom rules remain unchanged when you enable auto-apply. Auto-apply keeps all existing custom rules and does not modify or remove them.
> 
> Custom rules include affix (prefix/suffix) and drop rules. You cannot create new custom rules after you enable auto-apply.

> Warning
> 
> Be careful when customizing exact-match aggregation rules. If not explicitly exempted, exact-match rules may be automatically removed or replaced. To ensure your custom rule remains active, always include disable\_recommendations: true.

## Enable auto-apply using the UI

Enable auto-apply through the Grafana user interface, which provides you with a more visual way of managing auto-apply. It is the recommended way for initial set up and smaller organizations and it is also easier to make free-form adjustments.

### From the Overview page

You can enable auto-apply directly from the **Overview** page without navigating to the **Segments** page.

1. Navigate to **Adaptive Metrics**.
2. On the **Overview** page, click **Enable auto-apply** next to the **Segment** dropdown.
3. Select the segments you want to enable auto-apply for.
4. Click **Apply**.

You are also prompted to enable auto-apply after applying all recommendations. This prompt lets you enable auto-apply for the current segment so that future recommendations are applied automatically.

### Default or existing segments

To enable auto-apply for the default segment or an existing segment from the **Segments** page, complete the following steps.

1. Navigate to **Adaptive Metrics**.
2. Navigate to the **Segments** page.
3. Click the **Edit** icon next to the segment you want to enable auto-apply for.
4. Select the **Enable auto-apply** checkbox.
5. Click **Save**.
   
   In the Segments list, you can view your new segment and whether auto-apply is enabled.

### New segments

To enable auto-apply for new segments, complete the following steps.

1. Navigate to **Adaptive Metrics**.
2. Navigate to the **Segments** page.
3. Click **Add new segment**.
   
   Fill out the details for the new segment.
4. Select the **Enable auto-apply** checkbox.
5. Click **Add**.
   
   In the Segments list, you can view your new segment and whether auto-apply is enabled.
   
   From the **Rules** page, you can search for a segment and see whether auto-apply is enabled.

## Enable auto-apply using the API

Enable auto-apply using the API. This is useful for automation, version control and scalability for managing a large number of teams and integrating with existing as-code practices.

The auto-apply feature can be turned on and off on a per segment basis. This allows you to turn it on for segments where you are confident that you want to apply all recommendations and leave it turned off for other segments.

The `default` segment always exists, even without a custom segment and is configured using the main recommendations configuration.

### Configure the default segment

1. Go to the `/aggregations/recommendations/config` endpoint.
2. Set the `enabled` property to true.

![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```none
# Get the current config
% curl -s -u '<user>:<key>' 'https://<prom URL>/aggregations/recommendations/config' | jq '.'
{
  "keep_labels": [],
  "auto_apply": {
    "enabled": false
  }
}

# Enable auto-apply
curl -s -u '<user>:<key>' 'https://<prom URL>/aggregations/recommendations/config' -X POST -d '{
	"keep_labels": [],
	"auto_apply": {
        "enabled": true
	}
}'

# Verify the updated setting
% curl -s -u '<user>:<key>' 'https://<prom URL>/aggregations/recommendations/config' | jq '.'
{
  "keep_labels": [],
  "auto_apply": {
    "enabled": true
  }
}
```

### Configure custom segments

Configure auto-apply on a per-segment basis using the segment configuration endpoint.

1. Go to the `/aggregations/rules/segments` endpoint.
2. Set the `enabled` property to true.

![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```none
# Get the current config to lookup ID of segment
% curl -s -u '<user>:<key>' 'https://<prom URL>/aggregations/rules/segments' | jq '.'
[
  {
    "id": "01JTRP8G515JA77KD7K7ABFEKQ",
    "name": "Team1",
    "selector": "{team=\"team1\"}",
    "auto_apply": {
      "enabled": false
    }
  }
]

# Enable auto-apply on the segment with ID 01JTRP8G515JA77KD7K7ABFEKQ
% curl -s -u '<user>:<key>' 'https://<prom URL>/aggregations/rules/segments?segment=01JTRP8G515JA77KD7K7ABFEKQ' -X PUT -d '{
    "id": "01JTRP8G515JA77KD7K7ABFEKQ",
    "name": "Team1",
    "selector": "{team=\"team1\"}",
    "auto_apply": {
      "enabled": true
    }
}'

# Verify updated setting
% curl -s -u '<user>:<key>' 'https://<prom URL>/aggregations/rules/segments' | jq '.'
[
  {
    "id": "01JTRP8G515JA77KD7K7ABFEKQ",
    "name": "Team1",
    "selector": "{team=\"team1\"}",
    "auto_apply": {
      "enabled": true
    }
  }
]
```

## Enable auto-apply using Terraform

Manage auto-apply as part of your infrastructure-as-code strategy using the `grafana-adaptive-metrics` Terraform provider.

The auto-apply feature can be turned on and off on a per segment basis. This allows you to turn it on for segments where you are confident that you want to apply all recommendations and leave it turned off for other segments.

### Configure the default segment

Configure the default segment in the recommendations configuration object. The exact format is documented in the [Terraform registry](https://registry.terraform.io/providers/grafana/grafana-adaptive-metrics/latest/docs/resources/recommendations_config#example-usage).

The following is an example configuration, which enables auto-apply in the default segment.

![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```none
resource "grafana-adaptive-metrics_recommendations_config" "default" {
  auto_apply = {
    enabled = true
  }
}
```

### Configure custom segments

To configure the auto-apply feature for custom segments, add the configuration to the segment resources. The exact format is documented in the [Terraform registry](https://registry.terraform.io/providers/grafana/grafana-adaptive-metrics/latest/docs/resources/recommendations_config#example-usage).

The following is an example configuration, which enables auto-apply in the segment `team1`.

![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```none
resource "grafana-adaptive-metrics_recommendations_config" "default" {
  auto_apply = {
    enabled = true
  }
}

resource "grafana-adaptive-metrics_segment" "team1" {
  name     = "Team1"
  selector = "{team=\"team1\"}"
  auto_apply = {
    enabled = true
  }
}
```
