<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>TraceQL on Grafana Labs</title><link>https://grafana.com/docs/enterprise-traces/v2.7.x/traceql/</link><description>Recent content in TraceQL on Grafana Labs</description><generator>Hugo -- gohugo.io</generator><language>en</language><atom:link href="/docs/enterprise-traces/v2.7.x/traceql/index.xml" rel="self" type="application/rss+xml"/><item><title>Trace structure and TraceQL</title><link>https://grafana.com/docs/enterprise-traces/v2.7.x/traceql/trace-structure/</link><pubDate>Wed, 19 Feb 2025 20:52:00 +0000</pubDate><guid>https://grafana.com/docs/enterprise-traces/v2.7.x/traceql/trace-structure/</guid><content><![CDATA[&lt;h1 id=&#34;trace-structure-and-traceql&#34;&gt;Trace structure and TraceQL&lt;/h1&gt;
&lt;p&gt;Inspired by PromQL and LogQL, TraceQL uses similar syntax and semantics.
The differences being inherent to the very nature of searching spans and traces.&lt;/p&gt;
&lt;h2 id=&#34;trace-structure&#34;&gt;Trace structure&lt;/h2&gt;


&lt;div data-shared=&#34;trace-structure.md&#34;&gt;
            &lt;!--  Trace structure --&gt;
&lt;p&gt;Traces are telemetry data structured as trees.
Traces are made of spans (for example, a span tree); there is a root span that can have zero to multiple branches that are called child spans.
Each child span can itself be a parent span of one or multiple child spans, and so on so forth.&lt;/p&gt;
&lt;p&gt;&lt;img
  class=&#34;lazyload d-inline-block&#34;
  data-src=&#34;/media/docs/tempo/traceql/trace-tree-structures-and-spans.png&#34;
  alt=&#34;Trace_and_spans_in_tree_structure&#34; width=&#34;1600&#34;
     height=&#34;706&#34;/&gt;&lt;/p&gt;
&lt;p&gt;In the specific context of Tempo and 
    &lt;a href=&#34;/docs/tempo/v2.7.x/traceql/&#34;&gt;TraceQL query language&lt;/a&gt;, a span has the following associated fields:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;name&lt;/strong&gt;: the span name&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;duration&lt;/strong&gt;: difference between the end time and start time of the span&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;status&lt;/strong&gt;: enum: &lt;code&gt;{ok, error, unset}&lt;/code&gt;. For details, refer to &lt;a href=&#34;https://opentelemetry.io/docs/concepts/signals/traces/#span-status&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;OTel span status&lt;/a&gt; documentation.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;kind&lt;/strong&gt;: enum: &lt;code&gt;{server, client, producer, consumer, internal, unspecified}&lt;/code&gt;. For more details, refer to &lt;a href=&#34;https://opentelemetry.io/docs/concepts/signals/traces/#span-kind&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;OTel span kind&lt;/a&gt; documentation.&lt;/li&gt;
&lt;li&gt;Attributes&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The first four properties are &lt;em&gt;intrinsics&lt;/em&gt;.
They are fundamental to the span.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Attributes&lt;/em&gt; are custom span metadata in the form of key-value pairs.
There are four types of attributes: span attributes, resource attributes, event attributes, and link attributes.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Span attributes&lt;/em&gt; are key-value pairs that contain metadata that you can use to annotate a span to carry information about the operation it&amp;rsquo;s tracking.
For example, in an eCommerce application, if a span tracks an operation that adds an item to a user’s shopping cart, the user ID, added item ID and cart ID can be captured and attached to the span as span attributes.&lt;/p&gt;
&lt;p&gt;A &lt;em&gt;resource attribute&lt;/em&gt; represents information about an entity producing the span.
For example, a span created by a process running in a container deployed by Kubernetes could link a resource that specifies the cluster name, namespace, pod, and container name.
Resource attributes are resource-related metadata (key-value pairs) that are describing the Resource.&lt;/p&gt;
&lt;p&gt;An &lt;em&gt;event attribute&lt;/em&gt; represents a unique point in the time during the span&amp;rsquo;s duration. For more information, refer to &lt;a href=&#34;/blog/2024/08/15/all-about-span-events-what-they-are-and-how-to-query-them/#how-to-query-span-events-with-traceql&#34;&gt;All about span events&lt;/a&gt; and &lt;a href=&#34;https://opentelemetry.io/docs/concepts/signals/traces/#span-events&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Span events&lt;/a&gt; in the OTEL documentation.&lt;/p&gt;
&lt;p&gt;A &lt;em&gt;link attribute&lt;/em&gt; lets you query link data in a span.
A span link associates one span with one or more other spans that are a casual relationship. For more information on span links, refer to the &lt;a href=&#34;https://opentelemetry.io/docs/concepts/signals/traces/#span-links&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Span Links&lt;/a&gt; documentation in the Open Telemetry project.&lt;/p&gt;
&lt;p&gt;The OpenTelemetry specification defines Semantic Attributes for Spans and for Resources.
Semantic Span Attributes are a set of naming schemes for attributes shared across languages, frameworks, and runtimes.
For more details, refer to &lt;a href=&#34;https://opentelemetry.io/docs/specs/semconv/general/trace/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Trace Semantic Conventions&lt;/a&gt; and &lt;a href=&#34;https://opentelemetry.io/docs/specs/semconv/resource/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Resource Semantic Conventions&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;

        
&lt;h2 id=&#34;traceql-queries&#34;&gt;TraceQL queries&lt;/h2&gt;


