grafana-billing
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseGrafana 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
undefinedbash
undefinedQuery 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
undefineduv run .claude/skills/grafana-billing/scripts/billing_metrics.py --service prometheus
uv run .claude/skills/grafana-billing/scripts/billing_metrics.py --service loki
undefinedEnvironment Variables Required
所需环境变量
- - API key for staging Grafana workspace
GRAFANA_STAGING_API_KEY - - API key for prod Grafana workspace
GRAFANA_PROD_API_KEY
- - 预发布环境Grafana工作区的API密钥
GRAFANA_STAGING_API_KEY - - 生产环境Grafana工作区的API密钥
GRAFANA_PROD_API_KEY
Key Metrics Captured
捕获的关键指标
Prometheus
Prometheus
| Metric | Description |
|---|---|
| Active Time Series | Current count of active series (billing dimension) |
| Samples/sec | Ingestion rate (DPM = samples/sec * 60) |
| TSDB Storage | On-disk storage bytes |
| Top Cardinality | Top 10 metrics by series count |
| 指标 | 描述 |
|---|---|
| 活跃时间序列 | 当前活跃序列的数量(计费维度) |
| 样本数/秒 | 摄入速率(DPM = 样本数/秒 * 60) |
| TSDB存储 | 磁盘上的存储字节数 |
| 最高基数 | 按序列数排名前10的指标 |
Loki
Loki
| Metric | Description |
|---|---|
| Ingestion Rate | GB/day being ingested |
| Total Bytes | Cumulative bytes received |
| Active Streams | Number of active log streams |
| Memory Chunks | Chunks 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的说明
- Run the billing metrics script to gather current data
- Present the results in a clear, formatted way
- Highlight any concerning metrics (high cardinality, rapid growth)
- Compare staging vs prod if both are queried
- Suggest cost optimization if metrics are unusually high
- 运行计费指标脚本以收集当前数据
- 以清晰、格式化的方式呈现结果
- 突出显示任何值得关注的指标(高基数、快速增长)
- 如果同时查询了两个环境,对比预发布环境与生产环境的数据
- 如果指标异常高,建议成本优化方案
Critical Rules
重要规则
- Always check that API keys are set before running
- Use flag when you need to process the output programmatically
--json - Default to querying both environments for comparison
- Handle errors gracefully - missing data sources should not crash the script
- 运行前务必检查API密钥是否已设置
- 当需要以编程方式处理输出时,使用标志
--json - 默认查询两个环境以便对比
- 优雅处理错误 - 数据源缺失不应导致脚本崩溃