Skip to content

Commit

Permalink
Merge pull request #150 from axiomhq/arne/simplify-readme
Browse files Browse the repository at this point in the history
Simplify README.md
  • Loading branch information
dasfmi authored Oct 23, 2024
2 parents 6fb1931 + edd858f commit c9ec206
Showing 1 changed file with 9 additions and 114 deletions.
123 changes: 9 additions & 114 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,132 +1,27 @@
# axiom-py

<a href="https://axiom.co">
<picture>
<source media="(prefers-color-scheme: dark) and (min-width: 600px)" srcset="https://axiom.co/assets/github/axiom-github-banner-light-vertical.svg">
<source media="(prefers-color-scheme: light) and (min-width: 600px)" srcset="https://axiom.co/assets/github/axiom-github-banner-dark-vertical.svg">
<source media="(prefers-color-scheme: dark) and (max-width: 599px)" srcset="https://axiom.co/assets/github/axiom-github-banner-light-horizontal.svg">
<img alt="Axiom.co banner" src="https://axiom.co/assets/github/axiom-github-banner-dark-horizontal.svg" align="right">
</picture>
</a>
&nbsp;

[![CI][ci_badge]][ci]
[![PyPI version][pypi_badge]][pypi]
[![Python version][version_badge]][pypi]

[Axiom](https://axiom.co) 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](https://axiom.co/docs)
and our
[community Discord](https://axiom.co/discord).

## Quickstart

Install using `pip`:

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

# Windows
py -m pip install axiom-py
```

Alternatively, if you have the [`pip`](https://pip.pypa.io/) package installed, you can install `axiom-py` with the following command:

```bash
pip3 install axiom-py
```

If you use the [Axiom CLI](https://github.com/axiomhq/cli), run `eval $(axiom config export -f)` to configure your environment variables.

Otherwise create a personal token in [the Axiom settings](https://cloud.axiom.co/profile) 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:

```py
import axiom_py

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

Create and use a client like this:
# axiom-py [![CI][ci_badge]][ci] [![PyPI version][pypi_badge]][pypi] [![Python version][version_badge]][pypi]

```py
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`](examples/client_example.py).

## Logger

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

```python
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)
client.ingest_events(dataset="DATASET_NAME", events=[{"foo": "bar"}, {"bar": "baz"}])
client.query(r"['DATASET_NAME'] | where foo == 'bar' | limit 100")
```

For a full example, see [`examples/logger.py`](examples/logger_example.py).

If you use [structlog](https://github.com/hynek/structlog), you can set up the
`AxiomProcessor` like this:

```python
from axiom_py import Client
from axiom_py.structlog import AxiomProcessor
## Install


def setup_logger():
client = Client()

structlog.configure(
processors=[
# ...
structlog.processors.add_log_level,
structlog.processors.TimeStamper(fmt="iso", key="_time"),
AxiomProcessor(client, "my-dataset"),
# ...
]
)
```sh
pip install axiom-py
```

For a full example, see [`examples/structlog.py`](examples/structlog_example.py).

## Contributing

This project uses [uv](https://docs.astral.sh/uv) for dependency management
and packaging, so make sure that this is installed.
## Documentation

To lint and format files before commit, run `uvx pre-commit install`.
Read documentation on [axiom.co/docs/guides/python](https://axiom.co/docs/guides/python).

## License

Distributed under MIT License (`The MIT License`).
[MIT](./LICENSE)

<!-- Badges -->

Expand Down

0 comments on commit c9ec206

Please sign in to comment.