Send data using OpenTelemetry Protocol (OTLP)
In this guide, you’ll learn how to send data through OTLP to Grafana Cloud. You can send telemetry data in two ways:
- Using the OpenTelemetry Collector
- Using OpenTelemetry SDKs to instrument your application
After you send data to your Grafana Cloud stack, you can query it using your hosted Prometheus, Loki, or Tempo data sources.
Before you begin
- Instrument an application with OpenTelemetry SDKs or install the OpenTelemetry Collector.
- Create an Access Policy token
with the
metrics:write
,logs:write
and/ortraces:write
scopes, depending on the data you will be sending. - Open the Cloud Portal, and click Configure on the OpenTelemetry card.
Make a note of the following values associated with your instance:
- Instance ID (e.g.
130834
) - OTLP Endpoint URL (e.g.
https://otlp-gateway-prod-us-central-0.grafana.net/otlp
)
- Instance ID (e.g.
Examples in this topic
The examples in this topic are based on the following Grafana Cloud instance.
Push using the OpenTelemetry Collector
To export to Grafana Cloud, add the otlphttp
exporter with a basicauth
extension to the collector.
Note
To use thebasicauth
extension, choose a suitable collector distribution that contains the extension, such asotelcol-contrib
.
The following sample shows how to add the otlphttp
exporter to the collector. Using the example image above, the instanceID
is 130834
and the endpoint is https://otlp-gateway-prod-us-central-0.grafana.net/otlp
.
extensions:
basicauth/otlp:
client_auth:
username: <instanceID>
password: <Cloud Access Policy token>
exporters:
otlphttp:
auth:
authenticator: basicauth/otlp
endpoint: <OTLP Endpoint URL>
service:
extensions: [basicauth/otlp]
pipelines:
metrics:
receivers: [...]
processors: [...]
exporters: [..., otlphttp]
traces:
receivers: [...]
processors: [...]
exporters: [..., otlphttp]
logs:
receivers: [...]
processors: [...]
exporters: [..., otlphttp]
Note
The endpoints should contain the following:/v1/traces
or/v1/metrics
, or/v1/logs
appended to the endpoint, similar to the following example.https://otlp-gateway-prod-eu-west-3.grafana.net/otlp/v1/traces
Token scopes required for each endpoint.
Push directly from applications using the OpenTelemetry SDKs
In typical OTel architectures, the applications write to the collector, and the collector writes to Grafana Cloud. We recommend using the collector in the pipeline where possible because it enables you to batch, aggregate, clean up, and route the data.
However, if you want to bypass the collector, you can configure the OpenTelemetry SDKs to use environment variables to push directly to Grafana Cloud.
OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf
OTEL_EXPORTER_OTLP_ENDPOINT=<OTLP Endpoint URL>
OTEL_EXPORTER_OTLP_HEADERS=Authorization=Basic <base64 instanceID:token>
Note
If you are using Python, replace the space after
Basic
with%20
:
OTEL_EXPORTER_OTLP_HEADERS=Authorization=Basic%20<base64 instanceID:token>
To automatically obtain those values, click on Generate Now in the Password / API Token section. As a result, the Environment Variable section will be populated with environment variables necessary to send data directly to Grafana Cloud.
Note
Language specific guides can be found here.
See OTLP format considerations for information about metrics and logs conversion.
Visualize OpenTelemetry data in Application Observability
Visualize OpenTelemetry telemetry data in Application Observability to detect anomalies, identify root causes, and fix problems in services and applications.