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

Send data from Python app to Axiom

This page explains how to send data from a Python app to Axiom.

To send data from a Python app to Axiom, use the Axiom Python SDK.

Info

The Axiom Python SDK is an open-source project and welcomes your contributions. For more information, see the GitHub repository.

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

shell
python3 -m pip install axiom-py
shell
py -m pip install axiom-py
shell
pip3 install axiom-py

If you use the Axiom CLI, run eval $(axiom config export -f) to configure your environment variables. Otherwise, create an API token and export it as AXIOM_TOKEN.

You can also configure the client using options passed to the client constructor:

python
import axiom_py

client = axiom_py.Client("API_TOKEN")

Use client

python
import axiom_py

client = axiom_py.Client()

client.ingest_events(
    dataset="DATASET_NAME",
    events=[
        {"foo": "bar"},
        {"bar": "baz"},
    ])
client.query(r"['DATASET_NAME'] | where foo == 'bar' | limit 100")

For more examples, see the examples in GitHub.

Configure region

By default, the client sends data to api.axiom.co. To target a specific edge region, pass the edge argument with the edge domain that matches the region your dataset lives in:

python
import axiom_py

client = axiom_py.Client(
    token="xaat-your-api-token",
    edge="eu-central-1.aws.edge.axiom.co",
)
python
import axiom_py

client = axiom_py.Client(
    token="xaat-your-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.

To point at a custom edge endpoint such as a proxy or load balancer, use edge_url="https://your-edge-host" instead. edge_url takes precedence over edge if both are set.

Info

Edge endpoints require an API token (xaat-), not a personal token (xapt-). Passing a personal token with edge configuration raises an error.

Warning

Edge configuration must be passed explicitly when you create the client. Unlike token and org_id, the edge and edge_url arguments are not read from environment variables.

Example with AxiomHandler

The example below uses AxiomHandler to send logs from the logging module to Axiom:

python
import axiom_py
from axiom_py.logging import AxiomHandler
import logging

def setup_logger():
    client = axiom_py.Client()
    handler = AxiomHandler(client, "DATASET_NAME")
    logging.getLogger().addHandler(handler)

For a full example, see GitHub.

Example with structlog

The example below uses structlog to send logs to Axiom. structlog isn't a dependency of the Axiom Python SDK, so install it separately with pip install structlog.

AxiomProcessor passes the event dictionary on unchanged so that later processors can run. Place a renderer such as structlog.dev.ConsoleRenderer() after it as the last processor. Without a renderer, structlog's logger receives a dictionary and raises a TypeError.

python
from axiom_py import Client
from axiom_py.structlog import AxiomProcessor
import structlog

def setup_logger():
    client = Client()

    structlog.configure(
        processors=[
            structlog.processors.add_log_level,
            structlog.processors.TimeStamper(fmt="iso", key="_time"),
            AxiomProcessor(client, "DATASET_NAME"),
            structlog.dev.ConsoleRenderer(),
        ]
    )

For a full example, see GitHub.

Was this page helpful?
Suggest edits on GitHub
On this page
Install SDKUse clientConfigure regionExample with AxiomHandlerExample with structlog