Docs
DocumentationQuery ReferenceAPI Reference
Open Console→→
DocumentationQuery ReferenceAPI Reference

Platform overview

What is Axiom?QuickstartArchitectureFeatures
Fundamentals
Datasets
Edge deployments
Limits
Performance
Optimize usage
Requirements
Semantic conventions
Glossary
Tour
SecurityRoadmap

Send data

Reference architecturesMethods

Understand data

Console
Query
Builder
Editor
Query results
Visualize
Traces
Metrics
Correlations
Save queries
Stream
Dashboard
Create
Elements
Create
Configure
Element types
Gauge
Heatmap
Log stream
Monitor list
Note
Pie chart
Scatter plot
Statistic
Table
Time series
Sections
Configure
Filter
Annotate
Monitor
Overview
View status
Configure
Examples
Monitor types
Anomaly
Match
Threshold
Alerting
Overview
Configure
Notifier types
Custom Webhook
Discord
Email
Microsoft Teams
Opsgenie
PagerDuty
Slack
Manage
Datasets
Overview
Views
Virtual fields
Access
RBAC
Tokens
CLI
Organization
Audit log
Settings
Usage and billing
Profile
Extend
Overview
AWS Lambda
AWS PrivateLink
Cloudflare Workers
Cloudflare Logpush
Convex
Grafana
Hex
Netlify
Supabase
Tailscale
Terraform
Unkey
Vercel
Intelligence
Overview
Spotlight
AI agents
Overview
MCP Server
Query cost limits
Agent-created orgs
Skills
Overview
Axiom alerting
Build dashboards
Control costs
Query metrics
SRE
Translate SPL to APL
Splunk
Overview
Splunk app
Install and configure
Commands
Examples
Portal
How it works
Set up standard mode
Set up transparent mode
Observability Cloud
SPL command support
Examples
Monitor and troubleshoot

Use cases

ObservabilityProduct analytics
LLM observability
Overview
Use Axiom AI SDK
Manual instrumentation
GenAI attributes
Redaction policies

Miscellaneous

LLMs
Overview
List of docs pages
Full docs
Query reference
FAQs
Legal
Acceptable use policy
Cookies
Data processing
HIPAA
Partner agreement
Partner program guide
Privacy policy
SLA
Terms of service
Terms of use

Axiom transport for Winston logger

This page explains how to send data from a Node.js app to Axiom through Winston.

Prerequisites

  • Create an Axiom account.
  • Create a dataset in Axiom where you send your data.
  • Create an API token in Axiom with permissions to ingest data to the dataset you have created.

Install SDK

To install the SDK, run the following:

shell
npm install @axiomhq/winston

Import the Axiom transport for Winston

javascript
import { WinstonTransport as AxiomTransport } from '@axiomhq/winston';

Create a Winston logger instance

javascript
const logger = winston.createLogger({
    level: 'info',
    format: winston.format.json(),
    defaultMeta: { service: 'user-service' },
    transports: [
        // You can pass an option here. If you don’t, the transport is configured automatically
        // using environment variables like `AXIOM_DATASET` and `AXIOM_TOKEN`
        new AxiomTransport({
            dataset: 'DATASET_NAME',
            token: 'API_TOKEN',
        }),
    ],
});
Info

Replace API_TOKEN with the Axiom API token you have generated. For added security, store the API token in an environment variable.

Replace DATASET_NAME with the name of the Axiom dataset where you send your data.

After setting up the Axiom transport for Winston, use the logger as usual:

javascript
logger.log({
    level: 'info',
    message: 'Logger successfully setup',
});

Error, exception, and rejection handling

To log errors, use the winston.format.errors formatter. For example:

typescript
import winston from 'winston';
import { WinstonTransport as AxiomTransport } from '@axiomhq/winston';
const { combine, errors, stack } = winston.format;
const axiomTransport = new AxiomTransport({ ... });
const logger = winston.createLogger({
  // 8<----snip----
  format: combine(errors({ stack: true }), json()),
  // 8<----snip----
});

To automatically log exceptions and rejections, add the Axiom transport to the exceptionHandlers and rejectionHandlers. For example:

typescript
import winston from 'winston';
import { WinstonTransport as AxiomTransport } from '@axiomhq/winston';
const axiomTransport = new AxiomTransport({ ... });
const logger = winston.createLogger({
  // 8<----snip----
  transports: [axiomTransport],
  exceptionHandlers: [axiomTransport],
  rejectionHandlers: [axiomTransport],
  // 8<----snip----
});
Warning

Running on Edge runtime isn’t supported.

Configure region

By default, the transport sends data to api.axiom.co. To target a specific edge region, set the edge option on AxiomTransport to the edge domain that matches the region your dataset lives in:

typescript
new AxiomTransport({
    dataset: 'DATASET_NAME',
    token: 'API_TOKEN',
    edge: 'eu-central-1.aws.edge.axiom.co',
});
typescript
new AxiomTransport({
    dataset: 'DATASET_NAME',
    token: 'API_TOKEN',
    edge: 'us-east-1.aws.edge.axiom.co',
});

The following edge domains are available:

Edge deploymentBase domain for ingest and query
US East 1 (AWS)us-east-1.aws.edge.axiom.co
EU Central 1 (AWS)eu-central-1.aws.edge.axiom.co

For more information about edge deployments, see Edge deployments.

Warning

Always use the edge option to target a region. Don't put a regional hostname in url — url is reserved for non-ingest API operations and won't route ingest correctly. (This is unrelated to the Edge runtime note above, which is about where your code runs.)

Transport options

OptionRequiredDescription
datasetyesThe Axiom dataset to ingest logs into. Falls back to the AXIOM_DATASET environment variable.
tokenyesAn Axiom API token with ingest permission for the dataset.
orgIdnoOrganization ID. Required when using a personal token.
edgenoEdge domain for ingest, without scheme. Example: eu-central-1.aws.edge.axiom.co. Use this to target a region.
edgeUrlnoFull edge URL with scheme. Takes precedence over edge if both are set. Useful for self-hosted or proxy setups.
urlnoBase URL for non-ingest API operations.
onErrornoCallback invoked when sending data fails.

Examples

For more examples, see the examples in GitHub.

Was this page helpful?
Suggest edits on GitHub
On this page
Install SDKImport the Axiom transport for WinstonCreate a Winston logger instanceError, exception, and rejection handlingConfigure regionTransport optionsExamples