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.
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.
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.
The system analyzes the metrics within the specific segment and generates optimization recommendations based on the analysis.
The system automatically applies the recommendations.
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.
Default or existing segments
To enable auto-apply for the default segment or an existing segment, complete the following steps.
Navigate to Administration > Cost Management > Adaptive Metrics.
Click the Configuration tab.
Click the Edit icon next to the segment you want to enable auto-apply for.
Select the Enable auto-apply checkbox.
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.
Navigate to Administration > Cost Management > Adaptive Metrics.
Click the Configuration tab.
Click Add new segment.
Fill out the details for the new segment.
Select the Enable auto-apply checkbox.
Click Add.
In the Segments list, you can view your new segment and whether auto-apply is enabled.
From the Rules tab, 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
Go to the
/aggregations/recommendations/config
endpoint.Set the
enabled
property to true.
# 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.
- Go to the
/aggregations/rules/segments
endpoint. - Set the
enabled
property to true.
# 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.
The following is an example configuration, which enables auto-apply in the default segment.
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.
The following is an example configuration, which enables auto-apply in the segment team1
.
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
}
}