Grafana Cloud

Learn about query languages

Grafana Cloud uses three query languages for telemetry data. Each query language is optimized for its signal type: PromQL for metrics, LogQL for logs, and TraceQL for traces. If you’re not sure which signal to use, refer to What are telemetry signals?.

Note

Profiles data sources use visual exploration through Grafana Profiles Drilldown and don’t require a query language.

Each query language provides specific functions and features tailored to its signal type. Choose the query language that matches your data source type. If you are already familiar with PromQL, you can find LogQL and TraceQL to be very similar query languages.

PromQL

PromQL, or Prometheus Query Language, is a query language for time-series metrics. Use PromQL to calculate rates, aggregate across labels, and create complex metric expressions.

PromQL works best for resource monitoring, performance metrics, and service health analysis.

To learn PromQL, start with the Write a PromQL query using the Query Builder learning journey.

For reference documentation, refer to PromQL basics.

LogQL

LogQL, query language for Loki, is a query language for log data. Use LogQL to search for specific log patterns, extract fields from logs, aggregate log data, and create metrics from logs.

LogQL works best for error investigation, log pattern analysis, and troubleshooting application issues.

To learn LogQL, start with the Loki Quick Start, which includes Builder mode and Code mode examples.

For reference documentation, refer to the LogQL reference.

TraceQL

TraceQL is a query language for distributed traces. Use TraceQL to find traces by attributes, filter spans within traces, and analyze request paths through your system.

TraceQL works best for latency investigation, service dependency analysis, and distributed system troubleshooting.

To learn how to use the query editor, refer to Write TraceQL queries with the editor.

Refer to the TraceQL cookbook for example queries.

For reference documentation, refer to TraceQL reference.

Note

As a best practice for writing queries, start in Builder mode in the query editor, and then switch to Code mode to see the generated query. This helps you learn syntax by comparing your visual selections to the code.

Next steps