RousselTMLEARNING

Article · Alloy: From Discovery to Expertise

Processing Pipelines

2. Processing pipelines #

Filtering, parsing (JSON, Regex), and relabeling.

Enrich and filter logs #

Raw logs often lack context and consume too much storage. The loki.process component allows you to define sophisticated processing pipelines. You can embed stages to extract fields via JSON or Regex parsing, use these fields to create new dynamic labels, filter (drop) irrelevant lines (like HTTP healthchecks), or even rewrite the log content itself.


Best Practice: Drastically limit the number of labels extracted to Loki. Only extract global and static fields as labels (e.g., env, app, level). For other fields (dynamic business values), leave them in the log line and use LogQL filters (e.g., | json) at query time.
Common Mistake: Promoting a highly variable field (like an IP address, a trace_id, or a transaction uuid) as a label. This mistake will crush the performance of your Loki instance.
loki.process "filter_logs" {
  forward_to = [loki.write.default.receiver]

  // JSON Parsing
  stage.json {
    expressions = { level = "log_level", app = "app_name" }
  }
  // Secure label creation
  stage.labels {
    values = { level = null, app = null }
  }
  // Filter out useless logs
  stage.drop {
    source = "level"
    value  = "debug"
  }
}

📄 Grafana Alloy: Log Management with Loki →

My progress

  • ⏱ Estimated time : ≈ 3 min

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

💬 Ask a question

Course Glossary

Grafana Alloy

An open-source, vendor-neutral telemetry collector designed to replace Grafana Agent, fully compatible with OpenTelemetry (OTel).

Recommended Articles

Grafana Alloy: The importance of Self-Monitoring

Discover why and how to configure Grafana Alloy so that it monitors itself, collecting its own lo...

Transformer avec VRL et tester ses pipelines Vector

Le langage VRL (Vector Remap Language) : analyse de logs (JSON, regex, syslog), gestion des erreu...

Logs avancés avec OpenPipeline : traitement, masquage, buckets et rétention

Gérer les logs dans Dynatrace avec OpenPipeline : ingestion, routage, traitement DQL (parsing, en...

Bonnes Pratiques Grafana Alloy : Optimiser sa Collecte de Télémétrie

Découvrez les règles d'or pour configurer Grafana Alloy de manière robuste : modularité, gestion ...

Grafana Alloy : Collecter les métriques système et les logs locaux

Découvrez comment configurer Grafana Alloy pour superviser le serveur sur lequel il s'exécute, av...

Grafana Alloy: Syntax and Configuration (Alloy Language: River)

As part of a Grafana training or observability training, master the declarative syntax of Grafana...

Grafana Alloy: Metrics Collection (Prometheus & Ecosystem)

Learn how to configure Grafana Alloy to collect, transform, and forward metrics using the Prometh...

Grafana Alloy: Continuous Profiling with Pyroscope

Discover how to configure continuous profiling in your environments using Grafana Alloy and Pyros...

Grafana Alloy: Advanced Deployment and Clustering

Learn how to manage large-scale Grafana Alloy deployments. Configure Clustering mode for high ava...

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!