K8s Logs Quick Reference & Cheatsheet
A quick reference guide for common tasks and commands in Kubernetes Logs management.
Dashboard Navigation
| Task | Location |
|---|---|
| View logs | Clusters → Select Cluster → Logs Tab |
| Search logs | Logs Tab → Enter filters → Click "Search Logs" |
| Configure collection | Collection Config Tab → Create/Edit configs |
| Set up archival | Archive Tab → Create Policy |
| Monitor metrics | Metrics Tab → View statistics |
| Check system health | Settings Tab → System Health section |
| View S3 archives | S3 Storage Tab → Search archives |
| Manage clusters | Clusters Tab → View/edit configs |
Common Search Filters
| Filter | Purpose | Example |
|---|---|---|
| Namespace | Limit to specific K8s namespace | "production" |
| Log Level | Filter by severity | "error" |
| Date Range | Specify time period | Last 24 hours |
| Search Query | Full-text search in messages | "connection timeout" |
| Pod Name | Filter by specific pod | "api-server-1" |
LogQL Quick Reference
Basic Queries
# All logs from namespace
{namespace="production"}
# Error logs from pod
{pod="api-server"} |= "error"
# Multiple namespaces
{namespace=~"prod.*"}
# Exclude pattern
{namespace="prod"} != "debug"
Operators
| Operator | Meaning | Example |
|---|---|---|
|= | Contains (matches) | |= "error" |
!= | Does not contain | != "debug" |
|~ | Regex match | |~ "err.*\[0-9\]" |
!~ | Regex not match | !~ "warn" |
> | Greater than (numeric) | > 500 |
< | Less than (numeric) | < 100 |
>= <= | Greater/less or equal | >= 1000 |
Label Filters
# Exact match
{app="api"}
# Label exists
{namespace!=""}
# Regex match
{pod=~"api.*"}
# Multiple labels
{namespace="prod", app="web"}
Advanced Queries
# Combine filters with AND
{namespace="prod"} |= "error" |= "database"
# Combine with OR (use multiple patterns)
{namespace="prod"} |= "error" |~ "fatal|critical"
# Extract JSON fields
{app="api"} | json | status >= 500 | line_format "{{.message}}"
# Parse labels
{namespace="prod"} | regexp "user=(?P<user>\w+)"
# Count occurrences
{namespace="prod"} | pattern "<_> <method> <path> <_> <status>"