What you will learn in this TP
- Write a VRL transformation
- Route to Loki
- Produce metrics
Introduction #
What you will learn in this section
- Write a VRL transformation
- Route to Loki
- Produce metrics
Context. The website exposes no HTTP metrics, but nginx writes access logs. You get both structured logs and metrics out of them.
Prerequisites: Docker Compose · Estimated time: 45 min
Structured logs and metrics from a simple file.Setup #
Guided steps, with their solutions.
1. Prepare nginx and the traffic
Why? nginx writes its logs to a volume shared with Vector.
Create a Compose file with nginx (logs in a volume), a request generator (including 404s) and Loki.2. Write the transformation
Why? VRL extracts the fields and converts the types: you can then filter and aggregate.
Createvector.yamlwith afilesource and aremapthat parses the combined format.3. Run and observe
Why?
Add Vector to the Compose file, start it and inspect the output ofvector tapshows the transformed events live.parse.4. Derive metrics
Why? To count requests by status without touching nginx.
Add alog_to_metricand aprometheus_exportersink on port 9598, then read the metrics.5. Check in Loki
Why? The extracted fields can be filtered directly in LogQL.
Display the 404 requests.
Difficulty level : ●●●○○ (3/5)
My progress
Sign in to track your progress and take notes. Sign in
Recommended Articles
Traefik : les logs (journaux applicatifs et access logs)
Configurer les deux journaux de Traefik : le journal de fonctionnement (niveaux, format) et les a...
Logs Datadog avancés : index, filtres d'exclusion, Flex Logs, archives et Sensitive Data Scanner
Maîtriser coût et conformité des logs Datadog : pipelines et processeurs, index et rétention, fil...
Grafana Loki : le système de logs inspiré de Prometheus
Découvrir Grafana Loki : philosophie d'indexation par labels, architecture (distributor, ingester...
Grafana Alloy: Log Management with Loki
Discover how to configure Grafana Alloy to read log files, journald, or network streams, process ...
DQL en pratique : explorer logs et événements, notebooks, tableaux de bord et performance
Utiliser le Dynatrace Query Language au quotidien : explorer logs et événements, enchaîner les co...
Alerter sur les logs avec le Ruler de Loki
Mettre en place des alertes et des recording rules LogQL avec le Ruler Loki : configuration, fich...
Collecter des logs vers Loki : Alloy, Promtail, Docker et OpenTelemetry
Envoyer des logs vers Loki : Grafana Alloy, Promtail, driver Docker, OTLP, bons labels, parsing e...
LogQL (1/2) : requêter les logs (sélecteurs, filtres et parsers)
Apprendre LogQL : sélecteurs de flux, filtres de ligne, parsers json/logfmt/pattern/regexp, filtr...
LogQL (2/2) : transformer les logs en métriques
Créer des métriques à partir des logs avec LogQL : rate, count_over_time, bytes_rate, agrégations...