Path

Learn how Alloy components connect to form collect, process, and export pipelines.

Estimated time: 2 min

Components and pipelines

In Alloy, a component is a building block that does one job: discover targets, collect data, transform it, or send it somewhere. You connect components so data flows through a pipeline that matches your needs.

Each component has a name and a label, such as loki.write "local". Components take configuration that sets their behavior, and they can share values with other components through references.

This milestone focuses on the pipeline shape. For the configuration syntax itself — attributes, expressions, blocks, arguments, and exports — refer to Alloy syntax and Configure components.

The following example is adapted from the logs-file scenario in alloy-scenarios. It discovers log files, tails them, and writes entries to Loki:

Alloy
local.file_match "local_files" {
  path_targets = [{"__path__" = "/temp/logs/*.log", "job" = "python"}]
  sync_period  = "5s"
}

loki.source.file "log_scrape" {
  targets       = local.file_match.local_files.targets
  forward_to    = [loki.write.local.receiver]
  tail_from_end = true
}

loki.write "local" {
  endpoint {
    url = "http://loki:3100/loki/api/v1/push"
  }
}

Read the pipeline as discover → collect → send:

  • local.file_match finds matching files
  • loki.source.file tails those files and forwards log entries
  • loki.write sends the entries to Loki

Real production pipelines often add processing components for labels, parsing, filtering, or redaction between source and write steps.

In the next milestone, you explore how Alloy appears in Grafana Cloud Connections.


More to explore (optional)

At this point in your path, you can explore the following topics: