1.2. Configure a Collector
In this module, we will configure a collector to receive OpenTelemetry signals from our application, and ship them to Grafana Cloud.
Step 1: Configure Grafana Alloy
Grafana Alloy is a distribution of the OpenTelemetry Collector, with a Terraform-like syntax for building powerful telemetry pipelines. We will use Alloy to collect and ship your OpenTelemetry signals to Grafana Cloud.
An OpenTelemetry Collector acts as a bridge between your applications and your telemetry backends. The Collector can receive signals from multiple sources, and send them to multiple destinations. It can also perform transformations on the signals, such as filtering or aggregating them.
For this workshop, we will use Alloy to send telemetry to Grafana Cloud. Below would be the data flow:
- Receive OTLP signals from your application
- Send them to Grafana Cloud
Follow these steps:
-
In the terminal, type the following:
cd ./source/alloy -
Find the file
./source/alloy/config.alloyin the Explorer pane, and open it. Review the content of the configuration file, noting that:-
There is an
otelcol.receiver.otlpblock, which receives OTLP signals from your application. -
There is an
otelcol.exporter.otlphttpblock, which sends the signals to Grafana Cloud's OTLP endpoint.
You don't need to do anything with this file, but it's good to know what an Alloy configuration file looks like.
tipWhen you begin to implement OpenTelemetry in your own environment, you can use the Grafana Cloud interface to generate an Alloy configuration file. Navigate to Connections and follow the integration tiles to add an OpenTelemetry source.
-
-
Find the new file
./source/alloy/run.shin the Explorer pane, and open it.This script will run Grafana Alloy. You will see that we need to set some environment variables first:
export GRAFANA_CLOUD_OTLP_ENDPOINT=""
export GRAFANA_CLOUD_OTLP_USERNAME=""
export GRAFANA_CLOUD_OTLP_PASSWORD="" -
⚠️ 👆🏻 Please enter the value from the previous steps
Step 2: Run Grafana Alloy
Now we're ready to run Grafana Alloy!
-
In the terminal, run the following command to start Grafana Alloy:
./run.shYou should see Alloy start up, and begin to write some logs to the console.
In the logs, you will see two log lines, like "Starting GRPC server" and "Starting HTTP server". This means that Alloy has opened two ports, for receiving OTLP data. Alloy is ready to go.
Congratulations! You've just made the first step to collecting and exporting OpenTelemetry signals, by running a collector.
For the purposes of this workshop, and to keep things simple, you're running a standalone, foreground instance of Grafana Alloy, inside your development environment.
But in production, you may run Alloy in a different topology. For example, if you're running Kubernetes, you might use Grafana's Kubernetes Monitoring Helm chart, which deploys Alloy to collect OTLP signals from your applications and also Prometheus metrics from your underlying Kubernetes infrastructure.
See the Alloy documentation for more information.
Summary
In this module, you have configured a collector to receive OpenTelemetry signals from your application, and ship them to Grafana Cloud.
You have also learned how to configure Grafana Alloy, and how to run it in your development environment.
In the next module, you will learn how to instrument your application to send OpenTelemetry signals to Grafana Alloy.