DEV Community

Alex Spinov
Alex Spinov

Posted on

Grafana Alloy Has a Free API — The OpenTelemetry Collector You Actually Want

TL;DR

Grafana Alloy is an open-source OpenTelemetry Collector distribution that replaces Grafana Agent. It collects metrics, logs, and traces with a programmable pipeline — and it's completely free.

What Is Grafana Alloy?

Grafana Alloy is Grafana's vendor-neutral telemetry collector:

  • OpenTelemetry native — built on OTel Collector components
  • Programmable pipelines — River configuration language (like HCL)
  • Metrics + Logs + Traces — all three signals in one binary
  • Grafana ecosystem — ships to Prometheus, Loki, Tempo, Mimir
  • Free and open source — Apache 2.0 license

Quick Start

# Install on macOS
brew install grafana/grafana/alloy

# Install on Linux
curl -fsSL https://apt.grafana.com/gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/grafana.gpg
sudo apt-get install alloy

# Or Docker
docker run -v ./config.alloy:/etc/alloy/config.alloy \
  -p 12345:12345 grafana/alloy:latest \
  run /etc/alloy/config.alloy
Enter fullscreen mode Exit fullscreen mode

Configuration with River

// config.alloy — Collect metrics from Prometheus endpoints

prometheus.scrape "default" {
  targets = [
    {"__address__" = "localhost:8080", "job" = "my-app"},
    {"__address__" = "localhost:9090", "job" = "prometheus"},
  ]
  forward_to = [prometheus.remote_write.grafana_cloud.receiver]
  scrape_interval = "15s"
}

prometheus.remote_write "grafana_cloud" {
  endpoint {
    url = "https://prometheus-prod.grafana.net/api/prom/push"
    basic_auth {
      username = env("GRAFANA_CLOUD_USER")
      password = env("GRAFANA_CLOUD_TOKEN")
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

Collecting Logs

// Tail log files and ship to Loki

local.file_match "app_logs" {
  path_targets = [{__path__ = "/var/log/app/*.log"}]
}

loki.source.file "logs" {
  targets    = local.file_match.app_logs.targets
  forward_to = [loki.write.grafana_cloud.receiver]
}

loki.write "grafana_cloud" {
  endpoint {
    url = "https://logs-prod.grafana.net/loki/api/v1/push"
    basic_auth {
      username = env("GRAFANA_CLOUD_USER")
      password = env("GRAFANA_CLOUD_TOKEN")
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

OpenTelemetry Traces

// Receive OTLP traces and forward to Tempo

otelcol.receiver.otlp "default" {
  grpc { endpoint = "0.0.0.0:4317" }
  http { endpoint = "0.0.0.0:4318" }
}

otelcol.exporter.otlp "tempo" {
  client {
    endpoint = "tempo-prod.grafana.net:443"
    auth     = otelcol.auth.basic.grafana_cloud.handler
  }
}

otelcol.auth.basic "grafana_cloud" {
  username = env("GRAFANA_CLOUD_USER")
  password = env("GRAFANA_CLOUD_TOKEN")
}

otelcol.receiver.otlp.default.output {
  traces = [otelcol.exporter.otlp.tempo.input]
}
Enter fullscreen mode Exit fullscreen mode

Alloy vs Other Collectors

Feature Alloy OTel Collector Datadog Agent Vector
Price Free Free Paid Free
Config language River (HCL) YAML YAML TOML
Metrics
Logs
Traces
Programmable
Live debugging UI ✅ :12345

Built-in Debug UI

Alloy ships with a debug UI at http://localhost:12345:

  • See pipeline graph visualization
  • Check component health
  • View live data flowing through
  • Debug configuration errors

Resources


Need to monitor your scraping infrastructure? My Apify tools extract web data at scale — pair with Grafana Alloy to monitor your data pipelines. Questions? Email spinov001@gmail.com

Top comments (0)