&lt;div data-shared=&#34;traceql-query-structure.md&#34;&gt;
            &lt;!--  TraceQL query structure --&gt;
&lt;p&gt;The purpose of TraceQL is to search or query for spans.
The query returns a set of spans, also called a spanset.&lt;/p&gt;
&lt;p&gt;A TraceQL query can select traces based on:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;span attributes, timing and duration&lt;/li&gt;
&lt;li&gt;structural relationships between spans&lt;/li&gt;
&lt;li&gt;aggregated data from the spans in a trace&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;As with PromQL and LogQL, the query is structured as a pipeline of operations (filters and aggregators).
The query expression is evaluated on one trace at a time, selecting or discarding spans from the result.
At each stage of the query pipeline, the selected spans for a trace are grouped in a spanset (set of spans).
The associated trace is also returned. The result of the query is the spansets (and their associated traces) for all the traces evaluated.&lt;/p&gt;
&lt;p&gt;The simplest query is this one:&lt;/p&gt;

&lt;div class=&#34;code-snippet code-snippet__mini&#34;&gt;&lt;div class=&#34;lang-toolbar__mini&#34;&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet code-snippet__border&#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-none&#34;&gt;{ }&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The curly braces encompass the select/filter conditions.
In theory, each span (and the trace it belongs to) matching those conditions is returned by the query.
In the previous example, since there are no filter conditions, all spans are matching and thus returned with their associated traces.&lt;/p&gt;
&lt;p&gt;In practice, the query is performed against a defined time interval, relative (for example, the last 3 hours) or absolute (for example, from X date-time to Y date-time).
The query response is also limited by the number of traces (&lt;strong&gt;Limit&lt;/strong&gt;) and spans per spanset (&lt;strong&gt;Span Limit&lt;/strong&gt;).&lt;/p&gt;
&lt;p&gt;&lt;img
  class=&#34;lazyload d-inline-block&#34;
  data-src=&#34;/media/docs/tempo/traceql/TraceQL-in-Grafana.png&#34;
  alt=&#34;TraceQL in Grafana&#34; width=&#34;3006&#34;
     height=&#34;1544&#34;/&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;TraceQL query editor&lt;/li&gt;
