How to send OTLP or Prometheus metrics and logs to Grafana Cloud with Grafana Alloy
We introduced Grafana Alloy last year in an effort to create the best possible open source “big tent” telemetry collector. A continuation of our work on Grafana Agent Flow, we designed Alloy to simplify observability at scale and to easily integrate with the OpenTelemetry and Prometheus ecosystems.
We’ve seen lots of interest since Alloy was announced at GrafanaCON 2024, and industry observers are taking notice, too. That’s because Alloy is an OTLP-compatible collector with built-in Prometheus optimizations and enterprise-grade features for collecting signals across your metrics, logs, traces, and profiles—making it ideal for all your cloud native infrastructure and application observability demands.
Alloy can also process and transform your data before sending it to OTel-compabile databases or collectors, including Grafana Cloud. You can even use Alloy to write alerting rules.
If this all sounds great but you aren’t sure where to start, keep reading for handy tips and demos from our Grafana Labs experts about how to send and receive telemetry with Alloy.
How to receive OTLP metrics and send them to Grafana Cloud
Seeing as how Alloy is a distribution of the OpenTelemetry Collector, it only makes sense to start with OTLP (OpenTelemetry protocol) metrics. More specifically, let’s look at how to use Alloy to receive metrics from an application instrumented with OTel and then send that data to Grafana Cloud.
To do so, you’ll use four OpenTelemetry components:
otelcol.receiver.otlp
, which receives metrics in OTLP format via HTTP and forwards themotelcol.processor.attributes
, which transforms the attributes associated with a metricotelcol.exporter.otlphttp
, which sends the metrics to Grafana Cloud using credentialsotelcol.auth.basic
for exposing those credentials
We’ll also enable Alloy’s live debugging feature, which will help build the transformations we want for the attributes processor and to make sure we’re comfortable with those attributes before we begin sending the metrics to Grafana Cloud.
Once you have that set up, you’ll use the run
command, and you’ll then be able to see the four connected components in the Alloy UI. If you click on the otelcol.processor.attributes
component, you can go into live debugging to see which metrics are passing through the component and identify any necessary changes.
From there, you can go to your Grafana Cloud instance and look for the specific OTLP metric you’ve set Alloy to collect. If you run a query on that metric, it should appear in your graph in just a few seconds.
For more details on how to set up this type of OTLP metrics pipeline, check out the full Ask the Experts demo from William Dumont, a software engineer on the Alloy squad, below.
Note: As we alluded to earlier, if you have experience with Grafana Agent Flow, you’ll be right at home with Alloy, as it uses the same components, code, and concepts. However, Grafana Agent and Grafana Agent Operator have been depreciated. They are currently in Long-Term Support (LTS) and are expected to reach End-of-Life (EOL) on Nov. 1, 2025. For more information on how to transition to Alloy, check out our Agent to Alloy FAQ blog post.
How to send Prometheus metrics to Grafana Cloud using Alloy
As we already mentioned, while Alloy is a distribution of the OpenTelmetry Collector, it’s also designed to work seamlessly with Prometheus, as well. This is essential functionality, as 85% of OpenTelemetry users also use Prometheus in production, according to our second annual Observability Survey.
To illustrate how to use Alloy to send Prometheus metrics to Grafana Cloud, let’s imagine you have an application exposing metrics in a Docker container. For this, we’ll need three components:
prometheus.scrape
, which collects metrics from our target every three secondsprometheus.relabel
, which is used to edit labels attached to the metrics.prometheus.remote_write
, which sends the metrics to Grafana Cloud using basic authentication to pass the necessary credentials.
Again, we’ll use live debugging—this time to assist in building the rules for prometheus.relabel
. Before running the config, we’ll use a little trick and break the pipeline so we can shape the labels before they’re stored in our database. To do so, use the run
command, bypass the path for the config file, and set the stability level to experimental
. From there you check your prometheus.remove_write
component via live debugging and add any desired rules to filter out any unwanted data.
Just like our last example, once you’ve set up your pipeline, you can go to Grafana Cloud, where you should be able to find your metric and quickly run a query on it. For more details, check out William’s second Ask the Expert video below.
How to send Grafana Alloy logs to Grafana Cloud
Now that we’ve walked through sending OpenTelemetry and Prometheus metrics to Grafana Cloud, let’s look at the next most popular telemetry type: logs. In this example, we’ll send the data to Grafana Cloud Logs, which is powered by Grafana Loki.
To do so, we’ll need three components:
logging
, and in our example we’ll usedebug
level to get the most information possible, as well aslogfmt
for the format, though you can also use JSON. The other important argument here iswrite_to
, which tells the logging framework where to send those logsloki.process
, which is a pipeline unto itself. You can add any number of stages here, but for our purposes we’ll just add the service name, and we’ll usealloy
so we can identify it on the frontendloki.write
, is what actually sends the data from Alloy to Grafana Cloud, or any Loki-compatible endpoint.
Once you have that set up to suit your needs, go back to the Alloy UI to see all your components running. Then, go to Grafana Cloud and look for the Alloy label filter. If you run a query on that label filter, you should see logs coming though and you can manipulate your data as needed.
To find out more, check out this Ask the Expert video below from Matthew Durham, a senior software developer on the Alloy squad.
Learn more about Alloy—online or in person
If you’re looking for more information to help you get started with Grafana Alloy, check out our documentation for all sorts of helpful resources, and read some of our Grafana Alloy-related blogs that run through specific Alloy use cases.
You can also watch our GrafanaCON 2024 and ObservabilityCON 2024 talks that featured the collector. And if you plan on attending either GrafanaCON 2025 in Seattle this May, or ObservabilityCON 2025 later this year, remember that we’ll have Ask the Expert booths fully staffed to help answer all your toughest questions.
Grafana Cloud is the easiest way to get started with metrics, logs, traces, dashboards, and more. We have a generous forever-free tier and plans for every use case. Sign up for free now!