RousselTMLEARNING

TP · Vector: from discovery to expertise

Lab: Parse nginx logs with Vector and VRL

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. 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. 2. Write the transformation

    Why? VRL extracts the fields and converts the types: you can then filter and aggregate.

    Create vector.yaml with a file source and a remap that parses the combined format.
  3. 3. Run and observe

    Why? vector tap shows the transformed events live.

    Add Vector to the Compose file, start it and inspect the output of parse.
  4. 4. Derive metrics

    Why? To count requests by status without touching nginx.

    Add a log_to_metric and a prometheus_exporter sink on port 9598, then read the metrics.
  5. 5. Check in Loki

    Why? The extracted fields can be filtered directly in LogQL.

    Display the 404 requests.

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

My progress

  • ⏱ Estimated time : ≈ 45 min

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

💬 Ask a question

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

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!