OTEL Metrics Export
Export session metrics to your existing observability platform. Styrby sends data using the OpenTelemetry OTLP/HTTP protocol, so it works with any OTLP-compatible backend. Included on Pro and Growth.
Exported Metrics
After each session, Styrby exports these 7 metrics to your configured endpoint:
| Metric | Type | Attributes |
|---|---|---|
| styrby.session.duration_ms | Gauge | agent, model, status |
| styrby.tokens.input | Sum | agent, model |
| styrby.tokens.output | Sum | agent, model |
| styrby.tokens.cache_read | Sum | agent, model |
| styrby.tokens.cache_write | Sum | agent, model |
| styrby.cost.usd | Sum | agent, model |
| styrby.errors.count | Sum | agent, error_source |
All metrics include service.name as a resource attribute (defaults to "styrby-cli").
Configuration
There are two ways to configure OTEL export. Both produce the same result.
Option A: Web Dashboard (recommended)
- Go to Settings in the web dashboard
- Scroll to the OTEL Metrics Export section
- Select your provider preset (Grafana Cloud, Datadog, Honeycomb, New Relic, or Custom)
- Paste your endpoint URL and authentication credentials
- Click Save
- Copy the generated environment variables from the preview panel
- Add them to your shell profile (
~/.zshrcor~/.bashrc)
Option B: Environment Variables (direct)
Set these in your shell profile or .env file:
export STYRBY_OTEL_ENABLED=true
export STYRBY_OTEL_ENDPOINT="https://your-endpoint/v1/metrics"
export STYRBY_OTEL_HEADERS='{"Authorization":"Bearer your-key"}'
export STYRBY_OTEL_SERVICE="styrby-cli"
export STYRBY_OTEL_TIMEOUT_MS="5000"Grafana Cloud
Grafana Cloud accepts OTLP/HTTP data at a per-stack gateway endpoint. You need your stack's instance ID and an API token with the "metrics:write" scope.
Steps
- Sign in at grafana.com and open your stack
- Go to My Account → Access Policies (left sidebar under Security)
- Click Create access policy
- Give it a name like "Styrby Metrics", select the metrics:write scope, and choose your Grafana Cloud stack
- Click Create, then Add token
- Copy the token (you will not see it again)
- Note your Instance ID (shown at the top of the Access Policies page, or under your stack details)
- Create the Base64 credentials:
echo -n "INSTANCE_ID:API_TOKEN" | base64 - Find your OTLP gateway zone from your stack URL (e.g.,
prod-us-east-0)
Environment Variables
export STYRBY_OTEL_ENABLED=true
export STYRBY_OTEL_ENDPOINT="https://otlp-gateway-prod-us-east-0.grafana.net/otlp/v1/metrics"
export STYRBY_OTEL_HEADERS='{"Authorization":"Basic <BASE64_INSTANCE_ID:API_TOKEN>"}'Replace the zone (prod-us-east-0) with your stack's zone, and the Base64 string with the value from step 8.
Datadog
Datadog accepts OTLP metrics directly at their intake API. No Datadog Agent or Collector required. You need a Datadog API key.
Steps
- Sign in at app.datadoghq.com
- Go to Organization Settings → API Keys (bottom of the left sidebar)
- Click New Key, name it "Styrby Metrics"
- Copy the key value
- Note your Datadog site domain (e.g.,
datadoghq.comfor US1,datadoghq.eufor EU,us3.datadoghq.comfor US3, etc.)
Environment Variables
export STYRBY_OTEL_ENABLED=true
export STYRBY_OTEL_ENDPOINT="https://api.datadoghq.com/api/intake/otlp/v1/metrics"
export STYRBY_OTEL_HEADERS='{"DD-API-KEY":"<YOUR_DATADOG_API_KEY>"}'If your Datadog account is in EU, replace api.datadoghq.com with api.datadoghq.eu. For US3, use api.us3.datadoghq.com. For US5, use api.us5.datadoghq.com.
Honeycomb
Honeycomb accepts OTLP metrics natively. You need a Honeycomb Ingest API key. Metrics appear under the dataset you specify (or default to "styrby-cli").
Steps
- Sign in at ui.honeycomb.io
- Click the gear icon in the lower-left corner to open Environment Settings
- Go to API Keys
- Click Create API Key
- Name it "Styrby Metrics" and check Can create datasets
- Copy the key (you will not see it again after this page)
Environment Variables
export STYRBY_OTEL_ENABLED=true
export STYRBY_OTEL_ENDPOINT="https://api.honeycomb.io/v1/metrics"
export STYRBY_OTEL_HEADERS='{"X-Honeycomb-Team":"<YOUR_API_KEY>"}'For EU accounts, replace api.honeycomb.io with api.eu1.honeycomb.io. To set a custom dataset name, add "X-Honeycomb-Dataset":"your-dataset" to the headers JSON.
New Relic
New Relic accepts OTLP/HTTP at their dedicated ingest endpoint. You need your account's license key (not the REST API key or User API key).
Steps
- Sign in at one.newrelic.com
- Click your account name in the bottom-left corner
- Go to Administration → API Keys
- Find your INGEST - LICENSE key (or click Create a key with type "Ingest - License")
- Click the three-dot menu next to the key and select Copy key
Environment Variables
export STYRBY_OTEL_ENABLED=true
export STYRBY_OTEL_ENDPOINT="https://otlp.nr-data.net/v1/metrics"
export STYRBY_OTEL_HEADERS='{"api-key":"<YOUR_LICENSE_KEY>"}'For EU accounts, replace otlp.nr-data.net with otlp.eu01.nr-data.net. Use the license key (starts with a long hex string), not the User or REST API key.
Custom OTLP Endpoint
Any backend that accepts OTLP/HTTP JSON at a /v1/metrics path will work. This includes self-hosted OpenTelemetry Collectors, Prometheus with the OTLP receiver, Jaeger, SigNoz, and others.
export STYRBY_OTEL_ENABLED=true
export STYRBY_OTEL_ENDPOINT="https://your-collector:4318/v1/metrics"
export STYRBY_OTEL_HEADERS='{"Authorization":"Bearer your-token"}'Verifying the Integration
After adding the environment variables to your shell profile:
- Open a new terminal (or run
source ~/.zshrc) - Start a Styrby session:
styrby - Send a prompt, wait for the agent to respond, then stop the session
- Check your observability platform for metrics with
service.name = styrby-cli
If metrics do not appear, check for warnings in the Styrby CLI output. The exporter logs connection errors but does not interrupt your session. Common issues:
- 401 Unauthorized - Check that your API key or token is correct and has write permissions
- Connection timeout - Verify the endpoint URL is reachable from your machine. Increase
STYRBY_OTEL_TIMEOUT_MSif behind a slow proxy - No data in dashboard - It can take 1-2 minutes for metrics to appear. Check that you are looking at the correct service name and time range
Building a Dashboard
Once metrics are flowing, create a dashboard with panels for:
- Daily AI spend - Sum of
styrby.cost.usdgrouped by day - Token usage by agent -
styrby.tokens.input+styrby.tokens.outputgrouped byagentattribute - Session duration trend - Average of
styrby.session.duration_msover time - Cache hit ratio -
styrby.tokens.cache_read/ (styrby.tokens.input+styrby.tokens.cache_read) - Error rate -
styrby.errors.countas a time series, alert when it spikes
Set alerts on styrby.cost.usdto get paged when daily spend exceeds your threshold. This works alongside Styrby's built-in budget alerts for defense-in-depth cost control.