grafana-billing

Query Prometheus and Loki billing metrics through Grafana's data source proxy API.

Updated Jun 11, 2026
One-click install
npx skills add https://github.com/brillianodhiya/VisionScript --skill grafana-billing-brillianodhiya
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: grafana-billing
Source: https://github.com/brillianodhiya/VisionScript/tree/main/.agents/skills/grafana-billing
Command: npx skills add https://github.com/brillianodhiya/VisionScript --skill grafana-billing-brillianodhiya

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires httpx, python-dotenv, rich, and includes scripts (resource) and references (resource) components.

What problem does it solve? Observability costs from Grafana Cloud are driven by active time series, data points per minute, and log ingestion volume, but these metrics are scattered across Prometheus and Loki internals. This Skill consolidates them into a single report so you can analyze billing drivers, spot high-cardinality metrics, and compare staging versus production usage without writing PromQL by hand. ## Core Features & Use Cases - Prometheus Billing Metrics: Retrieves active series count, samples per second (converted to DPM), TSDB storage size, and top-10 cardinality breakdown via the TSDB status endpoint, with fallbacks for Cortex/Mimir and AWS Managed Prometheus. - Loki Ingestion Metrics: Reports ingestion rate in GB/day, cumulative bytes received, active streams, memory chunks, and rejected bytes from rate limiting. - Multi-Environment Comparison: Queries staging and production Grafana workspaces in one run, with human-readable Rich tables or JSON output for automation. - Use Case: Before a capacity planning review, run the CLI against both environments to get active series, DPM, and Loki GB/day side by side, then drill into the top cardinality metrics to identify cost reduction targets. ## Quick Start Ask the AI to run the billing metrics script to compare Prometheus and Loki usage across staging and production, making sure GRAFANA_STAGING_API_KEY and GRAFANA_PROD_API_KEY are set first.

Frequently Asked Questions about grafana-billing

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I check active time series count in Prometheus for billing?▼

Query the TSDB status endpoint (/api/v1/status/tsdb) and sum seriesCountByMetricName, or read prometheus_tsdb_head_series on standard Prometheus. This Skill tries TSDB status first, then falls back to cortex_ingester_active_series for AWS Managed Prometheus.

How to calculate data points per minute (DPM) from Prometheus metrics?▼

DPM equals the samples-per-second ingestion rate multiplied by 60. The rate comes from rate(prometheus_tsdb_head_samples_appended_total[5m]) or rate(cortex_ingester_ingested_samples_total[5m]) on Cortex/Mimir backends.

How do I measure Loki ingestion rate in GB per day?▼

Compute sum(rate(loki_distributor_bytes_received_total[5m])) to get bytes per second, then multiply by 86400 and divide by 1024 cubed. Loki metrics are scraped by Prometheus, so they are queried through the Prometheus data source proxy.

Does this work with AWS Managed Prometheus or Grafana Cloud?▼

Yes. The client queries through Grafana's data source proxy API, so it works with any Prometheus-compatible backend configured as a data source, including AWS Managed Prometheus, Cortex, and Mimir, using metric fallbacks for each variant.

Why does the billing metrics script fail with a missing API key error?▼

The client requires GRAFANA_STAGING_API_KEY and GRAFANA_PROD_API_KEY environment variables, loaded via python-dotenv. If a key is absent, that environment is skipped with a warning; if all fail, the script exits with an error.

Can I get billing metrics as JSON for automation?▼

Yes, pass the --json flag to billing_metrics.py to emit structured JSON instead of Rich tables. You can also filter with --env staging or --service prometheus to limit the scope of the output.