&lt;li&gt;Query options: &lt;strong&gt;Limit&lt;/strong&gt;, &lt;strong&gt;Span Limit&lt;/strong&gt; and &lt;strong&gt;Table Format&lt;/strong&gt; (Traces or Spans).&lt;/li&gt;
&lt;li&gt;Trace (by Trace ID). The &lt;strong&gt;Name&lt;/strong&gt; and &lt;strong&gt;Service&lt;/strong&gt; columns are displaying the trace root span name and associated service.&lt;/li&gt;
&lt;li&gt;Spans associated to the Trace&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;

        
]]></content><description>&lt;h1 id="trace-structure-and-traceql">Trace structure and TraceQL&lt;/h1>
&lt;p>Inspired by PromQL and LogQL, TraceQL uses similar syntax and semantics.
The differences being inherent to the very nature of searching spans and traces.&lt;/p></description></item><item><title>How TraceQL works</title><link>https://grafana.com/docs/enterprise-traces/v2.7.x/traceql/architecture/</link><pubDate>Tue, 11 Mar 2025 21:31:02 +0000</pubDate><guid>https://grafana.com/docs/enterprise-traces/v2.7.x/traceql/architecture/</guid><content><![CDATA[&lt;h1 id=&#34;how-traceql-works&#34;&gt;How TraceQL works&lt;/h1&gt;
&lt;p&gt;The TraceQL engine connects the Tempo API handler with the storage layer. The TraceQL engine:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Parses incoming requests and extract flattened conditions the storage layer can work with&lt;/li&gt;
&lt;li&gt;Pulls spansets from the storage layer and revalidates that the query matches each span&lt;/li&gt;
&lt;li&gt;Returns the search response&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The default Tempo search reviews the whole trace. TraceQL provides a method for formulating precise queries so you can zoom in to the data you need. Query results are returned faster because the queries limit what&amp;rsquo;s searched.&lt;/p&gt;
&lt;p&gt;For a deeper look at TraceQL, read the &lt;a href=&#34;/blog/2022/11/30/traceql-a-first-of-its-kind-query-language-to-accelerate-trace-analysis-in-tempo-2.0/&#34;&gt;TraceQL: A first-of-its-kind query language to accelerate trace analysis in Tempo 2.0&lt;/a&gt; blog post.&lt;/p&gt;
&lt;p&gt;For examples of query syntax, refer to 
    &lt;a href=&#34;/docs/enterprise-traces/v2.7.x/traceql/#construct-a-traceql-query&#34;&gt;Construct a TraceQL query&lt;/a&gt;.&lt;/p&gt;





  
  
  


&lt;div&gt;
  &lt;iframe src=&#34;https://player.vimeo.com/video/742056367?transparent=0&#34; title=&#34;vimeo video&#34; webkitallowfullscreen=&#34;&#34; mozallowfullscreen=&#34;&#34; allowfullscreen=&#34;&#34;&gt;&lt;/iframe&gt;
  &lt;div &gt;
    
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;active-development-and-limitations&#34;&gt;Active development and limitations&lt;/h2&gt;
&lt;p&gt;TraceQL will be implemented in phases. The initial iteration of the TraceQL engine includes spanset selection and pipelines.&lt;/p&gt;
&lt;p&gt;For more information about TraceQL’s design, refer to the &lt;a href=&#34;https://github.com/grafana/tempo/blob/main/docs/design-proposals/2023-11%20TraceQL%20Extensions.md&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;TraceQL extensions&lt;/a&gt; abd &lt;a href=&#34;https://github.com/grafana/tempo/blob/main/docs/design-proposals/2022-04%20TraceQL%20Concepts.md&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;TraceQL Concepts&lt;/a&gt; design proposals.&lt;/p&gt;
]]></content><description>&lt;h1 id="how-traceql-works">How TraceQL works&lt;/h1>
&lt;p>The TraceQL engine connects the Tempo API handler with the storage layer. The TraceQL engine:&lt;/p>
&lt;ul>
&lt;li>Parses incoming requests and extract flattened conditions the storage layer can work with&lt;/li>
&lt;li>Pulls spansets from the storage layer and revalidates that the query matches each span&lt;/li>
&lt;li>Returns the search response&lt;/li>
&lt;/ul>
&lt;p>The default Tempo search reviews the whole trace. TraceQL provides a method for formulating precise queries so you can zoom in to the data you need. Query results are returned faster because the queries limit what&amp;rsquo;s searched.&lt;/p></description></item><item><title>Write TraceQL queries in Grafana</title><link>https://grafana.com/docs/enterprise-traces/v2.7.x/traceql/query-editor/</link><pubDate>Mon, 13 Jan 2025 17:58:36 +0000</pubDate><guid>https://grafana.com/docs/enterprise-traces/v2.7.x/traceql/query-editor/</guid><content><![CDATA[&lt;h1 id=&#34;write-traceql-queries-in-grafana&#34;&gt;Write TraceQL queries in Grafana&lt;/h1&gt;
&lt;p&gt;The Tempo data source&amp;rsquo;s query editor helps you query and display traces from Tempo in 
    &lt;a href=&#34;/docs/grafana/next/explore/&#34;&gt;Explore&lt;/a&gt;.
The queries use 
    &lt;a href=&#34;/docs/enterprise-traces/v2.7.x/traceql/&#34;&gt;TraceQL&lt;/a&gt;, the query language designed specifically for tracing.&lt;/p&gt;
&lt;p&gt;For general documentation on querying data sources in Grafana, refer to 
    &lt;a href=&#34;/docs/grafana/next/panels-visualizations/query-transform-data/&#34;&gt;Query and transform data&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;before-you-begin&#34;&gt;Before you begin&lt;/h2&gt;
