Push log lines to Loki loki
Manually push a log entry to verify ingestion. note: timestamp must be ns epoch.
curl -s -H 'Content-Type: application/json' -XPOST "$LOKI_ADDR/loki/api/v1/push" -d '{"streams":[{"stream":{"app":"test"},"values":[["'$(date +%s%N)'","hello loki"]]}]}'
more loki
all 7 commands →
Parse JSON logs and reshape line
{app="api"} |= "error" | json | line_format "{{.level}} {{.msg}}"
Per-level log rate
sum by (level) (rate({app="api"} | logfmt [5m]))
Quantile over unwrapped latency
quantile_over_time(0.99, {app="api"} | json | unwrap latency_ms [5m]) by (route)
Count matching lines over time
sum(count_over_time({namespace="prod"} |~ "timeout|deadline exceeded" [1m]))
logcli ad-hoc query
logcli query '{job="app/api"} |= "panic"' --since=1h --limit=200 --output=jsonl