Skills Development Export Cost Tracking Telemetry

Export Cost Tracking Telemetry

v20261029
cost-export
This skill exports cost-tracking telemetry data in Prometheus textfile or webhook JSON formats for external observability systems like Grafana, Datadog, and custom dashboards. It pulls session and budget records from the cost-tracking namespace, enabling real-time metric updates and ad-hoc reporting. Supports cron scheduling for near-real-time dashboards and one-shot webhook calls for immediate notifications.
Get Skill
93 downloads
Overview

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:

```bash

Prometheus node_exporter textfile collector

node plugins/ruflo-cost-tracker/scripts/export.mjs --prometheus /var/lib/nodeexporter/textfilecollector/cost_tracker.prom

Webhook (POSTs JSON; add auth via env)

EXPORTWEBHOOKHEADER='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
```

  1. Inspect what's emitted — Prometheus output includes:

```
costtrackertotal_usd
costtrackertiertotalusd{tier="opus|sonnet|haiku"}
costtrackersessiontotalusd{session="<8-char>"}
costtrackersession_messages{session="<8-char>"}
costtrackerbudget_usd (if budget configured)
costtrackerbudget_utilization (spent / budget)
```

  1. 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

EnvDefaultPurpose
EXPORT_NAMESPACEcost-trackingOverride target namespace
EXPORT_WEBHOOK_HEADERunsetComma-separated K: V pairs for webhook auth
EXPORT_QUIET=1unsetSuppress 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
Info
Category Development
Name cost-export
Version v20261029
Size 2.73KB
Updated At 2026-10-30
Language