Grafana Cloud

Enable auto-apply

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.

Before you begin

To enable auto-apply, you need the Admin role.

Create exemptions before you turn on auto-apply, so critical metrics aren’t aggregated inadvertently.

For more information, refer to Manage access to Grafana Adaptive Metrics.

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. Select Coverage-first or Cost-first for the segment.

  3. The system analyzes the metrics within the specific segment and generates optimization recommendations based on the analysis.

  4. The system automatically applies the recommendations allowed by the selected mode.

Note

You can still add and edit custom rules after you enable auto-apply.

Auto-apply doesn’t modify affix (prefix or suffix) aggregation rules or drop rules. Auto-apply can remove or replace exact-match aggregation rules. To keep an exact-match rule in place, create an exemption for that metric.

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.

Choose an auto-apply mode

You can select an auto-apply mode for each segment. The mode controls which recommendations are applied automatically.

You choose a mode when you enable auto-apply for the Default segment or for multiple segments on the Overview page, for a single segment on the Segments page, and in the prompt after Apply all recommendations.

Coverage-first applies every recommendation, including any that are expected to add series when new usages of previously aggregated data need coverage. Recommended rule changes can increase the series count, for example, when a new query or dashboard usage requires more raw data than was previously available. Use this mode when adapting automatically to observed metric usage is more important than limiting estimated series growth.

Cost-first applies only those recommendations that are expected to reduce or maintain the overall series count. This mode uses estimated savings from the most recent analysis of your metric and usage data. It applies all recommendations that are expected to reduce your series count. It also applies all recommendations that are expected to increase your series count, but only up to the budget created by series count reductions applied in the same cycle. Recommendations that exceed this budget aren’t applied automatically. You can still apply those recommendations from the UI. Use this mode when limiting estimated series growth is more important than automatically expanding coverage.

Both modes are subject to the limit on aggregation rules. If a segment is at or near its limit, auto-apply might skip some or all recommendations.

Caution

Cost-first mode makes decisions using the series count estimates generated during the last analysis cycle. It doesn’t compare the live series count before and after applying rule changes. Cost-first mode is a guardrail based on recent series count estimates, not a hard guarantee that series count never increases under any circumstances.

Enable auto-apply for a single segment

Start with the Default segment if you are not using segmentation yet. The Default segment holds the series that are not assigned to a named segment. On Segments, you can also enable auto-apply for one existing segment, or while you add a segment.

  1. Navigate to Adaptive Metrics.

  2. On the Overview page, click Enable auto-apply next to the Segment dropdown.

    The Enable auto-apply per segment dialog box opens.

  3. Select Default.

    If you only have the Default segment, the dialog box recommends creating more segments and includes a Go to Segments link. You can still enable auto-apply for Default.

  4. Select an Auto-apply mode.

  5. Click Apply.

To enable auto-apply for one segment from Segments, including a segment you are adding:

  1. Navigate to the Segments page.

  2. Click Edit segment, or Edit default segment for the Default segment. To turn auto-apply on while you create a segment, click Add new segment and fill out the segment details.

  3. Select the Enable auto-apply checkbox.

  4. Select an Auto-apply mode.

  5. Click Apply for the Default segment, Save for a named segment, or Add when you are creating the segment.

    In the Segments list, you can view the segment and whether auto-apply is enabled. From the Metrics page, you can search for a segment and see whether auto-apply is enabled.

Enable auto-apply for multiple segments

Use this when you already have segments and want one mode for every segment you select. The mode you select applies to every segment in the selection.

  1. Navigate to Adaptive Metrics.

  2. On the Overview page, click Enable auto-apply next to the Segment dropdown.

    The Enable auto-apply per segment dialog box opens.

  3. Select the segments you want to enable auto-apply for.

    Segments that already have auto-apply enabled aren’t included.

  4. Select an Auto-apply mode.

  5. Click Apply.

Enable auto-apply after applying all recommendations

After you click Apply all recommendations on the Metrics page and click Apply in the Change rules? dialog box, a prompt asks you to enable auto-apply for the current segment.

The prompt doesn’t appear if you apply a selection of recommendations, or if auto-apply is already on for that segment.

Select an Auto-apply mode in the prompt. To change the mode later, on the Segments page click Edit segment or Edit default segment. The Overview dialog doesn’t list a segment that already has auto-apply on.

  1. Select an Auto-apply mode.
  2. Click Enable auto-apply for this segment to turn on auto-apply, or Dismiss to close the prompt.
  3. Optionally, select Do not show this again before you dismiss the prompt if you don’t want to see it later.

Turn auto-apply off

  1. Navigate to Adaptive Metrics.
  2. Navigate to the Segments page.
  3. Click Edit segment, or Edit default segment for the Default segment.
  4. Clear Enable auto-apply.
  5. Click Apply for the Default segment, or Save for a named segment.

The rules stay as they were applied at that moment. You can still change them yourself.

After auto-apply is on, return to Overview. Time series reduction shows the reduction from applied rules. On later visits, the recommendations summary shows how many recommendations are still pending. With Cost-first, recommendations past the budget stay pending. Refer to Monitor and validate results.

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 recommendations and leave it turned off for other segments.

Set auto_apply.gate.policy to one of the following values:

  • unbounded selects Coverage-first.
  • no-increase selects Cost-first.

If you omit gate or policy, auto-apply uses Coverage-first.

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

Configure the default segment

  1. Use the /aggregations/recommendations/config endpoint.
  2. Set the enabled property to true.
  3. Set gate.policy to the policy for the mode you want to use.

The following example enables Cost-first.

# 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 in Cost-first mode
curl -s -u '<user>:<key>' 'https://<prom URL>/aggregations/recommendations/config' -X POST -d '{
  "keep_labels": [],
  "auto_apply": {
    "enabled": true,
    "gate": {
      "policy": "no-increase"
    }
  }
}'

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

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.
  3. Set gate.policy to the policy for the mode you want to use.

The following example enables Cost-first.

# Get the current config to look up the segment ID
% 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 in Cost-first mode 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,
    "gate": {
      "policy": "no-increase"
    }
  }
}'

# Verify the 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,
      "gate": {
        "policy": "no-increase"
      }
    }
  }
]

Enable auto-apply using Terraform

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

Use the grafana-adaptive-metrics_recommendations_config resource to configure the default segment. Use the grafana-adaptive-metrics_segment resource to configure custom segments.

Set auto_apply.enabled to true for each segment where you want auto-apply on.

Set auto_apply.gate.policy to unbounded for Coverage-first or no-increase for Cost-first.

For provider setup instructions, refer to Adaptive Metrics Terraform provider.