Basics


Architecture

Components

Components are the core building block of Alloy. Each component performs a single task (collect, transform, forward) and has two parts:

Component naming follows the pattern NAMESPACE.TYPE (e.g., prometheus.scrape, loki.write). You identify a specific instance by combining name + label: prometheus.scrape.my_scraper.

// Component syntax:
COMPONENT_NAME "LABEL" {
  attribute = "value"
}

// Example: scrape and forward metrics
prometheus.scrape "app" {
  targets    = [{"__address__" = "localhost:8080"}]
  forward_to = [prometheus.remote_write.prod.receiver]
}

prometheus.remote_write "prod" {
  endpoint {
    url = "https://prometheus.example.com/api/v1/write"
  }
}

image.png

Component categories (by namespace prefix):

Prefix Purpose
discovery.* Service discovery (Kubernetes, EC2, Consul, DNS, etc.)
prometheus.* Metrics scraping, relabeling, remote write, exporters
loki.* Log collection, processing, and writing to Loki
otelcol.* OpenTelemetry receivers, processors, exporters
pyroscope.* Continuous profiling collection and forwarding
remote.* Pull config/secrets from remote sources
local.* Read local files
discovery.* Target discovery across cloud providers and orchestrators