Set up Grafana Alloy for Application Observability For production observability, Grafana Labs recommends Grafana Alloy, an OpenTelemetry Collector distribution, that packages various upstream OpenTelemetry Collector components and Prometheus exporters, to provide stability, support, and an integrated experience with Grafana Application Observability and other Grafana products.
Recommended setup For production, Application Observability requires Alloy on every host to seamlessly correlate data between Infrastructure and Application observability.
Grafana Labs recommends instrumentation of the OpenTelemetry (OTLP) with Grafana Alloy Grafana Cloud integration tile to configure Alloy.
This opinionated approach includes all the binaries, configuration, and connection parameters you need to set up OpenTelemetry and Application Observability.
If you have an existing Alloy per host, refer to the configure your application section.
Advanced manual setup For advanced use cases you can manually configure the Alloy alloy-config.river
configuration file:
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" )
}
Set the following environmental variables in the configuration file:
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