loki
БесплатноБез исполняемых скриптовНе проверенLoki is a horizontally scalable log aggregation system built by Grafana Labs. Unlike traditional log platforms that index the full text of every log line…
от TerminalSkills★ 221 звезда на GitHubОб этом скилле
Loki
Overview
Loki indexes only the labels attached to log streams; the log lines themselves are compressed into chunks. Writes are fast and storage is cheap, and LogQL (a PromQL-like language) still lets you filter, parse and aggregate lines. This skill covers a single-node Docker deployment (Loki 3.7), shipping logs with Grafana Alloy, LogQL queries, and the Grafana integration.
Promtail reached end of life on 2 March 2026 and receives no updates. Use Grafana Alloy as the agent. Existing Promtail configs convert with alloy convert --source-format=promtail --output=config.alloy promtail.yml.
Instructions
Deploy Loki and Alloy with Docker Compose
# docker-compose.yml
services:
loki:
image: grafana/loki:3.7.9
ports:
- "127.0.0.1:3100:3100" # Loki has no authentication; do not expose it publicly
volumes:
- ./loki-config.yml:/etc/loki/config.yml:ro
- loki-data:/loki
command: -config.file=/etc/loki/config.yml
alloy:
image: grafana/alloy:v1.21.2
volumes:
- ./config.alloy:/etc/alloy/config.alloy:ro
- /var/run/docker.sock:/var/run/docker.sock:ro
- /var/log/myapp:/var/log/myapp:ro
command: run --server.http.listen-addr=0.0.0.0:12345 --storage.path=/var/lib/alloy/data /etc/alloy/config.alloy
depends_on:
- loki
volumes:
loki-data:
Read access to the Docker socket is effectively root on the host. Mount it only on hosts where that is acceptable.
Loki configuration
Single instance, filesystem storage, 30-day retention. Retention needs compactor.delete_request_store; without it Loki 3.x refuses to start ("delete-request-store should be configured when retention is enabled"). Schema v13 with tsdb is the current one.
# loki-config.yml
auth_enabled: false
server:
http_listen_port: 3100
common:
ring:
instance_addr: 127.0.0.1
kvstore:
store: inmemory
replication_factor: 1
path_prefix: /loki
schema_config:
configs:
- from: "2024-01-01"
store: tsdb
object_store: filesystem
schema: v13
index:
prefix: index_
period: 24h
storage_config:
filesystem:
directory: /loki/chunks
limits_config:
retention_period: 720h
max_query_series: 5000
compactor:
working_directory: /loki/compactor
retention_enabled: true
delete_request_store: filesystem
After start, curl http://127.0.0.1:3100/ready answers ready (it says "Ingester not ready: waiting for 15s" for the first 15 seconds). To test without an agent, push a line:
curl -s -X POST -H 'Content-Type: application/json' http://127.0.0.1:3100/loki/api/v1/push \
-d "{\"streams\":[{\"stream\":{\"service\":\"api\",\"job\":\"myapp\"},\"values\":\"$(date +%s%N)\",\"{\\\"level\\\":\\\"error\\\",\\\"status\\\":502,\\\"duration_ms\\\":1500}\"}]}"
A 204 means accepted. Query with curl -G http://127.0.0.1:3100/loki/api/v1/query_range --data-urlencode 'query={service="api"}'.
Grafana Alloy agent
Alloy discovers targets, attaches labels and pushes to Loki. This config reads Docker container logs and JSON files:
// config.alloy
discovery.docker "containers" {
host = "unix:///var/run/docker.sock"
}
discovery.relabel "containers" {
targets = discovery.docker.containers.targets
rule {
source_labels = ["__meta_docker_container_name"]
regex = "/(.+)"
target_label = "container"
}
rule {
source_labels = ["__meta_docker_container_label_com_docker_compose_service"]
target_label = "service"
}
}
loki.source.docker "containers" {
host = "unix:///var/run/docker.sock"
targets = discovery.relabel.containers.output
forward_to = [loki.write.default.receiver]
}
local.file_match "myapp" {
path_targets = [{"__path__" = "/var/log/myapp/*.log", "job" = "myapp", "host" = "production-1"}]
}
loki.source.file "myapp" {
targets = local.file_match.myapp.targets
forward_to = [loki.process.myapp.receiver]
}
loki.process "myapp" {
stage.json {
expressions = { level = "level", status = "status", duration = "duration_ms", ts = "timestamp" }
}
stage.labels {
values = { level = "" } // low-cardinality fields only
}
stage.timestamp {
source = "ts"
format = "RFC3339"
}
forward_to = [loki.write.default.receiver]
}
loki.write "default" {
endpoint {
url = "http://loki:3100/loki/api/v1/push"
}
}
Check a config before deploying with alloy validate config.alloy and format it with alloy fmt. The Alloy UI listens on port 12345 and shows component health.
LogQL
A query starts with a stream selector in braces, then optional line filters, parsers and label filters.
{service="api"} # all lines of a service
{service="api"} |= "timeout" | json | level="error" # contains text, JSON-parsed, label filter
{service="api"} |~ "POST|PUT" !~ "/healthz" # regex include, regex exclude
{service="api"} | json |
Установить loki в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл loki?
Loki is a horizontally scalable log aggregation system built by Grafana Labs. Unlike traditional log platforms that index the full text of every log line, Loki indexes only metadata labels, making it significantly cheaper to operate. Use when someone asks to "set up Loki", "ship Docker logs to Loki", "write a LogQL query", "replace Promtail with Alloy", or "show logs in Grafana".
Как установить скилл loki?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл loki запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
от Anthropicacademy-guide
Stop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
от Anthropicinternal-comms
A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
от Anthropicskill-development
This skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…
от Anthropic