&lt;p&gt;You can compose TraceQL queries in Grafana and Grafana Cloud using &lt;strong&gt;Explore&lt;/strong&gt; and a Tempo data source.&lt;/p&gt;
&lt;h2 id=&#34;choose-a-query-editing-mode&#34;&gt;Choose a query editing mode&lt;/h2&gt;
&lt;p&gt;The query editor has three modes, or &lt;strong&gt;Query types&lt;/strong&gt;, that you can use to explore your tracing data.
You can use these modes by themselves or in combination to create building blocks to generate custom queries.&lt;/p&gt;
&lt;p&gt;&lt;img
  class=&#34;lazyload d-inline-block&#34;
  data-src=&#34;/media/docs/grafana/data-sources/tempo/query-editor/tempo-ds-query-types.png&#34;
  alt=&#34;The three query types: Search, TraceQL, and Service Graph&#34; width=&#34;807&#34;
     height=&#34;86&#34;/&gt;&lt;/p&gt;
&lt;p&gt;The three &lt;strong&gt;Query types&lt;/strong&gt; are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The &lt;strong&gt;Search&lt;/strong&gt; query builder provides a user interface for building a TraceQL query.&lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;TraceQL&lt;/strong&gt; query editor lets you write your own TraceQL query with assistance from autocomplete.&lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;Service Graph&lt;/strong&gt; view displays a visual relationship between services. Refer to the 
    &lt;a href=&#34;/docs/enterprise-traces/v2.7.x/metrics-generator/service-graph-view/&#34;&gt;Service graph view&lt;/a&gt; documentation for more information.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;search-query-builder&#34;&gt;Search query builder&lt;/h3&gt;
&lt;p&gt;The Search query builder provides drop-down lists and text fields to help you write a query.
The query builder is ideal for people who aren&amp;rsquo;t familiar with or want to learn TraceQL.&lt;/p&gt;
&lt;p&gt;Refer to the 
    &lt;a href=&#34;/docs/grafana/next/datasources/tempo/query-editor/traceql-search/&#34;&gt;Search using the TraceQL query builder documentation&lt;/a&gt; to learn more about creating queries using convenient drop-down menus.&lt;/p&gt;
&lt;p&gt;&lt;img
  class=&#34;lazyload d-inline-block&#34;
  data-src=&#34;/media/docs/grafana/data-sources/tempo/query-editor/tempo-ds-query-search-v11.png&#34;
  alt=&#34;The Search query builder&#34; width=&#34;1011&#34;
     height=&#34;435&#34;/&gt;&lt;/p&gt;
&lt;h3 id=&#34;traceql-query-editor&#34;&gt;TraceQL query editor&lt;/h3&gt;
&lt;p&gt;The TraceQL query editor lets you search by trace ID and write TraceQL queries using autocomplete.&lt;/p&gt;
&lt;p&gt;Refer to the 
    &lt;a href=&#34;/docs/grafana/next/datasources/tempo/query-editor/traceql-editor/&#34;&gt;TraceQL query editor documentation&lt;/a&gt; to learn more about constructing queries using a code-editor-like experience.&lt;/p&gt;
&lt;p&gt;&lt;img
  class=&#34;lazyload d-inline-block&#34;
  data-src=&#34;/media/docs/grafana/data-sources/tempo/query-editor/tempo-ds-query-traceql-v11.png&#34;
  alt=&#34;The TraceQL query editor&#34; width=&#34;1007&#34;
     height=&#34;277&#34;/&gt;&lt;/p&gt;
&lt;p&gt;You can also search for a Trace ID by entering a trace ID into the query field.&lt;/p&gt;
&lt;h3 id=&#34;service-graph-view&#34;&gt;Service graph view&lt;/h3&gt;
&lt;p&gt;Grafana’s service graph view uses metrics to display span request rates, error rates, and durations, as well as service graphs.
Once the requirements are set up, this pre-configured view is immediately available.&lt;/p&gt;
&lt;p&gt;Using the service graph view, you can:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Discover spans which are consistently erroring and the rates at which they occur&lt;/li&gt;
&lt;li&gt;Get an overview of the overall rate of span calls throughout your services&lt;/li&gt;
&lt;li&gt;Determine how long the slowest queries in your service take to complete&lt;/li&gt;
&lt;li&gt;Examine all traces that contain spans of particular interest based on rate, error, and duration values (RED signals)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For more information about the service graph, refer to 
    &lt;a href=&#34;/docs/enterprise-traces/v2.7.x/metrics-generator/service-graph-view/&#34;&gt;Service graph view&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img
  class=&#34;lazyload d-inline-block&#34;
  data-src=&#34;/media/docs/grafana/data-sources/tempo/query-editor/tempo-ds-query-service-graph.png&#34;
  alt=&#34;Screenshot of the Service Graph view&#34; width=&#34;1290&#34;
     height=&#34;1145&#34;/&gt;&lt;/p&gt;
