loki
Grafana Loki log aggregation and LogQL query language. Covers LogQL syntax (log queries, metric queries, label matchers, line filters, parsers: json/logfmt/pattern/regexp/unpack, label filters, line_format), Loki architecture, log ingestion via Alloy/Promtail/Fluent Bit, structured metadata, and Logs Drilldown. Use when writing LogQL queries, configuring Loki, troubleshooting log pipelines, or analyzing logs.
Security Assessment
Detected risks:
About loki
A reference for Grafana Loki, the log aggregation system, and its LogQL query language. It is meant for writing LogQL queries, configuring Loki, troubleshooting log pipelines, and analyzing logs, and it opens with the key design point that Loki indexes only metadata labels rather than full log content, which makes it dramatically cheaper than full-text search systems.
The bulk of the material is a LogQL quick reference. It covers the required log stream selector with exact, negated, and regex label matchers; line filters for substring and regex matching placed first for performance; and parsers including json, logfmt, pattern, regexp, and unpack. It then shows label filters with numeric and logical comparisons, line_format and label_format templating, dropping and keeping labels, and decolorize. Metric queries include log range aggregations such as rate, count_over_time, and bytes_rate, grouping aggregations like sum, topk, and by clauses, unwrapped range aggregations for numeric values with quantile and average, and the offset modifier for time comparisons. Practical examples cover error-rate alerts, slow-request extraction, HTTP 5xx detail, and credential-leak detection.
Beyond querying, it documents sending logs to Loki via Grafana Alloy, including a Kubernetes DaemonSet configuration and the Loki HTTP push API, and outlines the architecture with the distributor, ingester, querier, query frontend, and compactor along the push and read paths. Companion reference files cover LogQL, configuration, and sending data in more depth. Use it as a practical companion for building queries and operating a Loki logging pipeline.
FAQ
What is LogQL used for?
Querying logs in Grafana Loki, using stream selectors, line filters, parsers, label filters, and metric queries.
Which parsers does LogQL support?
json, logfmt, pattern, regexp, and unpack.
Why is Loki cheaper than full-text log search?
Because it indexes only metadata labels rather than the full log content.
How do you send logs to Loki?
Through Grafana Alloy, including a Kubernetes DaemonSet, or via the Loki HTTP push API, with ingestion also supported through Promtail and Fluent Bit.
What are Loki main components?
The distributor, ingester, querier, query frontend, and compactor.
Install loki
Quick Setup:
- Copy the skill folder to
.claude/skills/ - Claude will automatically detect and use the skill
Repository
grafana/skills