跳到正文
Skillpedia
其他81k · #1600

cost-export

它能做什么

这项技能把你记录的 AI 成本数据保存为其他监控工具可以展示的形式。适合希望把 AI 支出显示在共享仪表盘上的人。

适用场景

  • ✓当你希望 AI 支出显示在 Grafana 或类似的仪表盘上时。
  • ✓当你想把成本快照发送到某个网址以便汇报时。
  • ✓当你希望成本数据按计划定期刷新时。

技能链接

https://github.com/ruvnet/ruflo/blob/main/plugins/ruflo-cost-tracker/skills/cost-export/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/ruvnet/ruflo/blob/main/plugins/ruflo-cost-tracker/skills/cost-export/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“请导出我的 AI 成本数据,让我能在仪表盘上查看。”

每周 5 个新技能,1 分钟读完。

工作原理

这项技能读取已保存的成本记录,并把它们写成供 Prometheus 使用的文本文件,或作为 JSON 消息发送到你指定的网址。不加任何参数时,它会在屏幕上显示 JSON。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Cost Export

Pulls every session-* and budget-config-* record from cost-tracking and emits in formats consumable by external observability systems. Without this, cost data lives only inside the AgentDB namespace; with it, the same data lights up dashboards.

When to use

  • After any cost-track run, to refresh metrics for Grafana / Datadog / Prometheus.
  • Cron-friendly via /loop 5m to keep external dashboards near-real-time.
  • One-shot to a webhook for ad-hoc reporting (Slack, custom endpoint).

Steps

  1. Pick a format — textfile collector for Prometheus / Grafana, or webhook POST for everything else:

    # Prometheus node_exporter textfile collector
    node plugins/ruflo-cost-tracker/scripts/export.mjs --prometheus /var/lib/node_exporter/textfile_collector/cost_tracker.prom
    
    # Webhook (POSTs JSON; add auth via env)
    EXPORT_WEBHOOK_HEADER='Authorization: Bearer $TOKEN' \
      node plugins/ruflo-cost-tracker/scripts/export.mjs --webhook https://hooks.example.com/cost-tracker
    
    # Stdout JSON (default if no flag)
    node plugins/ruflo-cost-tracker/scripts/export.mjs
    
  2. Inspect what's emitted — Prometheus output includes:

    cost_tracker_total_usd                                    <gauge>
    cost_tracker_tier_total_usd{tier="opus|sonnet|haiku"}     <gauge>
    cost_tracker_session_total_usd{session="<8-char>"}        <gauge>
    cost_tracker_session_messages{session="<8-char>"}         <counter>
    cost_tracker_budget_usd                                   <gauge>  (if budget configured)
    cost_tracker_budget_utilization                           <gauge>  (spent / budget)
    
  3. Webhook payload shape — the JSON the webhook receives matches the stdout JSON: { exportedAt, sessions: [...], budget, totalUsd, byTier }. Headers may be added via EXPORT_WEBHOOK_HEADER='K1: V1, K2: V2' (comma-separated).

Env overrides

Env Default Purpose
EXPORT_NAMESPACE cost-tracking Override target namespace
EXPORT_WEBHOOK_HEADER unset Comma-separated K: V pairs for webhook auth
EXPORT_QUIET=1 unset Suppress non-error confirmation output

Cross-references

  • cost-track — produces the data this skill exports
  • cost-budget-check — the same cost_tracker_budget_* metrics are alertable in Prometheus
  • node_exporter textfile collector docs (Prometheus convention) — drop the .prom file in the collector directory and Prometheus picks it up
常见问题

什么是 Prometheus 文本文件?

这是一种普通文件,内含指标行,节点导出器的收集器可以读取并在仪表盘上显示。

我能给 webhook 加上登录验证吗?

可以。一个环境变量设置可以在请求中附带请求头,例如授权令牌。

默认会把数据发送到别处吗?

不会。除非你选择文件或 webhook 选项,否则它只会在屏幕上显示 JSON。

详情

作者的原始描述

Export cost-tracking telemetry in Prometheus textfile or webhook JSON formats — for external observability (Grafana, Datadog, custom dashboards)

repo: ruvnet/ruflo

热度

GitHub 星标
81k
排名
#1600
许可证
MIT
更新时间
2026/11/2

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能