&lt;h2 id=&#34;use-traceql-panels-in-dashboards&#34;&gt;Use TraceQL panels in dashboards&lt;/h2&gt;
&lt;p&gt;To add TraceQL panels to your dashboard, refer to the 
    &lt;a href=&#34;/docs/grafana/next/panels-visualizations/visualizations/traces/&#34;&gt;Traces panel documentation&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;To learn more about Grafana dashboards, refer to the 
    &lt;a href=&#34;/docs/grafana/next/dashboards/use-dashboards/&#34;&gt;Use dashboards documentation&lt;/a&gt;.&lt;/p&gt;
]]></content><description>&lt;h1 id="write-traceql-queries-in-grafana">Write TraceQL queries in Grafana&lt;/h1>
&lt;p>The Tempo data source&amp;rsquo;s query editor helps you query and display traces from Tempo in
&lt;a href="/docs/grafana/next/explore/">Explore&lt;/a>.
The queries use
&lt;a href="/docs/enterprise-traces/v2.7.x/traceql/">TraceQL&lt;/a>, the query language designed specifically for tracing.&lt;/p></description></item><item><title>TraceQL metrics queries</title><link>https://grafana.com/docs/enterprise-traces/v2.7.x/traceql/metrics-queries/</link><pubDate>Thu, 24 Apr 2025 21:41:19 +0000</pubDate><guid>https://grafana.com/docs/enterprise-traces/v2.7.x/traceql/metrics-queries/</guid><content><![CDATA[&lt;h1 id=&#34;traceql-metrics-queries&#34;&gt;TraceQL metrics queries&lt;/h1&gt;



&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;TraceQL metrics is an &lt;a href=&#34;/docs/release-life-cycle/&#34;&gt;experimental feature&lt;/a&gt;. Engineering and on-call support is not available. Documentation is either limited or not provided outside of code comments. No SLA is provided. Enable the  feature toggle in Grafana to use this feature. Do not enable this feature in production environments.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;


&lt;p&gt;TraceQL metrics is an experimental feature in Grafana Tempo that creates metrics from traces.&lt;/p&gt;
&lt;p&gt;Metric queries extend trace queries by applying a function to trace query results.
This powerful feature allows for ad hoc aggregation of any existing TraceQL query by any dimension available in your traces, much in the same way that LogQL metric queries create metrics from logs.&lt;/p&gt;
&lt;p&gt;Traces are a unique observability signal that contain causal relationships between the components in your system.&lt;/p&gt;
&lt;p&gt;TraceQL metrics can help answer questions like this:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;How many database calls across all systems are downstream of your application?&lt;/li&gt;
&lt;li&gt;What services beneath a given endpoint are failing?&lt;/li&gt;
&lt;li&gt;What services beneath an endpoint are slow?&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;TraceQL metrics can help you answer these questions by parsing your traces in aggregate.&lt;/p&gt;
&lt;p&gt;TraceQL metrics are powered by the 
    &lt;a href=&#34;/docs/enterprise-traces/v2.7.x/api_docs/#traceql-metrics&#34;&gt;TraceQL metrics API&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img
  class=&#34;lazyload d-inline-block&#34;
  data-src=&#34;/media/docs/tempo/metrics-explore-sapmle-v2.7.png&#34;
  alt=&#34;Metrics visualization in Grafana&#34; width=&#34;1271&#34;
     height=&#34;899&#34;/&gt;&lt;/p&gt;
