Loading...
Loading...
Reduce Grafana Cloud Metrics costs by managing cardinality with Adaptive Metrics aggregation rules. Use when the user asks to reduce metrics costs, manage cardinality, create aggregation rules, apply label dropping, analyse unused metrics, understand Active Series, or optimise Prometheus storage. Triggers on phrases like "adaptive metrics", "reduce cardinality", "aggregation rules", "metrics cost", "too many series", "Active Series", "label dropping", "unused metrics", "cardinality reduction", or "metrics spend".
npx skill4agent add grafana/skills adaptive-metrics# Check if any dashboards or alerts use the label being dropped
# Replace METRIC_NAME and LABEL_NAME with actual values
grep -r "METRIC_NAME" /path/to/dashboards/ --include="*.json" | grep "LABEL_NAME"# List recommendations
curl -s -H "Authorization: Bearer <API_KEY>" \
"https://adaptive-metrics.grafana.net/api/v1/recommendations" | \
jq '.recommendations[] | {metric_name, current_series, projected_series, estimated_reduction_percent}'
# Apply a recommendation by ID
curl -s -X POST \
-H "Authorization: Bearer <API_KEY>" \
-H "Content-Type: application/json" \
"https://adaptive-metrics.grafana.net/api/v1/recommendations/<RECOMMENDATION_ID>/apply"# Aggregation rule: keep only job and instance labels for process_cpu_seconds_total
rules:
- match_metric: process_cpu_seconds_total
drop_labels:
- version
- go_version
- service_name
aggregations:
- type: sum
without: [] # empty = keep only the labels not in drop_labelscurl -s -X POST \
-H "Authorization: Bearer <API_KEY>" \
-H "Content-Type: application/json" \
"https://adaptive-metrics.grafana.net/api/v1/rules" \
-d '{
"rules": [
{
"metric_name": "process_cpu_seconds_total",
"match_type": "MATCH_TYPE_EXACT",
"drop_labels": ["version", "go_version"],
"aggregations": [{"type": "AGGREGATION_TYPE_SUM"}]
}
]
}'| Type | Use case |
|---|---|
| Counters, request counts, byte totals |
| Gauges where you want the worst-case (e.g. CPU max across pods) |
| Gauges where you want the best-case |
| Rate metrics, averages |
sum# Apply a rule to all metrics matching a pattern
curl -s -X POST \
-H "Authorization: Bearer <API_KEY>" \
-H "Content-Type: application/json" \
"https://adaptive-metrics.grafana.net/api/v1/rules" \
-d '{
"rules": [
{
"metric_name": "go_.*",
"match_type": "MATCH_TYPE_REGEX",
"drop_labels": ["go_version", "version", "service_instance_id"],
"aggregations": [{"type": "AGGREGATION_TYPE_SUM"}]
}
]
}'versionapp_versiongo_versionservice_instance_idpod_uidcontainer_idgit_commitbuild_datecurl -s -H "Authorization: Bearer <API_KEY>" \
"https://adaptive-metrics.grafana.net/api/v1/usage-analysis?filter=unused" | \
jq '.metrics[] | {metric_name, series_count, last_queried}'prometheus.remote_write "grafana_cloud" {
endpoint {
url = "https://prometheus-prod-XX.grafana.net/api/prom/push"
write_relabel_config {
source_labels = ["__name__"]
regex = "unused_metric_name|another_unused_metric"
action = "drop"
}
}
}# Check log volume recommendations
curl -s -H "Authorization: Bearer <API_KEY>" \
"https://adaptive-logs.grafana.net/api/v1/recommendations" | \
jq '.recommendations[] | {stream_selector, estimated_reduction_percent}'# Active Series count over time (visible in Grafana Cloud Metrics Usage dashboard)
grafanacloud_instance_active_series
# Series reduction from adaptive metrics
grafanacloud_instance_active_series_dropped_by_aggregation_rules