OpenTelemetry Data Visualization Explore OpenTelemetry Logs in Loki
Open source

Explore OpenTelemetry Logs in Loki

Once you have data being sent to your Grafana Cloud or OSS stack, you can view log data via Grafana’s Explore UI. This document focuses on launching Explore from a Grafana Cloud stack, but navigation for an OSS stack should be similar.

To explore data, go to your Grafana Cloud console, select your Grafana instance and click Launch.

Then select Explore from the right side menu.

Once Explore opens, select your stack’s log instance from the dropdown menu. The naming convention is grafanacloud-<STACK_NAME>-log.

To view the logs, you can either use the Builder or Code tool to construct a query.

Every query must start with a stream selector. Select one or more labels to create the stream selector. An example of a simple one follows.


If you run the above query for an appropriate time window, you will see all logs that were sent via an OTLP exporter.

When viewing the log entries, the Prettify Json option can be toggled on to help make large statements easier to read; however, you can also write a query so that only fields of interests are included. To do this, add a json stage to the query to transform the log statement into key:value pairs.

{exporter="OTLP"} | json

Run the above query and then scroll down to the result set. Click on a record to expand and view the key:value pairs.

Next, you can customize your log format with a line_format expression that includes only fields of interest.

{exporter="OTLP"} | json | line_format "{{ .body}} {{.traceid}}"

The above query will create a result set that includes only the time, body and traceid fields. If you would like to keep the field label/key you can add them to the line_format expression.

{exporter="OTLP"} |= "INFO" | json | line_format "body:{{ .body}}{{.traceid}}"

Common Framework Formats

The following table provides line_format expressions that attempt to align with a given framework’s default logging format.

Java -
Spring Boot



Expression:{exporter="OTLP"} | json | line_format "{{.resources_process_pid}} {{.severity}} --- [{{.traceid}}] {{.resources_service_name}} {{.resources_service_instance_id}} : {{.body}}"

Note if the timestamp does not display, make sure that the Time property is toggled to on.