2021-11-30

Query Logs with Axiom CLI

Tola Ore-Aruwaji
@thecraftman_

Monitoring your infrastructure resources is every organization's need. Every server, backend, Kubernetes resource, and application generates tons of logs every day. Axiom CLI helps you store and query insights from the data collected from various data sources on Axiom. Running queries with Axiom CLI helps you find errors and issues in your application.

Axiom CLI querying provides a centralized CLI for interactive diagnostic logs search for your applications, Kubernetes workloads, CloudStack, and backend. Using Axiom CLI, you can explore and analyze your logs by running queries that make it easy to understand and visualize your logs instantly.

Prerequisites 🛠

Let's keep moving 🤩

To query logs using the Axiom CLI, you need to ingest logs into Axiom with any of our data shippers. You also need to create a dataset and an ingest token.

  1. Install and download Axiom CLI on your local machine.

  2. Next, create a new dataset, go to Settings → Datasets on the Axiom UI.

1.png

  • You can also create your dataset on the Axiom CLI by typing axiom dataset create on your terminal and entering the name of your dataset.

1b.png

  1. Generate your ingest token. Visit our docs to learn how you can generate ingest tokens.

  2. Validate the installation of Axiom CLI by typing axiom-v in your terminal.

2.png

  1. Login to your Axiom Deployment using axiom auth login
  • Choose the kind of Deployment you want to use and enter your deployment URL.

3.png

  • Enter your ingest or personal token.

4.png

  • When you are done, you will get the check mark that you've been logged in.

5.png

  1. Next, ingest your data logs into Axiom. You can use any of our data-shippers to ingest logs or use our CLI. To ingest logs using the CLI type in axiom ingest --help in your terminal.
  • Remember that your dataset name will be the name of the dataset you created in step 1. In the image below, the dataset name is nginx-logs

6.png

  1. Next, use the query command axiom query <dataset_name> to query your logs using APL.

6.png

  • The name of my dataset I created in step 1 is http-logs so if I want to query it using Axiom CLI it will be axiom query "['http-logs']" If you have a dataset that has special characters like - you would have to include the quoted marks like this "['http-logs']"

8.png

  • Get the history of all your logs in your dataset.

6.png

  • Query using APL directly on your terminal.

6.png

You can see the output of the logs below:

6.png

  • Run more Queries in your CLI using APL

6.png

  • Output of the Query:

6.png

  1. There are other commands you can run on the Axiom CLI like:
  • Live stream your data using axiom stream <dataset_name>

  • Select an Axiom deployment using axiom auth select

8.png

  • Get info about a dataset using axiom dataset info

8.png

  • Select your dataset you want to get info from

8.png


What’s next? 😇

There is a lot that Axiom CLI can do to help you be more productive when creating, managing, and building your Axiom Projects. A good place to look for more tips is in the help provided by the CLI itself. I’d recommend digging around:

# Overview of commands available 

axiom help 

# More specific help for a given command

axiom help [command]

You can also explore the code repository for the Axiom CLI on GitHub.

References for the road

Happy CLI-ing!

Join us in changing how developers think about data