Skip to main content

LogCLI Overview and Setup

1. Command-Line Interface for Loki

logcli provides a simple and efficient command-line interface (CLI) to query logs stored in Loki. It’s especially useful for users who prefer working in terminal environments or need to automate log queries.

2. Quick Access to Logs

It allows users to quickly query logs from their terminal without needing to open a full Grafana dashboard. This can be a time-saver, especially for troubleshooting or quick checks on logs.

3. Powerful Querying Capabilities

With logcli, you can run advanced queries using the same query language as in Grafana, which allows you to filter, aggregate, and view logs based on specific criteria, like time ranges or log levels.

4. Integration with Automation Scripts

Because it’s a CLI tool, logcli is easy to integrate into automation scripts, CI/CD pipelines, and monitoring workflows. It can be used to trigger alerts or log processing directly from scripts.

5. Lightweight and Efficient

logcli is lightweight and doesn’t require a browser or full Grafana UI, making it more resource-efficient for quick log investigations or automated tasks. It can be especially useful when working on remote systems or on resource-constrained environments.


Installation

You can download the LogCLI from the release page.

Steps to Install logcli:

  1. Visit the Loki Releases Page
    Go to the official Loki Releases page on GitHub.

  2. Download the Latest logcli Release

    • Scroll down to the "Assets" section for the latest release.
    • Download the appropriate binary for your operating system:
      • For Linux: logcli-linux-amd64
      • For macOS: logcli-darwin-amd64
      • For Windows: logcli-windows-amd64.exe
  3. Extract the Binary (if needed)
    If the binary is compressed (like in a .tar.gz file for Linux or macOS), extract it using the following commands:

    • On Linux/macOS:
      tar -xvf logcli-linux-amd64.tar.gz
    • On Windows, simply extract the .zip file.
  4. Move the Binary to a Directory in Your PATH
    To make logcli accessible globally, move the binary to a directory included in your system's PATH:

    • On Linux/macOS:
      sudo mv logcli-linux-amd64 /usr/local/bin/logcli
    • On Windows, move the binary to a folder like C:\Program Files\logcli\ and add that folder to your PATH environment variable.
  5. Verify the Installation
    Open a terminal or command prompt and run:

    logcli --version

    This should return the installed version of logcli, confirming the successful installation.