Grafana Alloy
repository·main·Indexed 11 days ago
https://github.com/grafana/alloyAn OpenTelemetry Collector distribution with built-in Prometheus pipelines, designed for collecting and processing metrics, logs, traces, and profiles using a programmable configuration syntax.
What's inside Grafana Alloy
- The Alloy Collector Distro is an OpenTelemetry (OTel) Collector distribution that embeds Alloy's OTel components and integrates them directly with the Alloy CLI. It is built using the OpenTelemetry Collector Builder (OCB), which uses a configuration file to define metadata and the specific set of receivers, processors, and exporters to include in the distribution.
Introduction to Grafana Alloy
mainGrafana Alloy is an open-source telemetry collector designed to simplify the gathering and sending of observability data. It is an OpenTelemetry Collector distribution that includes built-in Prometheus pipelines and native support for Loki (logs), Pyroscope (profiles), and other observability backends.
Key benefits include:
- Unified Collection: Collects metrics, logs, traces, and profiles in a single tool, reducing the operational complexity of running separate collectors for each signal type.
- Vendor Neutrality: Provides the flexibility to send data to any compatible backend, such as Grafana Cloud, self-managed Grafana stacks, or other observability platforms.
- Pipeline-based Architecture: Uses a component-based model where small building blocks are connected in a configuration file to create continuous data pipelines.
Overview of the Grafana Alloy CLI commands
mainThealloybinary provides a command-line interface for managing the lifecycle, configuration, and debugging of Alloy. The primary way to use Alloy is via therunsubcommand, which starts the service using an Alloy syntax configuration file. Other commands allow for configuration formatting, validation, conversion, and interacting with the running instance via GraphQL or OTel engines.Overview of Grafana Alloy
mainGrafana Alloy is an open-source OpenTelemetry Collector distribution that includes built-in Prometheus pipelines. It is designed to handle metrics, logs, traces, and profiles using a programmable, expression-based syntax.
Key capabilities include:
- OpenTelemetry Support: Acts as a distribution of the OpenTelemetry Collector, supporting many existing OTel components.
- Multi-Ecosystem Integration: Supports OpenTelemetry, Prometheus, Grafana Loki, and Grafana Pyroscope.
- Kubernetes-Native: Includes components to interact directly with Kubernetes resources.
- Scalability: Supports automatic workload distribution via clustering and centralized configuration via a remote server.
- Extensibility: Allows sharing pipelines using modules.
- Observability: Features a built-in UI for visualizing and debugging pipelines.
Use `otelcol.exporter.file` to write telemetry to disk
mainotelcol.exporter.fileaccepts metrics, logs, and traces telemetry data from otherotelcolcomponents and writes them to files on disk. It supports both JSON (JSONL) and Protocol Buffers (proto) formats.This component is a wrapper over the upstream OpenTelemetry Collector Contrib
fileexporter.otelcol.exporter.file "<LABEL>" { path = "<PATH>" }Use Helm charts for Grafana Alloy
mainGrafana Alloy can be deployed using Helm charts located in theoperations/helmdirectory. These charts allow for managed installations of Alloy on Kubernetes clusters.Use `database_observability.sql_server` to monitor Microsoft SQL Server
mainThe
database_observability.sql_servercomponent connects to a Microsoft SQL Server instance and collects observability data across all accessible user databases. It forwards log entries to Loki receivers and exports targets for Prometheus scraping.Core Functionality
- Schema Details: Collects schemas and tables from
information_schema. - Query Metrics: Collects per-query executions, errors, and duration counters from Query Store.
- Query Details: Collects query text and parsed table names from Query Store.
Requirements
- Permissions: The login requires
VIEW DATABASE STATEon the connected database. On SQL Server 2022 and later,VIEW DATABASE PERFORMANCE STATEis also sufficient. - Query Store: For
query_metricsandquery_detailsto work, Query Store must be enabled on the database specified in thedata_source_name.
database_observability.sql_server "orders_db" { data_source_name = "sqlserver://user:pass@server:1433" forward_to = [loki.write.logs_service.receiver] } loki.write "logs_service" { endpoint { url = sys.env("<GRAFANA_CLOUD_HOSTED_LOGS_URL>") basic_auth { username = sys.env("<GRAFANA_CLOUD_HOSTED_LOGS_ID>") password = sys.env("<GRAFANA_CLOUD_RW_API_KEY>") } } }- Schema Details: Collects schemas and tables from
Use `otelcol.exporter.googlecloudpubsub` to export telemetry to Google Cloud Pub/Sub
mainThe
otelcol.exporter.googlecloudpubsubcomponent accepts metrics, traces, and logs from otherotelcolcomponents and sends them to a Google Cloud Pub/Sub Topic. It acts as a wrapper over the upstream OpenTelemetry Collectorgooglecloudpubsubexporter.You can define multiple instances of this component by using different labels.
otelcol.exporter.googlecloudpubsub "<LABEL>" { project = "<PROJECT-ID>" topic = "projects/<PROJECT-ID>/topics/<TOPIC-NAME>" }Use `prometheus.operator.probes` to scrape Kubernetes Probes
mainThe
prometheus.operator.probescomponent discovers Probe resources in a Kubernetes cluster and scrapes the targets they reference.It performs three main functions:
- Discovers Probe resources from the Kubernetes cluster.
- Discovers targets or ingresses that match those Probes.
- Scrapes metrics from those endpoints and forwards them to a specified receiver.
By default, it uses the in-cluster configuration to access the Kubernetes API. If running outside the cluster, you must provide connection information via the
clientblock, and ensure network access to the target pods is available.prometheus.operator.probes "<LABEL>" { forward_to = <RECEIVER_LIST> }Understand the beyla.ebpf component
mainThe
beyla.ebpfcomponent runs Grafana Beyla (eBPF auto-instrumentation) as a child process of Alloy.Alloy automates the lifecycle by translating the Alloy component configuration into a Beyla YAML configuration, spawning the embedded Beyla binary, ingesting Beyla's OTLP telemetry, and forwarding it to your configured downstream outputs.
Platform Support:
- Supported on
linux/amd64andlinux/arm64. - On any other platform, the component acts as a no-op (does nothing) and logs a warning.
- Supported on
Use the Windows Event Log source
mainThe Windows Event Log source allows you to collect logs from the Windows Event Log system. This component is a specialized implementation designed to bridge the Windows eventlog syscalls with the Prometheus/Loki data models used in Alloy. It utilizes a saved file model to manage subscription restarts, ensuring continuity in log collection.Use otelcol.processor.span to transform traces
mainThe
otelcol.processor.spancomponent allows you to manipulate OpenTelemetry trace spans. You can rename spans based on attribute values or regex patterns, add new attributes extracted from the span name, filter spans using inclusion/exclusion rules, and modify the span status (e.g., setting it toError).Note: This component only supports traces. Logs and metrics are not supported.
otelcol.processor.span "default" { # Configuration blocks go here output { traces = [otelcol.exporter.otlphttp.default.input] } }