November 30, 2021

#engineering

Query Logs with Axiom CLI


Blog Screenshot
Author
Tola Ore-Aruwaji

Developer Relations Engineer

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.

  • 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.

  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.

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

  • Enter your ingest or personal token.

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

  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

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

  • 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']"

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

  • Query using APL directly on your terminal.

You can see the output of the logs below:

  • Run more Queries in your CLI using APL

  • Output of the Query:

  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

  • Get info about a dataset using axiom dataset info

  • Select your dataset you want to get info from


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!

Share
Get started with Axiom

Learn how to start ingesting, streaming, and
querying data into Axiom in less than 10 minutes.