What you will learn in this TP
- Start Loki and Grafana
- Push and read a log through the API
- Use logcli
Introduction #
What you will learn in this section
- Start Loki and Grafana
- Push and read a log through the API
- Use logcli
Context. Your team stores its logs in files on each server: it is impossible to view them together or to correlate them with metrics. You install Loki, the “Prometheus-style” log system, to understand how it receives and returns a log.
Prerequisites: Docker and Docker Compose · Estimated time: 30 min
You will deploy a local Loki + Grafana stack and validate each building block with commands.Setup #
Configuration, startup and validation.
1. Create loki.yaml and docker-compose.yml
Why? A reproducible local stack lets you test Loki without touching production; the configuration stores everything on local disk to keep things simple.
Reuse the monolithic configuration from the installation article (filesystem storage, TSDB schema v13) and declare thelokiandgrafanaservices.2. Check that Loki is ready
Why? The /ready endpoint tells you Loki has finished starting up: sending logs before that point causes misleading errors.
Which command shows that Loki is accepting requests?3. Push a log with the API
Why? The push API is what every agent (Alloy, Promtail) will use: handling it by hand shows what they actually send (labels + timestamp + line).
Send the line “Hello Loki” to the{job="tp"}stream.4. Read with logcli and Grafana
Why? logcli and Grafana are the two ways to view logs; knowing both means you do not depend on a single interface when troubleshooting.
Find the log withlogcli, then add the Loki data source in Grafana (http://loki:3100) and run the query in Explore.
Difficulty level : ●○○○○ (1/5)
My progress
Sign in to track your progress and take notes. Sign in
💬 Recent discussions about this course
- Loki : faut-il mettre le niveau de log et l'identifiant de requête en label ?✓ solved · 1 reply(ies)
Ask a question about this lesson →See all discussions about this course
Recommended Articles
Grafana Loki: the Prometheus-inspired log system
Discover Grafana Loki: the label-indexing philosophy, architecture (distributor, ingester, querie...
Installing Grafana Loki (Docker Compose, binary and Helm)
Install and validate Grafana Loki: minimal configuration, Docker Compose with Grafana and Alloy, ...
Grafana Loki vs Elasticsearch: the battle of log storage
A comparison between Loki, the Prometheus-inspired log system, and Elasticsearch, the reference f...
Collecting logs into Loki: Alloy, Promtail, Docker and OpenTelemetry
Send logs to Loki: Grafana Alloy, Promtail, the Docker driver, OTLP, good labels, parsing and enr...
Grafana Alloy: Log Management with Loki
Discover how to configure Grafana Alloy to read log files, journald, or network streams, process ...
The LGTM stack (Loki, Grafana, Tempo, Mimir): architecture and setup
Understand Grafana Labs' LGTM stack: Loki for logs, Grafana for visualization, Tempo for traces a...
Alerting on logs with the Loki Ruler
Set up LogQL alerts and recording rules with the Loki Ruler: configuration, rule files, Alertmana...
Grafana Loki best practices: labels, queries, storage and costs
Loki best practices: choosing labels and cardinality, structured metadata, efficient LogQL querie...
LogQL (2/2): turning logs into metrics
Create metrics from logs with LogQL: rate, count_over_time, bytes_rate, aggregations, unwrap, qua...