&lt;h2 id=&#34;red-metrics-traceql-and-promql&#34;&gt;RED metrics, TraceQL, and PromQL&lt;/h2&gt;
&lt;p&gt;RED is an acronym for three types of metrics:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Rate, the number of requests per second&lt;/li&gt;
&lt;li&gt;Errors, the number of those requests that are failing&lt;/li&gt;
&lt;li&gt;Duration, the amount of time those requests take&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For more information about the RED method, refer to &lt;a href=&#34;/blog/2018/08/02/the-red-method-how-to-instrument-your-services/&#34;&gt;The RED Method: how to instrument your services&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;You can write TraceQL metrics queries to compute rate, errors, and durations over different groups of spans.&lt;/p&gt;
&lt;p&gt;For more information on how to use TraceQL metrics to investigate issues, refer to 
    &lt;a href=&#34;/docs/enterprise-traces/v2.7.x/traceql/metrics-queries/solve-problems-metrics-queries/&#34;&gt;Solve problems with metrics queries&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;enable-and-use-traceql-metrics&#34;&gt;Enable and use TraceQL metrics&lt;/h2&gt;
&lt;p&gt;To use TraceQL metrics, you need to enable them on your Tempo database.
Refer to 
    &lt;a href=&#34;/docs/tempo/v2.7.x/operations/traceql-metrics/&#34;&gt;Configure TraceQL metrics&lt;/a&gt; for more information.&lt;/p&gt;
&lt;p&gt;From there, you can either query the TraceQL metrics API directly (for example, with &lt;code&gt;curl&lt;/code&gt;) or using Grafana
(recommended).
To run TraceQL metrics queries in Grafana, you need Grafana Cloud or Grafana 10.4 or later.
No extra configuration is needed.
Use a Tempo data source that points to a Tempo database with TraceQL metrics enabled.&lt;/p&gt;
&lt;p&gt;Refer to 
    &lt;a href=&#34;/docs/enterprise-traces/v2.7.x/traceql/metrics-queries/solve-problems-metrics-queries/&#34;&gt;Solve problems using metrics queries&lt;/a&gt; for some real-world examples.&lt;/p&gt;
&lt;h3 id=&#34;functions&#34;&gt;Functions&lt;/h3&gt;
&lt;p&gt;TraceQL metrics queries currently include the following functions for aggregating over groups of spans: &lt;code&gt;rate&lt;/code&gt;, &lt;code&gt;count_over_time&lt;/code&gt;, &lt;code&gt;max_over_time&lt;/code&gt;, &lt;code&gt;min_over_time&lt;/code&gt;, &lt;code&gt;avg_over_time&lt;/code&gt;, &lt;code&gt;quantile_over_time&lt;/code&gt;, &lt;code&gt;histogram_over_time&lt;/code&gt;, and &lt;code&gt;compare&lt;/code&gt;.
These functions can be added as an operator at the end of any TraceQL query.&lt;/p&gt;
&lt;p&gt;For detailed information and example queries for each function, refer to 
    &lt;a href=&#34;/docs/enterprise-traces/v2.7.x/traceql/metrics-queries/functions/&#34;&gt;TraceQL metrics functions&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&#34;exemplars&#34;&gt;Exemplars&lt;/h3&gt;
&lt;p&gt;Exemplars are a powerful feature of TraceQL metrics.
They allow you to see an exact trace that contributed to a given metric value.
This is particularly useful when you want to understand why a given metric is high or low.&lt;/p&gt;
&lt;p&gt;Exemplars are available in TraceQL metrics for all range queries.
To get exemplars, you need to configure it in the query-frontend with the parameter &lt;code&gt;query_frontend.metrics.max_exemplars&lt;/code&gt;,
or pass a query hint in your query.&lt;/p&gt;
&lt;p&gt;Example:&lt;/p&gt;

&lt;div class=&#34;code-snippet code-snippet__mini&#34;&gt;&lt;div class=&#34;lang-toolbar__mini&#34;&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet code-snippet__border&#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-none&#34;&gt;{ span:name = &amp;#34;GET /:endpoint&amp;#34; } | quantile_over_time(duration, .99) by (span.http.target) with (exemplars=true)&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;TraceQL metric queries with exemplars aren&amp;rsquo;t fully supported in Grafana Explore.
They will be supported in a future Grafana release.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

]]></content><description>&lt;h1 id="traceql-metrics-queries">TraceQL metrics queries&lt;/h1>
&lt;div class="admonition admonition-note">&lt;blockquote>&lt;p class="title text-uppercase">Note&lt;/p>&lt;p>TraceQL metrics is an &lt;a href="/docs/release-life-cycle/">experimental feature&lt;/a>. Engineering and on-call support is not available. Documentation is either limited or not provided outside of code comments. No SLA is provided. Enable the feature toggle in Grafana to use this feature. Do not enable this feature in production environments.&lt;/p></description></item></channel></rss>