Application Observability with Grafana Alloy Grafana Alloy is a vendor-neutral distribution of the OpenTelemetry Collector and the recommended and supported way to send OpenTelemetry data to Grafana Cloud.
Before you begin To set up Grafana Alloy to send data to Grafana Cloud:
Grafana requires you to run Alloy on every host for Application Observability to function optimally.
This also allows Grafana to seamlessly correlate data between Application and Infrastructure observability.
If you’ve already set up Alloy, configure your application to use it.
Recommended setup For most use cases, Grafana Labs recommends to use the OpenTelemetry (OTLP) with Grafana Alloy Grafana Cloud integration tile to configure Alloy.
It’s recommended to use the OpenTelemetry (OTLP) with Grafana Alloy integration to generate a configuration file.
For advanced use cases you can manually configure the alloy-config.river
configuration file to run Grafana Alloy in flow mode:
Expand code
metrics = [ otelcol. processor. resourcedetection. default. input]
logs = [ otelcol. processor. resourcedetection. default. input]
traces = [ otelcol. processor. resourcedetection. default. input]
detectors = [ "env" , "system" ]
hostname_sources = [ "os" ]
metrics = [ otelcol. processor. transform. drop_unneeded_resource_attributes. input]
logs = [ otelcol. processor. transform. drop_unneeded_resource_attributes. input]
traces = [ otelcol. processor. transform. drop_unneeded_resource_attributes. input]
error_mode = "ignore"
context = "resource"
statements = [
context = "resource"
statements = [
context = "resource"
statements = [
metrics = [ otelcol. processor. transform. add_resource_attributes_as_metric_attributes. input]
logs = [ otelcol. processor. batch. default. input]
traces = [
host_identifiers = [ "host.name" ]
metrics = [ otelcol. processor. batch. default. input]
error_mode = "ignore"
context = "datapoint"
statements = [
metrics = [ otelcol. processor. batch. default. input]
metrics = [ otelcol. exporter. otlphttp. grafana_cloud. input]
logs = [ otelcol. exporter. otlphttp. grafana_cloud. input]
traces = [ otelcol. exporter. otlphttp. grafana_cloud. input]
endpoint = env( "GRAFANA_CLOUD_OTLP_ENDPOINT" )
auth = otelcol. auth. basic. grafana_cloud. handler
username = env( "GRAFANA_CLOUD_INSTANCE_ID" )
password = env( "GRAFANA_CLOUD_API_KEY" )
}
The configuration file requires you to set several environmental variables:
Expand table
Environment Variable Description Example GRAFANA_CLOUD_API_KEY
API key generated above eyJvSomeLongStringJ9fQ==
GRAFANA_CLOUD_OTLP_ENDPOINT
OTLP endpoint from Grafana Cloud > OpenTelemetry > Configure https://otlp-endpoint-***.grafana.net/otlp
GRAFANA_CLOUD_INSTANCE_ID
Instance ID from Grafana Cloud > OpenTelemetry > Configure 11111
Run Grafana Alloy Create the alloy-config.river
configuration file, set the necessary environment variables, and run Grafana Alloy .
Set the following environment variables to configure your application to use Alloy:
Expand table
Configuration Options Result export OTEL_EXPORTER_OTLP_ENDPOINT=<host>
http://localhost:4318
, remote host addressThe default local host address, or a remote host address. export OTEL_EXPORTER_OTLP_PROTOCOL=<protocol>
grpc
, http/protobuf
The default http/protobuf
protocol or grpc
For example, for a local Grafana Alloy set the following environment variables:
export OTEL_EXPORTER_OTLP_ENDPOINT = http://localhost:4317
export OTEL_EXPORTER_OTLP_PROTOCOL = grpc
Then restart your application.
Next steps Observe your services in Application Observability