i18n/de/skills/configure-log-aggregation/SKILL.md
Zentralisierte Log-Aggregation mit Loki und Promtail (oder ELK-Stack) einrichten, einschliesslich Log-Parsing, Label-Extraktion, Aufbewahrungsrichtlinien und Integration mit Metriken zur Korrelation. Verwenden, wenn Logs aus mehreren Services in einem durchsuchbaren System zusammengefuehrt werden sollen, lokale Log-Dateien durch zentralen abfragbaren Speicher ersetzt werden, Logs mit Metriken und Traces korreliert werden, strukturiertes Logging mit Label-Extraktion implementiert wird oder Produktionsvorfaelle eine serviceuebergreifende Log-Analyse erfordern.
npx skillsauth add pjt222/agent-almanac configure-log-aggregationInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Zentrale Log-Sammlung, -Parsing und -Abfrage mit Loki/Promtail oder ELK-Stack fuer operationelle Sichtbarkeit implementieren.
Unter Extended Examples sind vollstaendige Konfigurationsdateien und Templates verfuegbar.
Zwischen Loki (Prometheus-Stil) und ELK (Elasticsearch-basiert) basierend auf den Anforderungen waehlen.
Loki-Vorteile:
ELK-Vorteile:
Fuer diese Anleitung liegt der Fokus auf Loki + Promtail (empfohlen fuer die meisten modernen Setups).
Entscheidungskriterien:
Use Loki if:
- You want label-based queries similar to Prometheus
- Storage costs are a concern (Loki indexes only labels)
- You already use Grafana for metrics
- Kubernetes/container-native deployment
Use ELK if:
- You need full-text search across all log content
- You have complex log parsing and enrichment requirements
- You require advanced analytics and aggregations
- Legacy systems with existing Logstash pipelines
Erwartet: Klare Entscheidung basierend auf Anforderungen getroffen, Team laedt geeignete Installationsartefakte herunter.
Bei Fehler:
Loki mit geeignetem Speicher-Backend installieren und konfigurieren.
Docker-Compose-Deployment (docker-compose.yml):
version: '3.8'
services:
loki:
image: grafana/loki:2.9.0
ports:
- "3100:3100"
volumes:
- ./loki-config.yml:/etc/loki/local-config.yaml
- loki-data:/loki
command: -config.file=/etc/loki/local-config.yaml
restart: unless-stopped
promtail:
image: grafana/promtail:2.9.0
volumes:
- ./promtail-config.yml:/etc/promtail/config.yml
- /var/log:/var/log:ro
- /var/lib/docker/containers:/var/lib/docker/containers:ro
command: -config.file=/etc/promtail/config.yml
restart: unless-stopped
depends_on:
- loki
volumes:
loki-data:
Loki-Konfiguration (loki-config.yml):
auth_enabled: false
server:
http_listen_port: 3100
grpc_listen_port: 9096
# ... (see EXAMPLES.md for complete configuration)
Fuer Produktion mit S3-Speicher:
storage_config:
aws:
s3: s3://us-east-1/my-loki-bucket
s3forcepathstyle: true
boltdb_shipper:
active_index_directory: /loki/index
cache_location: /loki/cache
shared_store: s3
Erwartet: Loki startet erfolgreich, Health-Check besteht unter http://localhost:3100/ready, Logs werden gemaess Aufbewahrungsrichtlinie gespeichert.
Bei Fehler:
docker logs lokidocker run grafana/loki:2.9.0 -config.file=/etc/loki/local-config.yaml -verify-configPromtail einrichten, um Logs zu scrapen und mit Label-Extraktion an Loki weiterzuleiten.
Promtail-Konfiguration (promtail-config.yml):
server:
http_listen_port: 9080
grpc_listen_port: 0
positions:
filename: /tmp/positions.yaml
# ... (see EXAMPLES.md for complete configuration)
Wichtige Promtail-Konzepte:
Erwartet: Promtail scrapt konfigurierte Log-Dateien, Labels werden korrekt angewendet, Logs sind in Loki ueber LogQL-Abfragen sichtbar.
Bei Fehler:
docker logs promtaildocker exec promtail ls /var/logcurl http://localhost:9080/metrics | grep promtailcat /tmp/positions.yamlLogQL-Syntax fuer Filterung und Aggregation von Logs erlernen.
Grundlegende Abfragen:
# All logs from a job
{job="app"}
# Logs with specific label values
{job="app", level="error"}
# Regex filter on log line content
{job="app"} |~ "authentication failed"
# Case-insensitive regex
{job="app"} |~ "(?i)error"
# Line filter (doesn't parse, just includes/excludes)
{job="app"} |= "user" # Contains "user"
{job="app"} != "debug" # Doesn't contain "debug"
Parsing und Filterung:
# JSON parsing
{job="app"} | json | level="error"
# Regex parsing with named groups
{job="app"} | regexp "user_id=(?P<user_id>\\d+)" | user_id="12345"
# Logfmt parsing (key=value format)
{job="app"} | logfmt | level="error", service="auth"
# Pattern parsing
{job="nginx"} | pattern `<ip> - <user> [<timestamp>] "<method> <path> <protocol>" <status> <size>` | status >= 500
Aggregationen (Metriken aus Logs):
# Count log lines per level
sum by (level) (count_over_time({job="app"}[5m]))
# Rate of error logs
rate({job="app", level="error"}[5m])
# Bytes processed per service
sum by (service) (bytes_over_time({job="app"}[1h]))
# Average request duration from logs
avg_over_time({job="app"} | json | unwrap duration [5m])
# Top 10 error messages
topk(10, sum by (message) (count_over_time({level="error"} [1h])))
Filterung nach extrahierten Feldern:
# Find specific trace in logs
{job="app"} | json | trace_id="abc123def456"
# HTTP 5xx errors from nginx
{job="nginx"} | pattern `<_> "<_> <_> <_>" <status> <_>` | status >= 500
# Failed authentication attempts
{job="app"} | json | message=~"authentication failed" | user_id != ""
Grafana-Explore-Abfragen oder Dashboard-Panels mit diesen Mustern erstellen.
Erwartet: Abfragen liefern erwartete Log-Zeilen zurueck, Filterung funktioniert korrekt, Aggregationen erzeugen Metriken aus Logs.
Bei Fehler:
curl http://localhost:3100/loki/api/v1/labelscurl http://localhost:3100/loki/api/v1/label/{label_name}/valuesLogs mit Prometheus-Metriken und verteilten Traces fuer einheitliche Observability korrelieren.
Trace-IDs zu Logs hinzufuegen (Anwendungsinstrumentierung):
# Python with OpenTelemetry
import logging
from opentelemetry import trace
logger = logging.getLogger(__name__)
def handle_request():
span = trace.get_current_span()
trace_id = span.get_span_context().trace_id
logger.info(
"Processing request",
extra={"trace_id": format(trace_id, "032x")}
)
// Go with OpenTelemetry
import (
"go.opentelemetry.io/otel/trace"
"go.uber.org/zap"
)
func handleRequest(ctx context.Context) {
span := trace.SpanFromContext(ctx)
traceID := span.SpanContext().TraceID().String()
logger.Info("Processing request",
zap.String("trace_id", traceID),
)
}
Grafana-Datenlinks konfigurieren von Metriken zu Logs:
In der Prometheus-Panel-Feldkonfiguration:
{
"fieldConfig": {
"defaults": {
"links": [
{
"title": "View Logs",
"url": "/explore?left={\"datasource\":\"Loki\",\"queries\":[{\"refId\":\"A\",\"expr\":\"{job=\\\"app\\\",instance=\\\"${__field.labels.instance}\\\"} |= `${__field.labels.trace_id}`\"}],\"range\":{\"from\":\"${__from}\",\"to\":\"${__to}\"}}",
"targetBlank": false
}
]
}
}
}
Grafana-Datenlinks konfigurieren von Logs zu Traces:
In der Loki-Datenquellenkonfiguration:
datasources:
- name: Loki
type: loki
url: http://loki:3100
jsonData:
derivedFields:
- datasourceName: Tempo
matcherRegex: "trace_id=(\\w+)"
name: TraceID
url: "$${__value.raw}"
Logs in Grafana Explore korrelieren:
Erwartet: Das Klicken auf Metriken oeffnet verwandte Logs, Trace-IDs in Logs verlinken zum Trace-Viewer, einheitliche Ansicht fuer Metriken/Logs/Traces-Navigation.
Bei Fehler:
Aufbewahrungsrichtlinien und Komprimierung konfigurieren, um Speicherkosten zu verwalten.
Aufbewahrung nach Stream (in der Loki-Konfiguration):
limits_config:
retention_period: 720h # Global default: 30 days
# Per-tenant retention (requires multi-tenancy enabled)
per_tenant_override_config: /etc/loki/overrides.yaml
# overrides.yaml
overrides:
production:
retention_period: 2160h # 90 days for production
staging:
retention_period: 360h # 15 days for staging
development:
retention_period: 168h # 7 days for dev
Aufbewahrung nach Stream-Labels (erfordert Komprimierungsdienst):
compactor:
working_directory: /loki/compactor
shared_store: filesystem
compaction_interval: 10m
retention_enabled: true
retention_delete_delay: 2h
# ... (see EXAMPLES.md for complete configuration)
Die Prioritaet bestimmt, welche Regel gilt, wenn mehrere zutreffen (niedrigere Zahl = hoehere Prioritaet).
Komprimierungseinstellungen:
chunk_store_config:
chunk_cache_config:
enable_fifocache: true
fifocache:
max_size_bytes: 1GB
ttl: 24h
# ... (see EXAMPLES.md for complete configuration)
Aufbewahrung ueberwachen:
# Check chunk stats
curl http://localhost:3100/loki/api/v1/status/chunks | jq
# Check compactor metrics
curl http://localhost:3100/metrics | grep loki_compactor
# Verify deleted chunks
curl http://localhost:3100/metrics | grep loki_boltdb_shipper_retention_deleted
Erwartet: Alte Logs werden gemaess Aufbewahrungsrichtlinie automatisch geloescht, Speichernutzung stabilisiert sich, Komprimierung reduziert die Indexgroesse.
Bei Fehler:
docker logs loki | grep compactorretention_enabled: true und retention_deletes_enabled: true pruefendu -sh /loki/curl http://localhost:3100/readyretention_enabled: true und retention_deletes_enabled: true pruefen.ingestion_rate_mb und ingestion_burst_size_mb anpassen.correlate-observability-signals - Einheitliches Debugging ueber Metriken, Logs und Traces hinweg mithilfe von Trace-IDsbuild-grafana-dashboards - Log-abgeleitete Metriken visualisieren und Log-Panels in Dashboards erstellensetup-prometheus-monitoring - Metriken liefern Kontext dafuer, wann Logs waehrend Vorfaellen abgefragt werden solleninstrument-distributed-tracing - Trace-IDs zu Logs hinzufuegen zur Korrelation mit verteilten Tracestesting
Launch all available agents in parallel waves for open-ended hypothesis generation on problems where the correct domain is unknown. Use when facing a cross-domain problem with no clear starting point, when single-agent approaches have stalled, or when diverse perspectives are more valuable than deep expertise. Produces a ranked hypothesis set with convergence analysis and adversarial refinement.
tools
Write integration tests for a Node.js CLI application using the built-in node:test module. Covers the exec helper pattern, output assertions, filesystem state verification, cleanup hooks, JSON output parsing, error case testing, and state restoration after destructive tests. Use when adding tests to an existing CLI, testing a new command, verifying adapter behavior across frameworks, or setting up CI for a CLI tool.
development
Screen a proposed trademark for conflicts and distinctiveness before filing. Covers trademark database searches (TMview, WIPO Global Brand Database, USPTO TESS), distinctiveness analysis using the Abercrombie spectrum, likelihood of confusion assessment using DuPont factors and EUIPO relative grounds, common law rights evaluation, and goods/services overlap analysis. Produces a conflict report with a risk matrix. Use before adopting a new brand name, logo, or slogan — distinct from patent prior art search, which uses different databases, legal frameworks, and analysis methods.
tools
Scaffold a new CLI command using Commander.js with options, action handler, three output modes (human-readable, quiet, JSON), and optional ceremony variant. Covers command naming, option design, shared context patterns, error handling, and integration testing. Use when adding a command to an existing Commander.js CLI, designing a new CLI tool from scratch, or standardizing command structure across a multi-command CLI.