# Export and Integrate

`tj` stores all telemetry in a local DuckDB database. Export it in multiple formats for analysis, evaluation, or forwarding to external backends.

## Export formats

### OTLP (OpenTelemetry)

Forward spans to Grafana, Datadog, Honeycomb, or any OTel-compatible backend:

```bash
tj export --format otlp
```

### OpenEvals / AgentEvals

Export traces in the format expected by trajectory evaluation tools:

```bash
tj export --format openevals --output traces.json
```

### JSON (NDJSON)

One span per line, newline-delimited JSON:

```bash
tj export --format json
tj export --format json --output spans.jsonl
```

### CSV

Flat tabular format for spreadsheets or pandas:

```bash
tj export --format csv
tj export --format csv --output spans.csv
```

## Filtering exports

All formats support filtering by time range, agent, and more:

```bash
tj export --format json --since 7d           # last 7 days
tj export --format csv --agent my-agent      # specific agent
tj export --format otlp --since 1h           # last hour
```

## Prometheus metrics

When `tj serve` is running, Prometheus metrics are available at:

```
http://127.0.0.1:7391/metrics
```

Metrics are generated by querying the database on each scrape request, so data is accurate even after server restarts. Scrape this endpoint from your Prometheus instance or any compatible monitoring tool (Grafana Agent, Victoria Metrics, etc.).

## REST API

All data is also accessible via the local REST API at `http://127.0.0.1:7391/api/v1/`:

```
GET /api/v1/traces         # trace listing
GET /api/v1/spans          # span listing
GET /api/v1/cost           # cost breakdown
GET /api/v1/alerts         # alert history
GET /api/v1/drift          # drift baselines
GET /api/v1/agents         # agent registry
GET /metrics               # Prometheus text format
```

API docs are available at `http://127.0.0.1:7391/docs` when the server is running.
