Skip to main content

Official bindings for the Axiom API

Project description

axiom-py

Axiom.co banner  

CI PyPI version Python version

Axiom unlocks observability at any scale.

  • Ingest with ease, store without limits: Axiom’s next-generation datastore enables ingesting petabytes of data with ultimate efficiency. Ship logs from Kubernetes, AWS, Azure, Google Cloud, DigitalOcean, Nomad, and others.
  • Query everything, all the time: Whether DevOps, SecOps, or EverythingOps, query all your data no matter its age. No provisioning, no moving data from cold/archive to “hot”, and no worrying about slow queries. All your data, all. the. time.
  • Powerful dashboards, for continuous observability: Build dashboards to collect related queries and present information that’s quick and easy to digest for you and your team. Dashboards can be kept private or shared with others, and are the perfect way to bring together data from different sources

For more information check out the official documentation and our community Discord.

Quickstart

Install using pip:

# Linux / MacOS
python3 -m pip install axiom-py

# Windows
py -m pip install axiom-py

Alternatively, if you have the pip package installed, you can install axiom-py with the following command:

pip3 install axiom-py

If you use the Axiom CLI, run eval $(axiom config export -f) to configure your environment variables.

Otherwise create a personal token in the Axiom settings and export it as AXIOM_TOKEN. Set AXIOM_ORG_ID to the organization ID from the settings page of the organization you want to access.

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

import axiom_py

client = axiom_py.Client("<api token>", "<org id>")

Create and use a client like this:

import axiom_py
import rfc3339
from datetime import datetime,timedelta

client = axiom_py.Client()

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

For more examples, see examples/client.py.

Logger

You can use the AxiomHandler to send logs from the logging module to Axiom like this:

import axiom_py
from axiom_py.logging import AxiomHandler
import logging


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

For a full example, see examples/logger.py.

If you use structlog, you can set up the AxiomProcessor like this:

from axiom_py import Client
from axiom_py.structlog import AxiomProcessor


def setup_logger():
    client = Client()

    structlog.configure(
        processors=[
            # ...
            structlog.processors.add_log_level,
            structlog.processors.TimeStamper(fmt="iso", key="_time"),
            AxiomProcessor(client, "my-dataset"),
            # ...
        ]
    )

For a full example, see examples/structlog.py.

Contributing

This project uses uv for dependency management and packaging, so make sure that this is installed.

To lint and format files before commit, run uvx pre-commit install.

License

Distributed under MIT License (The MIT License).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

axiom_py-0.8.1.tar.gz (87.3 kB view details)

Uploaded Source

Built Distribution

axiom_py-0.8.1-py3-none-any.whl (19.9 kB view details)

Uploaded Python 3

File details

Details for the file axiom_py-0.8.1.tar.gz.

File metadata

  • Download URL: axiom_py-0.8.1.tar.gz
  • Upload date:
  • Size: 87.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for axiom_py-0.8.1.tar.gz
Algorithm Hash digest
SHA256 759fe959a06dc8bfb687266cb76d1cf7cb5f22b55b96a5dfb5d8b89b2895f578
MD5 c1162dff8ab5444632e7dbe1e9fefd24
BLAKE2b-256 819708552352f5e3403bf6634be9d51bf39c8ad2d0496e276c77e8ca621660a4

See more details on using hashes here.

File details

Details for the file axiom_py-0.8.1-py3-none-any.whl.

File metadata

  • Download URL: axiom_py-0.8.1-py3-none-any.whl
  • Upload date:
  • Size: 19.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for axiom_py-0.8.1-py3-none-any.whl
Algorithm Hash digest
SHA256 162297d7e27cd373eacc2a615dfb93e7e1e11a0fd85cbe311022eed1510a80f1
MD5 58e5c31a799c9ee68bb292198082389f
BLAKE2b-256 d98ba781380cce9b37d701ba80cae4256fae012e3694697c89011d5a26dc8dbc

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page