RousselTMLEARNING

TP · Grafana Loki: from discovery to expertise

Lab: Deploy Loki and send your first logs

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. 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 the loki and grafana services.
  2. 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. 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. 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 with logcli, then add the Loki data source in Grafana (http://loki:3100) and run the query in Explore.

Difficulty level : ●○○○○ (1/5)

My progress

  • ⏱ Estimated time : ≈ 30 min

Sign in to track your progress and take notes. Sign in

💬 Recent discussions about this course

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...

Support us

♥ SUPPORT US

Support RousselTM Learning

Courses, articles, labs and certificates stay free with no intrusive ads. A voluntary contribution, of any amount you choose, pays for hosting, lab environments and new content.

Contribute with PayPal Any amount · card or PayPal accountLearn more
QR code PayPal
Or scan this QR code with your phone

Thank you, every contribution counts!