talkops-loki-mcp-server

v0.2.1
talkops-loki-mcp-server Checked 16 hours ago Published 13 days ago

A Model Context Protocol (MCP) server for Grafana Loki log observability.

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

loki_get_labels Get Loki Indexed Labels

List all indexed label names in Grafana Loki over an optional time window. Read-only.

ParameterTypeDescription
endEnd timestamp (RFC3339 or relative like 'now')
org_idOptional tenant ID (X-Scope-OrgID) for multi-tenant Loki
startStart timestamp (RFC3339 or relative like 'now-24h')

loki_get_label_values Get Loki Label Values

Retrieve values for a specific indexed label in Grafana Loki, optionally scoped by stream selector. Read-only.

ParameterTypeDescription
label *stringIndexed label name to retrieve values for (from loki_get_labels)
endEnd timestamp (RFC3339 or relative)
org_idOptional tenant ID (X-Scope-OrgID) for multi-tenant Loki
queryOptional LogQL stream selector to scope values (e.g., '{namespace="prod"}')
startStart timestamp (RFC3339 or relative)

loki_get_series Get Active Loki Log Streams

Return active Loki log stream label sets and per-label cardinality for a stream selector. Read-only.

ParameterTypeDescription
match *stringLogQL stream selector (MUST start with '{', e.g., '{app="checkout"}')
endEnd timestamp (RFC3339 or relative)
org_idOptional tenant ID (X-Scope-OrgID) for multi-tenant Loki
startStart timestamp (RFC3339 or relative)

loki_get_log_patterns Get Loki Log Patterns

Retrieve recurring structural `<_>` log patterns and line counts from Loki's pattern ingester. Read-only.

ParameterTypeDescription
query *stringLogQL stream selector (e.g., '{app="checkout"}')
endstringEnd timestamp (RFC3339 or relative)
org_idOptional tenant ID (X-Scope-OrgID) for multi-tenant Loki
startstringStart timestamp (RFC3339 or relative)

loki_get_detected_fields Get Loki Detected Fields

Discover structured metadata, JSON keys, and logfmt fields with types and cardinalities in Loki 3.x streams. Read-only.

ParameterTypeDescription
query *stringLogQL stream selector (e.g., '{app="checkout"}')
endEnd timestamp (RFC3339 or relative)
field_limitMax fields to return (default: 1000)
line_limitMax log lines to scan per shard (default: 100)
org_idOptional tenant ID (X-Scope-OrgID) for multi-tenant Loki
startStart timestamp (RFC3339 or relative)

loki_get_query_stats Get Loki Query Cost Stats

Estimate streams, chunks, entries, and uncompressed bytes touched by a LogQL selector before execution. Read-only.

ParameterTypeDescription
query *stringLogQL stream selector wrapped in curly braces (e.g., '{app="checkout"}')
endEnd timestamp (RFC3339 or relative)
org_idOptional tenant ID (X-Scope-OrgID) for multi-tenant Loki
startStart timestamp (RFC3339 or relative)

loki_query_instant Execute Loki Instant Query

Evaluate a LogQL metric or stream query at a single point in time. Read-only.

ParameterTypeDescription
query *stringLogQL query containing a stream selector wrapped in braces (e.g., 'rate({app="checkout"} |= "error" [5m])')
directionSort order: 'forward' or 'backward' (default backward)
limitMaximum log entries (default 100)
org_idOptional tenant ID (X-Scope-OrgID) for multi-tenant Loki
timeEvaluation timestamp (RFC3339 or relative). Defaults to 'now'.

loki_query_range Execute Loki Range Query

Execute a LogQL range query returning log streams or metric time-series matrices with cost guardrails. Read-only.

ParameterTypeDescription
query *stringLogQL query containing a stream selector wrapped in braces (e.g., '{app="checkout"} |= "error" | json')
directionSort order: 'forward' or 'backward' (default backward)
endstringEnd timestamp (RFC3339 or relative like 'now')
max_log_linesintegerMax log lines to return for stream queries (default: 100, max: 1000)
org_idOptional tenant ID (X-Scope-OrgID) for multi-tenant Loki
startstringStart timestamp (RFC3339 or relative like 'now-1h')
stepStep for metric queries (e.g., '30s', '5m'). Auto-computed if omitted.

loki_query_a2ui A2UI Log Table Query

Execute a LogQL range query and flatten results into an interactive A2UI log table payload. Read-only.

