Query Loki Logs with LogQL
Loki MCP Server for AI assistants to query and analyze logs using LogQL, with automatic HTTP API fallback.
Why it matters
Empower AI assistants to query and analyze logs stored in Grafana Loki using LogQL. This connector automatically falls back to the HTTP API if the logcli tool is unavailable.
Outcomes
What it gets done
Query Loki logs using LogQL syntax with filtering.
Retrieve all values for a specific log label.
Fetch all available log labels.
Configure authentication via environment variables or files.
Install
Add it to your toolbox
Run in your project directory:
curl -fsSL https://spark.entire.vc/get/vb-simple-loki-mcp | bash Capabilities
Tools your agent gets
Query logs from Loki with filtering options using LogQL syntax
Get all values for a specific label
Get all available labels
Overview
Simple Loki MCP Server
What it does
This MCP server provides AI assistants with the capability to query and analyze logs stored in Grafana Loki. It supports the full LogQL syntax for detailed log filtering and retrieval. The connector includes tools to fetch all values for a specific label and to list all available labels within Loki.
How it connects
Use this MCP server when you need to integrate AI assistants with Grafana Loki for log analysis and troubleshooting. It is particularly useful when logcli is unavailable, as it automatically falls back to using the Loki HTTP API.
Source README
MCP server that provides AI assistants with access to query and analyze logs from Grafana Loki using LogQL, with automatic fallback to HTTP API when logcli is unavailable.
Installation
Smithery
npx -y @smithery/cli install @ghrud92/simple-loki-mcp --client claude
NPX
npx -y simple-loki-mcp
From Source
git clone https://github.com/ghrud92/loki-mcp.git
cd loki-mcp
npm install
npm run build
Configuration
MCP Configuration
{
"mcpServers": {
"simple-loki": {
"command": "npx",
"args": ["-y", "simple-loki-mcp"],
"env": {
"LOKI_ADDR": "https://loki.sup.band"
}
}
}
}
Available Tools
| Tool | Description |
|---|---|
query-loki |
Query logs from Loki with filtering options using LogQL syntax |
get-label-values |
Get all values for a specific label |
get-labels |
Get all available labels |
Features
- Query Loki logs with full LogQL support
- Get label values and metadata
- Support for authentication and configuration via environment variables or configuration files
- Provides formatted results in various output formats (default, raw, JSON lines)
- Automatic fallback to HTTP API when logcli is unavailable in the environment
Environment Variables
Required
LOKI_ADDR- Loki server address (URL)
Optional
LOKI_USERNAME- Username for basic authenticationLOKI_PASSWORD- Password for basic authenticationLOKI_TENANT_ID- Tenant ID for multi-tenant LokiLOKI_BEARER_TOKEN- Bearer token for authenticationLOKI_BEARER_TOKEN_FILE- File containing bearer tokenLOKI_CA_FILE- Custom CA file for TLSLOKI_CERT_FILE- Client certificate file for TLSLOKI_KEY_FILE- Client key file for TLS
Notes
Requires Node.js v16 or higher. Uses Grafana Loki logcli if available in PATH, otherwise automatically falls back to HTTP API. Supports YAML configuration files for authentication settings.
Discussion
Questions & comments · 0
Sign In Sign in to leave a comment.