grafana-billing

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Grafana Billing Metrics Skill

Grafana计费指标Skill

Query key billing metrics from Prometheus and Loki through Grafana's data source proxy API.
通过Grafana的数据源代理API查询Prometheus和Loki的关键计费指标。

Quick Start

快速开始

bash
undefined
bash
undefined

Query both staging and prod (default)

查询预发布环境(staging)和生产环境(prod)(默认行为)

uv run .claude/skills/grafana-billing/scripts/billing_metrics.py
uv run .claude/skills/grafana-billing/scripts/billing_metrics.py

Query specific environment

查询特定环境

uv run .claude/skills/grafana-billing/scripts/billing_metrics.py --env staging uv run .claude/skills/grafana-billing/scripts/billing_metrics.py --env prod
uv run .claude/skills/grafana-billing/scripts/billing_metrics.py --env staging uv run .claude/skills/grafana-billing/scripts/billing_metrics.py --env prod

JSON output for automation

输出JSON格式以用于自动化

uv run .claude/skills/grafana-billing/scripts/billing_metrics.py --json
uv run .claude/skills/grafana-billing/scripts/billing_metrics.py --json

Filter to specific service

过滤特定服务

uv run .claude/skills/grafana-billing/scripts/billing_metrics.py --service prometheus uv run .claude/skills/grafana-billing/scripts/billing_metrics.py --service loki
undefined
uv run .claude/skills/grafana-billing/scripts/billing_metrics.py --service prometheus uv run .claude/skills/grafana-billing/scripts/billing_metrics.py --service loki
undefined

Environment Variables Required

所需环境变量

  • GRAFANA_STAGING_API_KEY
    - API key for staging Grafana workspace
  • GRAFANA_PROD_API_KEY
    - API key for prod Grafana workspace
  • GRAFANA_STAGING_API_KEY
    - 预发布环境Grafana工作区的API密钥
  • GRAFANA_PROD_API_KEY
    - 生产环境Grafana工作区的API密钥

Key Metrics Captured

捕获的关键指标

Prometheus

Prometheus

MetricDescription
Active Time SeriesCurrent count of active series (billing dimension)
Samples/secIngestion rate (DPM = samples/sec * 60)
TSDB StorageOn-disk storage bytes
Top CardinalityTop 10 metrics by series count
指标描述
活跃时间序列当前活跃序列的数量(计费维度)
样本数/秒摄入速率(DPM = 样本数/秒 * 60)
TSDB存储磁盘上的存储字节数
最高基数按序列数排名前10的指标

Loki

Loki

MetricDescription
Ingestion RateGB/day being ingested
Total BytesCumulative bytes received
Active StreamsNumber of active log streams
Memory ChunksChunks held in memory
指标描述
摄入速率每日摄入的GB数
总字节数累计接收的字节数
活跃流活跃日志流的数量
内存块保存在内存中的块

When to Use

使用场景

Use this skill when the user asks about:
  • Observability billing or costs
  • Active time series counts
  • Prometheus cardinality analysis
  • Loki ingestion rates
  • Storage usage for metrics or logs
  • Comparing staging vs production usage
当用户询问以下内容时使用此技能:
  • 可观测性计费或成本
  • 活跃时间序列数量
  • Prometheus基数分析
  • Loki摄入速率
  • 指标或日志的存储使用量
  • 对比预发布环境与生产环境的使用情况

Instructions for Claude

给Claude的说明

  1. Run the billing metrics script to gather current data
  2. Present the results in a clear, formatted way
  3. Highlight any concerning metrics (high cardinality, rapid growth)
  4. Compare staging vs prod if both are queried
  5. Suggest cost optimization if metrics are unusually high
  1. 运行计费指标脚本以收集当前数据
  2. 以清晰、格式化的方式呈现结果
  3. 突出显示任何值得关注的指标(高基数、快速增长)
  4. 如果同时查询了两个环境,对比预发布环境与生产环境的数据
  5. 如果指标异常高,建议成本优化方案

Critical Rules

重要规则

  • Always check that API keys are set before running
  • Use
    --json
    flag when you need to process the output programmatically
  • Default to querying both environments for comparison
  • Handle errors gracefully - missing data sources should not crash the script
  • 运行前务必检查API密钥是否已设置
  • 当需要以编程方式处理输出时,使用
    --json
    标志
  • 默认查询两个环境以便对比
  • 优雅处理错误 - 数据源缺失不应导致脚本崩溃