ParameterTypeDescription
query *stringLogQL stream query formatted with '| json' or '| logfmt' and '| line_format' for A2UI table rendering
title *stringThe title for the A2UI log table
endstringEnd timestamp (RFC3339 or relative like 'now')
max_log_linesintegerMax log lines to return (default: 100).
org_idOptional tenant ID (X-Scope-OrgID)
startstringStart timestamp (RFC3339 or relative like 'now-1h')

loki_summarize_service_logs Summarize Service Logs (N-to-1 Triage)

Compute a high-signal service log health & error summary in one call. Aggregates index stats, total log rate, error rate/ratio, top recurring error signatures, sample error lines, and extracted `trace_id` values for cross-pillar pivoting to Tempo. Read-only.

ParameterTypeDescription
selector *stringLogQL stream selector wrapped in braces (e.g., '{app="checkout"}')
endstringEnd timestamp (RFC3339 or relative like 'now')
error_patternstringRegex line filter used to identify error log lines
org_idOptional tenant ID (X-Scope-OrgID)
sample_limitintegerMax sample error log lines to include (1-50)
startstringStart timestamp (RFC3339 or relative like 'now-1h')

loki_compare_periods Compare Log Periods or Deployments (N-to-1 Diff)

Compare log volume, error counts, and error signatures across two windows or versions. Detects newly emerging error signatures after a deployment or incident onset without requiring multiple sequential tool calls. Read-only.

ParameterTypeDescription
selector *stringCurrent LogQL stream selector (e.g., '{app="checkout"}')
baseline_offsetLookback offset for baseline comparison (e.g., '1h', '24h'). Defaults to '0s' when baseline_selector differs from selector, else '1h'.
baseline_selectorOptional distinct baseline selector (e.g., '{app="checkout", version="v1"}')
endstringCurrent window end (e.g., 'now')
error_filterstringSubstring or regex filter for error lines (default: 'error')
org_idOptional tenant ID (X-Scope-OrgID)
startstringCurrent window start (e.g., 'now-15m')

loki_correlate_trace_logs Correlate Logs by Trace or Request ID

Find and chronologically order all logs matching a trace_id or request_id. Enforces Loki cardinality guardrails by querying via structured metadata or line filter (`|= "<correlation_id>"`) outside `{}` stream selectors. Returns participating services and timeline entries for Tempo handoff.

ParameterTypeDescription
correlation_id *stringTrace ID, Span ID, or Request ID to search across services (e.g., '4bf92f3577b34da6a3ce929d0e0e4736')
correlation_keystringStructured metadata / JSON key name (e.g., 'trace_id', 'request_id', 'span_id')
endstringEnd timestamp (RFC3339 or relative like 'now')
org_idOptional tenant ID (X-Scope-OrgID)
scope_selectorstringLow-cardinality stream selector scope (never put trace_id in {})
startstringStart timestamp (RFC3339 or relative like 'now-1h')

loki_analyze_volume Analyze Log Volume & FinOps Attribution

Attribute ingested log bytes and stream counts by label for FinOps optimization. Queries `/loki/api/v1/index/volume` and falls back to `topk(limit, sum by (target_label) (bytes_over_time(...)))` if the Index Volume endpoint is disabled on the Loki backend. Read-only.

ParameterTypeDescription
query *stringLogQL stream selector to analyze volume for (e.g., '{namespace="prod"}')
aggregate_bystringAggregation mode for /loki/api/v1/index/volume ('labels' or 'series')
endstringEnd timestamp (RFC3339 or relative like 'now')
limitintegerMax top volume series to return (default: 20)
org_idOptional tenant ID (X-Scope-OrgID)
startstringStart timestamp (RFC3339 or relative like 'now-6h')
target_labelstringLabel dimension to group byte volume by (e.g., 'app', 'namespace', 'level')

loki_get_diagnostics Get Loki Backend & Ingestion Diagnostics

Diagnose Loki backend readiness, build version, and discarded log sample reasons. Inspects `/ready`, `/loki/api/v1/status/buildinfo`, and `/metrics` (`loki_discarded_samples_total` by `reason`) to identify rate limiting, stream cardinality limits, or out-of-order/too-old log drops. Read-only.

ParameterTypeDescription
include_metricsbooleanScrape /metrics for loki_discarded_samples_total and ingester chunk counts
org_idOptional tenant ID (X-Scope-OrgID)
selectorOptional stream selector to check recent 1h index stats for (e.g., '{app="checkout"}')