Axiom
Axiom is a cloud-native logging platform with powerful querying capabilities. The evlog Axiom adapter sends your wide events directly to Axiom datasets.
Installation
The Axiom adapter is included in the main evlog package:
import { createAxiomDrain } from 'evlog/axiom'
Quick Start
1. Get your Axiom credentials
- Create an Axiom account
- Create a dataset for your logs
- Generate an API token with ingest permissions
2. Set environment variables
NUXT_AXIOM_TOKEN=xaat-your-token-here
NUXT_AXIOM_DATASET=your-dataset-name
3. Create the drain plugin
import { createAxiomDrain } from 'evlog/axiom'
export default defineNitroPlugin((nitroApp) => {
nitroApp.hooks.hook('evlog:drain', createAxiomDrain())
})
That's it! Your logs will now appear in Axiom.
Configuration
The adapter reads configuration from multiple sources (highest priority first):
- Overrides passed to
createAxiomDrain() - Runtime config at
runtimeConfig.evlog.axiom - Runtime config at
runtimeConfig.axiom - Environment variables (
NUXT_AXIOM_*orAXIOM_*)
Environment Variables
| Variable | Description |
|---|---|
NUXT_AXIOM_TOKEN | API token with ingest permissions |
NUXT_AXIOM_DATASET | Dataset name to ingest logs into |
NUXT_AXIOM_ORG_ID | Organization ID (required for Personal Access Tokens) |
You can also use AXIOM_TOKEN, AXIOM_DATASET, and AXIOM_ORG_ID as fallbacks.
Runtime Config
Configure via nuxt.config.ts for type-safe configuration:
export default defineNuxtConfig({
runtimeConfig: {
axiom: {
token: '', // Set via NUXT_AXIOM_TOKEN
dataset: '', // Set via NUXT_AXIOM_DATASET
},
},
})
Override Options
Pass options directly to override any configuration:
import { createAxiomDrain } from 'evlog/axiom'
export default defineNitroPlugin((nitroApp) => {
nitroApp.hooks.hook('evlog:drain', createAxiomDrain({
dataset: 'production-logs',
timeout: 10000, // 10 seconds
}))
})
Full Configuration Reference
| Option | Type | Default | Description |
|---|---|---|---|
token | string | - | API token (required) |
dataset | string | - | Dataset name (required) |
orgId | string | - | Organization ID (for PAT tokens) |
baseUrl | string | https://api.axiom.co | Axiom API base URL |
timeout | number | 5000 | Request timeout in milliseconds |
Querying Logs in Axiom
evlog sends structured wide events that are perfect for Axiom's APL query language:
// Find slow requests
['your-dataset']
| where duration > 1000
| project timestamp, path, duration, status
// Error rate by endpoint
['your-dataset']
| where level == "error"
| summarize count() by path
| order by count_ desc
// Request volume over time
['your-dataset']
| summarize count() by bin(timestamp, 1h)
| render timechart
Troubleshooting
Missing dataset or token error
[evlog/axiom] Missing dataset or token. Set NUXT_AXIOM_DATASET and NUXT_AXIOM_TOKEN
Make sure your environment variables are set and the server was restarted after adding them.
401 Unauthorized
Your token may be invalid or expired. Generate a new token in the Axiom dashboard with Ingest permissions.
403 Forbidden with PAT tokens
Personal Access Tokens require an organization ID:
NUXT_AXIOM_ORG_ID=your-org-id
Direct API Usage
For advanced use cases, you can use the lower-level functions:
import { sendToAxiom, sendBatchToAxiom } from 'evlog/axiom'
// Send a single event
await sendToAxiom(event, {
token: 'xaat-xxx',
dataset: 'logs',
})
// Send multiple events in one request
await sendBatchToAxiom(events, {
token: 'xaat-xxx',
dataset: 'logs',
})