Axiom Go adapter for Logrus
This page explains how to send logs generated by the sirupsen/logrus library to Axiom.
Use the adapter of the Axiom Go SDK to send logs generated by the sirupsen/logrus library to Axiom.
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.
Set up SDK
-
Install the Axiom Go SDK and configure your environment as explained in Send data from Go app to Axiom.
-
In your Go app, import the
logruspackage. It’s imported as anadapterso that it doesn’t conflict with thesirupsen/logruspackage.import adapter "github.com/axiomhq/axiom-go/adapters/logrus"
Alternatively, configure the adapter using options passed to the New function:
hook, err := adapter.New(
adapter.SetDataset("DATASET_NAME"),
)Replace DATASET_NAME with the name of the Axiom dataset where you send your data.
Configure client
To configure the underlying client manually, choose one of the following:
- Use SetClient to pass in the client you have previously created with Send data from Go app to Axiom.
- Use SetClientOptions to pass client options to the adapter.
import (
"github.com/axiomhq/axiom-go/axiom"
adapter "github.com/axiomhq/axiom-go/adapters/logrus"
)
// ...
hook, err := adapter.New(
adapter.SetClientOptions(
axiom.SetPersonalTokenConfig("AXIOM_TOKEN"),
),
)Configure region
By default, the adapter sends data to api.axiom.co. To target a specific edge region, pass axiom.SetEdge through SetClientOptions with the edge domain that matches the region your dataset lives in:
hook, err := adapter.New(
adapter.SetClientOptions(
axiom.SetAPITokenConfig("xaat-your-api-token"),
axiom.SetEdge("eu-central-1.aws.edge.axiom.co"),
),
)hook, err := adapter.New(
adapter.SetClientOptions(
axiom.SetAPITokenConfig("xaat-your-api-token"),
axiom.SetEdge("us-east-1.aws.edge.axiom.co"),
),
)The following edge domains are available:
| Edge deployment | Base 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 |
Reference
For a full reference of the adapter’s functions, see the Go Packages page.