axiom-go

module
v0.6.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 28, 2021 License: MIT

README

Axiom Go

Go Reference Go Workflow Coverage Status Go Report Latest Release License


Table of Contents

  1. Introduction
  2. Installation
  3. Authentication
  4. Usage
  5. Documentation
  6. Contributing
  7. License

Introduction

Axiom Go is a Go client library for accessing the Axiom API.

Currently, Axiom Go requires Go 1.16 or greater.

Installation

Install using go get
go get github.com/axiomhq/axiom-go/axiom
Install from source
git clone https://github.com/axiomhq/axiom-go.git
cd axiom-go
make # Run code generators, linters, sanitizers and test suits

Authentication

The Client is initialized with the url of the deployment and an access token. The access token can be a personal token retrieved from the users profile page or an ingest token retrieved from the settings of the Axiom deployment.

The personal access token grants access to all resources available to the user on his behalf.

The ingest token just allows ingestion into the datasets the token is configured for.

Usage

// Export `AXIOM_TOKEN` and `AXIOM_ORG_ID` for Axiom Cloud
// Export `AXIOM_URL` and `AXIOM_TOKEN` for Axiom Selfhost

// 1. Open the file to ingest.
f, err := os.Open("logs.json")
if err != nil {
	log.Fatal(err)
}
defer f.Close()

// 2. Wrap it in a gzip enabled reader.
r, err := axiom.GZIPStreamer(f, gzip.BestSpeed)
if err != nil {
	log.Fatal(err)
}

// 3. Initialize the Axiom API client.
client, err := axiom.NewClient()
if err != nil {
	log.Fatal(err)
}

// 4. Ingest ⚡
// Note the JSON content type and GZIP content encoding being set because
// the client does not auto sense them.
res, err := client.Datasets.Ingest(context.Background(), "test", r, axiom.JSON, axiom.GZIP, axiom.IngestOptions{})
if err != nil {
	log.Fatal(err)
}

// 5. Make sure everything went smoothly.
for _, fail := range res.Failures {
	log.Print(fail.Error)
}

For more sample code snippets, head over to the examples directory.

Documentation

You can find the Axiom and Axiom Go documentation on the docs website.

The documentation is divided into several sections:

Contributing

The main aim of this repository is to continue developing and advancing Axiom Go, making it faster and more simplified to use. Kindly check our contributing guide on how to propose bugfixes and improvements, and submitting pull requests to the project.

License

© Axiom, Inc., 2021

Distributed under MIT License (The MIT License).

See LICENSE for more information.

License Status

Directories

Path Synopsis
Package adapters provides packages which implement integration into well known Go logging libraries.
Package adapters provides packages which implement integration into well known Go logging libraries.
zap
Package axiom implements Go bindings for the Axiom API.
Package axiom implements Go bindings for the Axiom API.
apl
Package apl provides the datatypes for construction APL.
Package apl provides the datatypes for construction APL.
query
Package query provides the datatypes for construction queries and working with their results.
Package query provides the datatypes for construction queries and working with their results.
Package examples contains code examples on how to use Axiom Go.
Package examples contains code examples on how to use Axiom Go.
apex
The purpose of this example is to show how to integrate with apex.
The purpose of this example is to show how to integrate with apex.
ingestfile
The purpose of this example is to show how to stream the contents of a JSON logfile and gzip them on the fly.
The purpose of this example is to show how to stream the contents of a JSON logfile and gzip them on the fly.
logrus
The purpose of this example is to show how to integrate with logrus.
The purpose of this example is to show how to integrate with logrus.
query
The purpose of this example is to show how to query a dataset using the Axiom Processing Language (APL).
The purpose of this example is to show how to query a dataset using the Axiom Processing Language (APL).
zap
The purpose of this example is to show how to integrate with zap.
The purpose of this example is to show how to integrate with zap.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL