Create rules
Create and manage rules using the UI, API, or Terraform. This topic focuses on how to manage your rules using the Grafana UI.
To manage rules using the API or Terraform, refer to Adaptive Metrics HTTP API or Adaptive Metrics Terraform provider.
A rule determines how your metrics are aggregated or dropped. Rules are active configurations that are either created by applying a recommendation or created manually.
Rules define which metrics to aggregate, which labels to drop, and which aggregation functions to apply, for example, sum, count, or average.
Create rules using the UI
Create a rule to manage your metric data. These rules are applied in real-time as data is ingested and are used to reduce metric cardinality and control costs.
You can create two types of rules: aggregation rules to combine series, or drop rules to discard data entirely.
View a list of all rules on the Rules tab, where you can also edit and delete existing rules.
Create aggregation rules
Create aggregation rules to combine multiple time series into a smaller, more manageable set. This is the most common way to reduce cardinality while retaining important data.
For example, you might combine data from many different instance labels into a single series for a job.
- Navigate to Administration > Cost Management > Metrics > Adaptive Metrics.
- Click the Rules tab.
- Click Add new rule.
- Select the Aggregation rule type.
- Define which metrics to target.
Choose a metric match type.
- Exact: The rule applies only to the metric name that perfectly matches your entry.
- Prefix: The rule applies to all metrics that begin with your entry (e.g., httpserver).
- Suffix: The rule applies to all metrics that end with your entry (e.g., _total).
Enter the metric name or part of the name to match (e.g., http_server_requests_seconds_sum).
Click the Aggregations dropdown to choose how to aggregate the data.
- sum: Add the values together.
- avg: Calculate the average.
- max: Keep the highest value.
- min: Keep the lowest value.
- count: Count the number of series.
Specify which labels to change.
This is the most critical step for reducing cardinality. You decide what to do with the labels of the selected metrics.
- Drop labels (Default): This is the most common choice. You will select a list of labels to remove. The system will then aggregate all series that are identical after these labels are removed. For example, dropping the instance label will combine all series for a job, regardless of which instance they came from.
- Keep labels: This is the inverse. You select a list of labels to preserve, and all other labels will be dropped. This is useful when you only care about a few specific dimensions.
- Choose labels: Based on your choice above, select the specific labels, for example, instance, pod, ip from the dropdown list that you want to either drop or keep.
Click Save.
Create drop rules
Create drop rules to completely discard metrics that match your criteria. This should be used with caution for metrics you know are not needed.
Navigate to Administration > Cost Management > Metrics > Adaptive Metrics.
Click the Rules tab.
Click Add new rule.
Select the Drop rule type.
Define which metrics to target.
Choose a metric match type.
- Exact: The rule applies only to the metric name that perfectly matches your entry.
- Prefix: The rule applies to all metrics that begin with your entry (e.g., httpserver).
- Suffix: The rule applies to all metrics that end with your entry (e.g., _total).
Enter the metric name or part of the name to match, for example, http_server_requests_seconds_sum.
Click Save.