
Cost Export
FreeStream cost data to external observability systems.
Free · Opens the source repo
What Cost Export does
Cost Export is a utility designed to facilitate the export of cost-tracking telemetry data from the AgentDB to external observability platforms such as Prometheus, Grafana, and Datadog. By converting session-* and budget-config-* records into formats that these systems can consume, it ensures that cost data is not confined to internal databases but is available for real-time monitoring and analysis. This capability is essential for teams that rely on visualizing cost metrics to make informed decisions about resource allocation and budgeting.
The skill supports two primary output formats: a textfile collector format for Prometheus and a JSON format for webhook integration. This flexibility allows users to choose the most appropriate method for their existing monitoring setup. For instance, the textfile output can be directly integrated into Prometheus environments, where it can be picked up by the node_exporter, while the webhook option allows for posting data to custom endpoints or services such as Slack, enabling ad-hoc reporting.
Cost Export is particularly useful after running cost-tracking operations, as it refreshes metrics for external dashboards, ensuring that the displayed data is up-to-date. It can also be scheduled to run at regular intervals using cron jobs, providing near-real-time updates. The skill is straightforward to use, requiring minimal setup, and it provides clear output formats that can be easily inspected and utilized by developers and data analysts alike.
This skill is ideal for developers and operations teams looking to enhance their observability practices by integrating cost data into their existing monitoring frameworks. It empowers users to make data-driven decisions based on accurate and timely cost information, ultimately leading to better resource management and financial oversight.
When to use it
Use this skill after any cost-tracking run to update external dashboards with the latest metrics.
When not to use it
This skill is not suitable for environments that do not utilize external observability tools or require real-time data processing without exporting.
What you can build with it
Integrating with Grafana
Use Cost Export to send cost data to Grafana, allowing you to visualize and analyze your spending in real-time.
Ad-hoc Reporting
Quickly generate and send cost data to a custom webhook for immediate reporting needs, such as to a Slack channel.
Scheduled Updates
Set up a cron job to run Cost Export every 5 minutes, ensuring your external dashboards always display the latest cost metrics.
How to install Cost Export
View source1. Install with the skills CLI
npx skills add ruvnet/ruflo/cost-export --agent claude-code2. Or install it manually
Download the skill folder and drop it into ~/.claude/skills/ for all projects, or .claude/skills/ to scope it to one repo. Restart Claude Code so it picks up the new skill.
Anthropic's agentic coding CLI, and the reference implementation of Agent Skills. Drop a skill folder into ~/.claude/skills and Claude Code loads it automatically whenever a task matches the skill's description. Claude Code docs
Inside SKILL.md
Written by ruvnetCost 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 5mto keep external dashboards near-real-time. - One-shot to a webhook for ad-hoc reporting (Slack, custom endpoint).
Steps
-
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 -
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) -
Webhook payload shape — the JSON the webhook receives matches the stdout JSON:
{ exportedAt, sessions: [...], budget, totalUsd, byTier }. Headers may be added viaEXPORT_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 exportscost-budget-check— the samecost_tracker_budget_*metrics are alertable in Prometheus- node_exporter textfile collector docs (Prometheus convention) — drop the
.promfile in the collector directory and Prometheus picks it up
Frequently asked questions about Cost Export
Similar skills
Turborepo
Optimized build system for JavaScript/TypeScript monorepos.
Azure Pipelines Validation
Streamline your Azure DevOps pipeline changes locally.
Azure Developer CLI
Streamline your Azure project workflows with best practices.
Azure Container Registry CLI
Manage Azure Container Registry resources with ease.
Aspire
Build and orchestrate polyglot distributed applications seamlessly.
Vercel CLI
Manage and deploy Vercel projects from the command line.
