DEV Community

Alex Spinov
Alex Spinov

Posted on

Grafana Alloy Has a Free API: The OpenTelemetry Collector That Actually Makes Sense

Configuring an OpenTelemetry Collector feels like writing YAML in the dark. Grafana Alloy fixes that with a programmable pipeline language.

What Is Grafana Alloy?

Grafana Alloy is an OpenTelemetry Collector distribution with a twist: instead of YAML configuration, you get a programmable, component-based pipeline language called Alloy syntax.

It collects metrics, logs, traces, and profiles — and sends them anywhere: Prometheus, Loki, Tempo, Jaeger, Datadog, or any OTLP endpoint.

Alloy Syntax vs YAML

Traditional OTel Collector (YAML):

receivers:
  otlp:
    protocols:
      grpc:
        endpoint: 0.0.0.0:4317
processors:
  batch:
    timeout: 5s
exporters:
  prometheusremotewrite:
    endpoint: http://mimir:9009/api/v1/push
service:
  pipelines:
    metrics:
      receivers: [otlp]
      processors: [batch]
      exporters: [prometheusremotewrite]
Enter fullscreen mode Exit fullscreen mode

Grafana Alloy:

otelcol.receiver.otlp "default" {
  grpc { endpoint = "0.0.0.0:4317" }
  output { metrics = [otelcol.processor.batch.default.input] }
}

otelcol.processor.batch "default" {
  timeout = "5s"
  output { metrics = [otelcol.exporter.prometheusremotewrite.mimir.input] }
}

otelcol.exporter.prometheusremotewrite "mimir" {
  endpoint { url = "http://mimir:9009/api/v1/push" }
}
Enter fullscreen mode Exit fullscreen mode

Components connect like LEGO blocks. You see the data flow.

Key Features

1. Component-based architecture — Each component does one thing. Chain them together.

2. Live debugging UI — Built-in web UI shows component status, throughput, errors in real-time.

3. Prometheus scraping — Drop-in replacement for prometheus agent:

prometheus.scrape "app" {
  targets = [{"__address__" = "localhost:8080"}]
  forward_to = [prometheus.remote_write.mimir.receiver]
}
Enter fullscreen mode Exit fullscreen mode

4. Log collection — Replace Promtail, Fluentd, Filebeat:

local.file_match "logs" {
  path_targets = [{"__path__" = "/var/log/*.log"}]
}
loki.source.file "logs" {
  targets = local.file_match.logs.targets
  forward_to = [loki.write.default.receiver]
}
Enter fullscreen mode Exit fullscreen mode

5. Auto-discovery — Kubernetes, Docker, Consul service discovery built in.

Quick Start

brew install grafana/grafana/alloy
alloy run config.alloy
# UI at http://localhost:12345
Enter fullscreen mode Exit fullscreen mode

Building monitoring solutions or need data pipelines? Check out my automation tools or email spinov001@gmail.com.

Top comments (0)