Adaptive Metrics
Grafana LabsOfficialPublished by Grafana Labs
- Skill
- Tool integration
- Cloud and DevOps
- Apache-2.0
- No issues found
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
Adaptive Metrics provides a framework for controlling metrics billing in Grafana Cloud by reducing the active series count. It enables users to identify high-cardinality labels and unused metrics, then apply aggregation rules or drop configurations to shrink the data footprint before storage. The process involves reviewing automated recommendations, creating custom exact or regex-based aggregation rules, and verifying the impact on series counts.
What it does
- Generates recommendations for reducing active series based on query history.
- Allows creation of custom aggregation rules using exact or regex matching.
- Identifies unused metrics that can be safely dropped to save costs.
- Provides methods to drop specific labels that contribute to high cardinality.
- Supports verification of series reduction impact through query metrics.
- Offers a fallback configuration for dropping metrics at the remote write stage.
When to use it
- When investigating high costs in a Grafana Cloud metrics bill.
- When dealing with exploding active series counts due to high-cardinality labels.
- When you need to pre-aggregate counters or gauges to optimize storage.
- When you want to remove unused metrics that are still being sent to the cloud.
- When you need to verify the effectiveness of cardinality reduction strategies.
Advantages
- Directly impacts billing by reducing the number of active series.
- Automated recommendations simplify the identification of optimization targets.
- Flexible rule creation supports both specific and broad metric patterns.
- Provides clear verification steps to measure the success of applied rules.
Usage examples
- “How can I see which metrics are recommended for aggregation to lower my bill?”
- The agent retrieves the recommendation list from the Adaptive Metrics API, showing metric names, current series counts, and estimated reduction percentages.
- “I need to drop the version label from my CPU metrics to reduce cardinality.”
- The agent guides you through creating a custom aggregation rule that targets the specific metric and drops the requested labels using a sum aggregation type.
- “How do I find and remove unused metrics in my Grafana Cloud instance?”
- The agent lists unused metrics via the usage analysis endpoint and provides instructions for verifying their lack of use in dashboards or alerts before dropping them.
- “How can I check if my aggregation rules are actually working?”
- The agent provides PromQL queries to monitor the total active series and the specific count of series dropped by your active aggregation rules.
Install
Download the skill as a ZIP:
https://autogineer.com/agent-skills/grafana/adaptive-metrics/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip adaptive-metrics.zip -d .agents/skills
Documentation by Grafana Labs
Grafana Cloud Adaptive Metrics
Aggregation rules that pre-shrink high-cardinality metrics before storage — directly reduces active-series billing.
Prerequisites
Grafana Cloud Metrics plan (any paid tier)
API key with
metrics:write(for the Adaptive Metrics API —adaptive-metrics.grafana.net, Bearer auth)For the verification queries: the metrics query endpoint (
prometheus-prod-XX.grafana.net) uses HTTP basic auth —<metrics_user>(numeric stack/instance ID) plus a token withmetrics:read— not the Bearer keyAccess to Home → Adaptive Metrics in the Cloud portal
Common Workflows
1. Review + apply auto-recommendations
# 1. Pull the recommendation list (sorted by series-reduction impact)
curl -s -H "Authorization: Bearer <KEY>" \
"https://adaptive-metrics.grafana.net/api/v1/recommendations" \
| jq '.recommendations[] | {metric_name, current_series, projected_series, estimated_reduction_percent}'
# 2. Capture the baseline series count for the target metric
# (metrics query endpoint = basic auth, not the Bearer key)
curl -s -u "<metrics_user>:<metrics_token>" \
"https://prometheus-prod-XX.grafana.net/api/prom/api/v1/query?query=count({__name__=\"process_cpu_seconds_total\"})" \
| jq '.data.result[0].value[1]' # → e.g. "12480"
# 3. Apply the recommendation (or click Apply in the UI)
curl -s -X POST -H "Authorization: Bearer <KEY>" \
"https://adaptive-metrics.grafana.net/api/v1/recommendations/<ID>/apply"
# 4. Wait ~5 min. Verify — re-run the count query; expect a large drop.
# Also check the saving metric:
# grafanacloud_instance_active_series_dropped_by_aggregation_rulesRollback — delete the rule:
curl -s -H "Authorization: Bearer <KEY>" \
"https://adaptive-metrics.grafana.net/api/v1/rules" | jq '.rules[] | {id, metric_name}'
curl -s -X DELETE -H "Authorization: Bearer <KEY>" \
"https://adaptive-metrics.grafana.net/api/v1/rules/<RULE_ID>"
# Or in the UI: Rules → row → Disable2. Hand-write a custom rule
# 1. Sanity-check the metric is not used WITH that label in dashboards/alerts
grep -r 'process_cpu_seconds_total' dashboards/ alerts/ | grep -E 'version|go_version'
# Expect no hits → safe to drop.
# 2. Create the rule
curl -s -X POST -H "Authorization: Bearer <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"}]}]}'
# 3. Verify — same count() query as above; series count should drop within 5 min.Full payloads (regex match, aggregation types, all caveats): references/api.md.
3. Drop unused metrics entirely
# 1. List unused metrics
curl -s -H "Authorization: Bearer <KEY>" \
"https://adaptive-metrics.grafana.net/api/v1/usage-analysis?filter=unused" | \
jq '.metrics[] | {metric_name, series_count, last_queried}'
# 2. Confirm not referenced in dashboards / alerts / recording rules
grep -r '<METRIC_NAME>' dashboards/ alerts/ recording-rules/
# 3. Add a write_relabel_config drop in Alloy (full block in references/api.md)
# Reload Alloy: curl -X POST http://localhost:12345/-/reload
# 4. Verify — the metric should no longer appear in series counts after ~10 min
curl -s -u "<metrics_user>:<metrics_token>" \
'https://prometheus-prod-XX.grafana.net/api/prom/api/v1/label/__name__/values' | jq '.data | index("<METRIC_NAME>")' # → nullMeasure the impact
# Total active series (billed unit)
grafanacloud_instance_active_series
# Series specifically dropped by Adaptive Metrics rules
grafanacloud_instance_active_series_dropped_by_aggregation_rulesRules take effect within ~5 minutes; full billing impact appears within an hour. The original high-cardinality samples keep flowing but the dropped labels no longer count toward billing.
Resources
Files
- ATTRIBUTION.mdAdded by AutoGineer853 B
- LICENSELicence file added by AutoGineer11.1 KiB
- SKILL.md5.2 KiB
- references/api.md3.3 KiB
references/api.md
Adaptive Metrics API + rule formats
Base URL: https://adaptive-metrics.grafana.net/api/v1
Auth: Authorization: Bearer <grafana-cloud-API-key> (scope metrics:write)
List recommendations
curl -s -H "Authorization: Bearer <KEY>" \
"https://adaptive-metrics.grafana.net/api/v1/recommendations" | \
jq '.recommendations[] | {metric_name, current_series, projected_series, estimated_reduction_percent}'Apply / disable a recommendation
# Apply by ID
curl -s -X POST -H "Authorization: Bearer <KEY>" \
"https://adaptive-metrics.grafana.net/api/v1/recommendations/<ID>/apply"
# Roll back — list rules, then DELETE the offending rule
curl -s -H "Authorization: Bearer <KEY>" \
"https://adaptive-metrics.grafana.net/api/v1/rules" | jq
curl -s -X DELETE -H "Authorization: Bearer <KEY>" \
"https://adaptive-metrics.grafana.net/api/v1/rules/<RULE_ID>"Create a custom rule (exact match)
curl -s -X POST -H "Authorization: Bearer <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"}]
}]
}'Create a regex-match rule (family)
curl -s -X POST -H "Authorization: Bearer <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"}]
}]
}'Aggregation types
| Type | Use case |
|---|---|
sum | Counters, request counts, byte totals |
max | Gauges where you want the worst-case |
min | Gauges where you want the best-case |
avg | Rate metrics / averages |
Counters MUST use sum — averaging counters produces incorrect rates.
Unused metrics — usage analysis
curl -s -H "Authorization: Bearer <KEY>" \
"https://adaptive-metrics.grafana.net/api/v1/usage-analysis?filter=unused" | \
jq '.metrics[] | {metric_name, series_count, last_queried}'Before dropping unused metrics entirely:
Confirm not used in any dashboard (search dashboard JSON by metric name).
Confirm not used in any alert or recording rule.
Check with the owning team — could be an SLO input.
Alloy fallback — drop at remote_write
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"
}
}
}Common labels safe to drop globally
version,app_version,go_version— rarely queried in PromQLservice_instance_id,pod_uid,container_id— ultra-high cardinalitygit_commit,build_date— static, inflate series for no query value
Adaptive Logs (companion)
curl -s -H "Authorization: Bearer <KEY>" \
"https://adaptive-logs.grafana.net/api/v1/recommendations" | \
jq '.recommendations[] | {stream_selector, estimated_reduction_percent}'Requirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Needs: Needs network access, Needs an API key
Security
No issues found by our static scan· No issues found
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Published by
- Grafana Labs
- Publisher
- Grafana Labs (Official)
- Source
- grafana/skills · skills/grafana-cloud/adaptive-metrics · commit 8fb72a5
- Licence
- Apache License 2.0 (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
AutoGineer is not affiliated with or endorsed by Grafana Labs or Grafana Labs.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download adaptive-metrics.zip