Skip to content

Latest commit

 

History

History

examples

Examples

This directory contains examples that showcase the usage of Axiom Go. Each example is a self-contained Go package that can be run with go run:

go run ./{example}

Before you start

Axiom Go and the adapters automatically pick up their configuration from the environment, if not otherwise specified. To learn more about configuration, check the documentation.

To quickstart, export the environment variables below.

Note

If you have the Axiom CLI installed and are logged in, you can easily export most of the required environment variables:

eval $(axiom config export -f)

Required environment variables

  • AXIOM_TOKEN: API or Personal token. Can be created under Settings > API Tokens or Profile. For security reasons it is advised to use an API token with minimal privileges only.
  • AXIOM_ORG_ID: Organization identifier of the organization to (when using a personal token).
  • AXIOM_DATASET: Dataset to use. Must exist prior to using it. You can use Axiom CLI to create a dataset: axiom dataset create.

Package usage

  • ingestevent: How to ingest events into Axiom.
  • ingestfile: How to ingest the contents of a file into Axiom and compress them on the fly.
  • ingesthackernews: How to ingest the contents of Hacker News into Axiom.
  • query: How to query a dataset using the Kusto-like Axiom Processing Language (APL).
  • querylegacy: How to query a dataset using the legacy query datatypes.

Adapter usage

  • apex: How to ship logs to Axiom using the popular Apex logging package.
  • logrus: How to ship logs to Axiom using the popular Logrus logging package.
  • slog: How to ship logs to Axiom using the standard libraries Slog structured logging package.
  • zap: How to ship logs to Axiom using the popular Zap logging package.

OpenTelemetry usage

  • otelinstrument: How to instrument the Axiom Go client using OpenTelemetry.
  • oteltraces: How to ship traces to Axiom using the OpenTelemetry Go SDK and the Axiom SDKs otel helper package.