<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Query tracing data on Grafana Labs</title><link>https://grafana.com/docs/grafana/v13.0/datasources/tempo/query-editor/</link><description>Recent content in Query tracing data on Grafana Labs</description><generator>Hugo -- gohugo.io</generator><language>en</language><atom:link href="/docs/grafana/v13.0/datasources/tempo/query-editor/index.xml" rel="self" type="application/rss+xml"/><item><title>Search traces using the query builder</title><link>https://grafana.com/docs/grafana/v13.0/datasources/tempo/query-editor/traceql-search/</link><pubDate>Tue, 14 Apr 2026 14:59:56 +0000</pubDate><guid>https://grafana.com/docs/grafana/v13.0/datasources/tempo/query-editor/traceql-search/</guid><content><![CDATA[&lt;h1 id=&#34;search-traces-using-the-query-builder&#34;&gt;Search traces using the query builder&lt;/h1&gt;
&lt;p&gt;The &lt;strong&gt;Search&lt;/strong&gt; query builder lets you create TraceQL queries using drop-down lists and text fields instead of writing syntax directly.
Each selection you make generates a TraceQL query behind the scenes.
You can view the generated query and copy it to the &lt;a href=&#34;../traceql-editor/&#34;&gt;TraceQL editor&lt;/a&gt; at any time.&lt;/p&gt;
&lt;p&gt;Use Search when you&amp;rsquo;re exploring data or learning TraceQL patterns.
For complex queries involving structural operators, aggregations, or features that Search doesn&amp;rsquo;t support, use the &lt;a href=&#34;../traceql-editor/&#34;&gt;TraceQL editor&lt;/a&gt;.
To learn the full query syntax, refer to 
    &lt;a href=&#34;/docs/tempo/latest/traceql/construct-traceql-queries/&#34;&gt;Construct a TraceQL query&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;If queries return no results, check that your &lt;a href=&#34;../configure-tempo-data-source/&#34;&gt;Tempo data source is configured and connected&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;enable-search-with-the-query-builder&#34;&gt;Enable Search with the query builder&lt;/h2&gt;
&lt;p&gt;This feature is automatically available in Grafana 10 (and newer) and Grafana Cloud.&lt;/p&gt;
&lt;p&gt;To enable the TraceQL query builder in self-managed Grafana through version 10.1, 
    &lt;a href=&#34;/docs/grafana/v13.0/setup-grafana/configure-grafana/feature-toggles/&#34;&gt;enable the &lt;code&gt;traceqlSearch&lt;/code&gt; feature toggle&lt;/a&gt;.&lt;/p&gt;


&lt;div data-shared=&#34;datasources/tempo-search-traceql.md&#34;&gt;
            

&lt;h2 id=&#34;write-traceql-queries-using-search&#34;&gt;Write TraceQL queries using Search&lt;/h2&gt;
&lt;p&gt;The &lt;strong&gt;Search&lt;/strong&gt; query builder, located on the &lt;strong&gt;Explore&lt;/strong&gt; &amp;gt; &lt;strong&gt;Query type&lt;/strong&gt; &amp;gt; &lt;strong&gt;Search&lt;/strong&gt; in Grafana, provides drop-down lists and text fields to help you write a query.
The selections you make automatically generate a &lt;a href=&#34;/docs/tempo/latest/traceql/&#34;&gt;TraceQL query&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-search-v11.png&#34;
  alt=&#34;The Search query builder&#34; width=&#34;1011&#34;
     height=&#34;435&#34;/&gt;&lt;/p&gt;
&lt;p&gt;The builder lets you run the most common queries in as few clicks as possible. You don&amp;rsquo;t need to know the underlying query language or database architecture to use it.&lt;/p&gt;
&lt;p&gt;The builder supports a subset of TraceQL capabilities, including some structural operators (&lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;gt;&lt;/code&gt;, &lt;code&gt;=~&lt;/code&gt;, &lt;code&gt;!=&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;To access &lt;strong&gt;Search&lt;/strong&gt;, select your Tempo data source, and then choose &lt;strong&gt;Explore&lt;/strong&gt; and select &lt;strong&gt;Query type&lt;/strong&gt; &amp;gt; &lt;strong&gt;Search&lt;/strong&gt;.
You can use the query builder to search trace data by resource service name, span name, duration, one or more tags. The examples on this page use the default filters.&lt;/p&gt;
&lt;p&gt;In addition, you can add query builder blocks, view the query history, and use the &lt;strong&gt;Inspector&lt;/strong&gt; to see details.&lt;/p&gt;
&lt;figure
    class=&#34;figure-wrapper figure-wrapper__lightbox w-100p docs-image--no-shadow&#34;
    style=&#34;max-width: 750px;&#34;
    itemprop=&#34;associatedMedia&#34;
    itemscope=&#34;&#34;
    itemtype=&#34;http://schema.org/ImageObject&#34;
  &gt;&lt;a
        class=&#34;lightbox-link captioned&#34;
        href=&#34;/media/docs/grafana/data-sources/tempo/query-editor/tempo-ds-query-builder-v11.png&#34;
        itemprop=&#34;contentUrl&#34;
      &gt;&lt;div class=&#34;img-wrapper w-100p h-auto&#34;&gt;&lt;img
          class=&#34;lazyload mb-0&#34;
          data-src=&#34;/media/docs/grafana/data-sources/tempo/query-editor/tempo-ds-query-builder-v11.png&#34;data-srcset=&#34;/media/docs/grafana/data-sources/tempo/query-editor/tempo-ds-query-builder-v11.png?w=320 320w, /media/docs/grafana/data-sources/tempo/query-editor/tempo-ds-query-builder-v11.png?w=550 550w, /media/docs/grafana/data-sources/tempo/query-editor/tempo-ds-query-builder-v11.png?w=750 750w, /media/docs/grafana/data-sources/tempo/query-editor/tempo-ds-query-builder-v11.png?w=900 900w, /media/docs/grafana/data-sources/tempo/query-editor/tempo-ds-query-builder-v11.png?w=1040 1040w, /media/docs/grafana/data-sources/tempo/query-editor/tempo-ds-query-builder-v11.png?w=1240 1240w, /media/docs/grafana/data-sources/tempo/query-editor/tempo-ds-query-builder-v11.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;Screenshot of the Tempo Search query type&#34;width=&#34;1034&#34;height=&#34;859&#34;title=&#34;Screenshot of the Tempo Search query type&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/media/docs/grafana/data-sources/tempo/query-editor/tempo-ds-query-builder-v11.png&#34;
            alt=&#34;Screenshot of the Tempo Search query type&#34;width=&#34;1034&#34;height=&#34;859&#34;title=&#34;Screenshot of the Tempo Search query type&#34;class=&#34;docs-image--no-shadow&#34;/&gt;
        &lt;/noscript&gt;&lt;/div&gt;&lt;figcaption class=&#34;w-100p caption text-gray-13  &#34;&gt;Screenshot of the Tempo Search query type&lt;/figcaption&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;h3 id=&#34;perform-a-search&#34;&gt;Perform a search&lt;/h3&gt;
&lt;p&gt;To perform a search, you need to select filters and then run the query. The results appear underneath the query builder.
The screenshot identifies the areas used to perform a search.&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-build-numbered-v11.png&#34;
  alt=&#34;Parts of the Search query builder&#34; width=&#34;1416&#34;
     height=&#34;624&#34;/&gt;&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th style=&#34;text-align: left&#34;&gt;Number&lt;/th&gt;
              &lt;th style=&#34;text-align: left&#34;&gt;Name&lt;/th&gt;
              &lt;th style=&#34;text-align: left&#34;&gt;Action&lt;/th&gt;
              &lt;th style=&#34;text-align: left&#34;&gt;Comment&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;1&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;Data source&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;Use the data source drop-down list to select a Tempo data source.&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;Each data source has its own version of search. This &lt;strong&gt;Search&lt;/strong&gt; is specific to the Tempo data source.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;2&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;Query type&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;Select &lt;strong&gt;Search&lt;/strong&gt;.&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;3&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;Choose filter&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;Choose one or more of the filters.&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;Optional. You can execute an empty query in the Search tab. In TraceQL, &lt;code&gt;{}&lt;/code&gt; is a valid query and is the default query to provide a list of all traces or spans.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;4&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;Filters conditions&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;Select options for one or more filters. For example, you can define a filter where &lt;strong&gt;Service Name&lt;/strong&gt; (&lt;code&gt;resource.service.name&lt;/code&gt;) equals (&lt;code&gt;=&lt;/code&gt;) &lt;code&gt;user&lt;/code&gt;.&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;Optional. At least one tag or filter must be defined.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;5&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;Tags and Aggregate by&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;Add tags for span, resource, or unscoped and define their conditions. Use &lt;strong&gt;Aggregate by&lt;/strong&gt; to group results.&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;Optional.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;6&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;TraceQL query&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;Displays the TraceQL query constructed by your selections.&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;This TraceQL query is executed when you select &lt;strong&gt;Run query&lt;/strong&gt;.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;p&gt;Every query searches the data for the selected time frame.
By default, queries run against data from the last hour.
Select &lt;strong&gt;Time range&lt;/strong&gt; to the left of &lt;strong&gt;Run query&lt;/strong&gt; to choose the time range for the data your query runs against.
Read the &lt;a href=&#34;/docs/grafana/latest/dashboards/use-dashboards/#set-dashboard-time-range&#34;&gt;dashboard time range&lt;/a&gt; documentation to learn more.&lt;/p&gt;
&lt;p&gt;To access the &lt;strong&gt;Search&lt;/strong&gt; query builder, use the following steps:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Sign into Grafana.&lt;/li&gt;
&lt;li&gt;Select your Tempo data source.&lt;/li&gt;
&lt;li&gt;From the menu, choose &lt;strong&gt;Explore&lt;/strong&gt; and select &lt;strong&gt;Query type &amp;gt; Search&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&#34;define-filters&#34;&gt;Define filters&lt;/h3&gt;
&lt;p&gt;Using filters, you refine the data returned from the query by selecting &lt;strong&gt;Service Name&lt;/strong&gt;, &lt;strong&gt;Span Name&lt;/strong&gt;, &lt;strong&gt;Status&lt;/strong&gt;, or &lt;strong&gt;Duration&lt;/strong&gt;.
&lt;strong&gt;Duration&lt;/strong&gt; represents span time, calculated by subtracting the end time from the start time of the span.&lt;/p&gt;
&lt;p&gt;Grafana administrators can change the default filters using the Tempo data source configuration.
Filters can be limited by the operators.
The field type determines the available operators.
For example, &lt;strong&gt;Span Name&lt;/strong&gt; and &lt;strong&gt;Service Name&lt;/strong&gt; are string fields so the comparison operators are equals (&lt;code&gt;=&lt;/code&gt;), not equal (&lt;code&gt;!=&lt;/code&gt;), matches regular expressions (&lt;code&gt;=~&lt;/code&gt;), or doesn&amp;rsquo;t match regular expression (&lt;code&gt;!~&lt;/code&gt;).
&lt;strong&gt;Duration&lt;/strong&gt; is a duration field type and uses range selections (&lt;code&gt;&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;gt;=&lt;/code&gt;, &lt;code&gt;&amp;lt;&lt;/code&gt;, &lt;code&gt;&amp;lt;=&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;When you select multiple values for the same filter, Grafana automatically changes the operator to the regular expression (regex) operator &lt;code&gt;=~&lt;/code&gt; and concatenates the values with a &lt;code&gt;|&lt;/code&gt;.
This capability only applies to fields with drop-down value selection.&lt;/p&gt;
&lt;p&gt;For example, if you choose &lt;strong&gt;Span Name&lt;/strong&gt; &lt;code&gt;= get&lt;/code&gt; and then &lt;strong&gt;Span Name&lt;/strong&gt; &lt;code&gt;= log_results_cache,&lt;/code&gt; operator drop-down list changes from &lt;code&gt;=&lt;/code&gt; to &lt;code&gt;=~&lt;/code&gt; and both &lt;code&gt;get&lt;/code&gt; and &lt;code&gt;log_results_cache&lt;/code&gt; are listed in the &lt;strong&gt;Span Name&lt;/strong&gt; field.
The resulting query is updated with this:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;{duration&amp;gt;5ms &amp;amp;&amp;amp; duration&amp;lt;10ms &amp;amp;&amp;amp; name=~&amp;quot;get|log_results_cache&amp;quot;}&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;To define filters, follow these steps:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Choose one of the filters.&lt;/li&gt;
&lt;li&gt;Select a comparison operator from the drop-down.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Service Name&lt;/strong&gt;, &lt;strong&gt;Span Name&lt;/strong&gt;, and &lt;strong&gt;Status&lt;/strong&gt; only: Select one or more values from the drop-down.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Duration&lt;/strong&gt; only: Enter values and units for the range and choose comparison operators for the drop-downs. Units can be nanoseconds (&lt;code&gt;ns&lt;/code&gt;), milliseconds (&lt;code&gt;ms&lt;/code&gt;), seconds (&lt;code&gt;s&lt;/code&gt;), minutes (&lt;code&gt;m&lt;/code&gt;), and hours (&lt;code&gt;h&lt;/code&gt;).&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;You can either select &lt;strong&gt;Run query&lt;/strong&gt; to execute the query or define tags and then run the query.&lt;/p&gt;
&lt;h4 id=&#34;define-tags&#34;&gt;Define tags&lt;/h4&gt;
&lt;p&gt;You can add any tags to your query to further filter the results.
Tags can be selected by scoped (span or resource) or unscoped.
If you select unscoped, then all tags are searched for matches.&lt;/p&gt;
&lt;p&gt;To add a tag, follow these steps:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Select span, resource, or unscoped.&lt;/li&gt;
&lt;li&gt;Select a tag from the &lt;strong&gt;Select tag&lt;/strong&gt; drop-down.&lt;/li&gt;
&lt;li&gt;Select a comparison operator.&lt;/li&gt;
&lt;li&gt;Select a value from the &lt;strong&gt;Select value&lt;/strong&gt; drop-down. This field is populated based upon the tag.&lt;/li&gt;
&lt;li&gt;Optional: Select &lt;strong&gt;&#43;&lt;/strong&gt; to add another tag.&lt;/li&gt;
&lt;/ol&gt;
&lt;h4 id=&#34;optional-use-aggregate-by&#34;&gt;Optional: Use Aggregate by&lt;/h4&gt;


&lt;div class=&#34;admonition admonition-warning&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Warning&lt;/p&gt;&lt;p&gt;Metrics summary API and the &lt;strong&gt;Aggregate by&lt;/strong&gt; feature are deprecated in Grafana Cloud and Grafana 11.3 and later.
It will be removed in a future release.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;p&gt;Using &lt;strong&gt;Aggregate by&lt;/strong&gt;, you can calculate RED metrics (total span count, percent erroring spans, and latency information) for spans of &lt;code&gt;kind=server&lt;/code&gt; that match your filter criteria, grouped by one or more attributes.
This capability is based on the &lt;a href=&#34;/docs/grafana-cloud/send-data/traces/metrics-summary-api/&#34;&gt;metrics summary API&lt;/a&gt;.
Metrics summary only calculates summaries based on spans received within the last hour.
For additional information, refer to &lt;a href=&#34;/blog/2023/12/07/traces-to-metrics-ad-hoc-red-metrics-in-grafana-tempo-with-aggregate-by/&#34;&gt;Traces to metrics: Ad-hoc RED metrics in Grafana Tempo with &lt;code&gt;Aggregate by&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;!--Impromptu RED metrics with Aggregate by --&gt;
&lt;iframe width=&#34;560&#34; height=&#34;315&#34; src=&#39;https://www.youtube.com/embed/xOolCpm2F8c&#39; title=&#34;YouTube video player&#34; frameborder=&#34;0&#34; allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; allowfullscreen&gt;&lt;/iframe&gt;
&lt;p&gt;&lt;strong&gt;Aggregate by&lt;/strong&gt; is disabled by default.
&lt;a href=&#34;/docs/grafana/latest/setup-grafana/configure-grafana/feature-toggles/&#34;&gt;Enable the &lt;code&gt;metricsSummary&lt;/code&gt; feature toggle&lt;/a&gt; in Grafana to use this feature.&lt;/p&gt;
&lt;p&gt;Your Grafana Tempo data source must also point to a Tempo database with the &lt;a href=&#34;/docs/tempo/latest/api_docs/metrics-summary/&#34;&gt;Metrics Summary API&lt;/a&gt; enabled.
Contact Grafana Support to enable this feature in Grafana Cloud.&lt;/p&gt;
&lt;h5 id=&#34;use-aggregate-by&#34;&gt;Use Aggregate by&lt;/h5&gt;
&lt;p&gt;When you use &lt;strong&gt;Aggregate by&lt;/strong&gt;, the selections you make determine how the information is reported in the Table.
Every combination that matches selections in your data is listed in the table.
Each aggregate value, for example &lt;code&gt;intrinsic&lt;/code&gt;:&lt;code&gt;name&lt;/code&gt;, has a corresponding column in the results table.&lt;/p&gt;
&lt;p&gt;For example, &lt;strong&gt;names&lt;/strong&gt; matching &lt;code&gt;GET /:endpoint&lt;/code&gt; with a &lt;strong&gt;span.http.user_agent&lt;/strong&gt; of &lt;code&gt;k6/0.46&lt;/code&gt; appeared in 31,466 spans. Instead of being listed by traces and associated spans, the query results are grouped by the selections in &lt;strong&gt;Aggregate by&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;The RED metrics are calculated for every name and user agent combination found in your data.&lt;/p&gt;
&lt;p&gt;The screenshot shows all of the successful HTTP &lt;code&gt;status_code&lt;/code&gt; API calls against the &lt;code&gt;mystical-server&lt;/code&gt; service.
The results are shown in the same order used in &lt;strong&gt;Aggregate by&lt;/strong&gt;.
For example, &lt;strong&gt;Aggregate by&lt;/strong&gt; lists &lt;code&gt;intrinsic.name&lt;/code&gt; followed by &lt;code&gt;span.http.user_agent&lt;/code&gt;.
The first column in the results Table shows &lt;strong&gt;name&lt;/strong&gt; and then &lt;strong&gt;span.http.user_agent&lt;/strong&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-build-aggregate-v11-a.png&#34;
  alt=&#34;Use Aggregate by to calculate RED metrics for spans and group by attributes&#34; width=&#34;1412&#34;
     height=&#34;925&#34;/&gt;&lt;/p&gt;
&lt;p&gt;To use this capability:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;In the &lt;strong&gt;Aggregate by&lt;/strong&gt; row, select a scope from the first drop-down box. For example, &lt;code&gt;span&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Select an attribute from the second drop-down.&lt;/li&gt;
&lt;li&gt;Optional: Select &lt;strong&gt;&#43;&lt;/strong&gt; to add an &lt;strong&gt;Aggregate by&lt;/strong&gt; row.&lt;/li&gt;
&lt;li&gt;Optional: Select a &lt;strong&gt;Time range&lt;/strong&gt; to expand or narrow the data set for an hour&amp;rsquo;s range.&lt;/li&gt;
&lt;li&gt;Select &lt;strong&gt;Run query&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;
&lt;!-- Explanation of how to use feature --&gt;
&lt;iframe width=&#34;560&#34; height=&#34;315&#34; src=&#39;https://www.youtube.com/embed/g97CjKOZqT4&#39; title=&#34;YouTube video player&#34; frameborder=&#34;0&#34; allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; allowfullscreen&gt;&lt;/iframe&gt;
&lt;h4 id=&#34;optional-add-query-and-service-graph-blocks&#34;&gt;Optional: Add query and service graph blocks&lt;/h4&gt;
&lt;p&gt;Using &lt;strong&gt;Add query&lt;/strong&gt;, you can have successive query or service node blocks that run in sequential order.
For example, query A runs and then query B.
You can reorder the queries by dragging and dropping them above or below other queries.
Select &lt;strong&gt;&#43; Add query&lt;/strong&gt; to add another query block.&lt;/p&gt;
&lt;p&gt;For more information, refer to 
    &lt;a href=&#34;/docs/grafana/v13.0/datasources/tempo/query-editor/&#34;&gt;Use query types together&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&#34;run-queries-and-view-results&#34;&gt;Run queries and view results&lt;/h3&gt;
&lt;p&gt;Select &lt;strong&gt;Run query&lt;/strong&gt; to run the TraceQL query (1 in the screenshot).&lt;/p&gt;
&lt;p&gt;Queries can take a little while to return results. The results appear in a table underneath the query builder.
Selecting a Trace ID (2 in the screenshot) displays more detailed information (3 in the screenshot).
&lt;strong&gt;Span Filters&lt;/strong&gt; (4 in the screenshot) provide an additional to refine the query results.&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-results-numbered-v11.png&#34;
  alt=&#34;Query results with numbered sections&#34; width=&#34;1482&#34;
     height=&#34;1037&#34;/&gt;&lt;/p&gt;
&lt;h4 id=&#34;stream-results&#34;&gt;Stream results&lt;/h4&gt;
&lt;p&gt;The Tempo data source supports streaming responses to TraceQL queries so you can see partial query results as they come in without waiting for the whole query to finish.&lt;/p&gt;
&lt;p&gt;When active, all configured Tempo data sources attempt to use streaming.
You can activate and control which Tempo data sources do and don&amp;rsquo;t attempt to stream results at the per-data source level using the &lt;strong&gt;Streaming&lt;/strong&gt; section of the Tempo data source configuration.
For more information, refer to the 
    &lt;a href=&#34;/docs/grafana/v13.0/datasources/tempo/configure-tempo-data-source/#streaming&#34;&gt;Tempo data source&lt;/a&gt; documentation.&lt;/p&gt;
&lt;p&gt;Streaming is available for both the &lt;strong&gt;Search&lt;/strong&gt; and &lt;strong&gt;TraceQL&lt;/strong&gt; query types.
You&amp;rsquo;ll get immediate visibility of incoming traces on the results table.&lt;/p&gt;
&lt;div class=&#34;&#34;&gt;
  &lt;figure class=&#34;p-0 m-0 &#34;&gt;
    &lt;video 
      width=&#34;&#34; 
      controls
      muted
      playsinline
      
        class=&#34;lazyload&#34;
        preload=&#34;none&#34;
        
             
      
      
        loop
      
      src=&#34;/media/docs/grafana/data-sources/tempo-streaming-v2.mp4&#34;
      type=&#34;video/mp4&#34;
    &gt;
    &lt;/video&gt;&lt;/figure&gt;
&lt;/div&gt;
&lt;h4 id=&#34;use-filters-and-tags-on-spans&#34;&gt;Use filters and tags on spans&lt;/h4&gt;
&lt;p&gt;Using &lt;strong&gt;Span Filters&lt;/strong&gt;, you can use filters to refine results when viewing span details.
These filters are available when viewing details for a trace.&lt;/p&gt;
&lt;p&gt;You can continue to apply filters until you have narrowed down your resulting spans to the select few you are most interested in.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Service Name&lt;/strong&gt;, &lt;strong&gt;Span Name&lt;/strong&gt;, &lt;strong&gt;Duration&lt;/strong&gt;, and &lt;strong&gt;Tags&lt;/strong&gt; have the same function and operation as the filters of the same name in the &lt;strong&gt;Search&lt;/strong&gt; query builder.&lt;/p&gt;
&lt;p&gt;In addition, you can search for a keyword, opt to &lt;strong&gt;Show matches only&lt;/strong&gt;, opt to &lt;strong&gt;Show critical path only&lt;/strong&gt;, and browse matches using &lt;strong&gt;Prev&lt;/strong&gt; and &lt;strong&gt;Next&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Use &lt;strong&gt;Clear&lt;/strong&gt; to reset the filters.&lt;/p&gt;

  &lt;/div&gt;

        
&lt;h2 id=&#34;try-these-common-searches&#34;&gt;Try these common searches&lt;/h2&gt;
&lt;p&gt;The following examples show what to select in the Search builder and the TraceQL query each selection generates.
Adjust service names and values to match your environment.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Find error spans for a service:&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Set &lt;strong&gt;Service Name&lt;/strong&gt; to your service (for example, &lt;code&gt;frontend&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;Set &lt;strong&gt;Status&lt;/strong&gt; to &lt;code&gt;error&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Generated query:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;traceql&lt;/span&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 class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-traceql&#34;&gt;{ resource.service.name = &amp;#34;frontend&amp;#34; &amp;amp;&amp;amp; status = error }&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Find slow API calls:&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Set &lt;strong&gt;Span Name&lt;/strong&gt; to the operation (for example, &lt;code&gt;POST /api/orders&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;Set &lt;strong&gt;Duration&lt;/strong&gt; to &lt;code&gt;&amp;gt;&lt;/code&gt; &lt;code&gt;500ms&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Generated query:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;traceql&lt;/span&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 class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-traceql&#34;&gt;{ name = &amp;#34;POST /api/orders&amp;#34; &amp;amp;&amp;amp; duration &amp;gt; 500ms }&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Filter by HTTP status code:&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Select &lt;strong&gt;Add tag&lt;/strong&gt;, choose &lt;strong&gt;span&lt;/strong&gt;, and select &lt;code&gt;http.response.status_code&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Set the operator to &lt;code&gt;&amp;gt;=&lt;/code&gt; and the value to &lt;code&gt;500&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Generated query:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;traceql&lt;/span&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 class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-traceql&#34;&gt;{ span.http.response.status_code &amp;gt;= 500 }&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;For more query examples, refer to &lt;a href=&#34;../traceql-query-examples/&#34;&gt;TraceQL query examples&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;next-steps&#34;&gt;Next steps&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;../traceql-query-examples/&#34;&gt;TraceQL query examples&lt;/a&gt;: Copy-paste query examples for common use cases&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;../traceql-editor/&#34;&gt;Write TraceQL queries with the editor&lt;/a&gt;: For complex queries the Search builder doesn&amp;rsquo;t support&lt;/li&gt;
&lt;li&gt;
    &lt;a href=&#34;/docs/tempo/latest/traceql/construct-traceql-queries/&#34;&gt;Construct a TraceQL query&lt;/a&gt;: Full TraceQL syntax reference&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;../../service-graph/&#34;&gt;Service Graph and Service Graph view&lt;/a&gt;: Visualize service dependencies&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;../../span-filters/&#34;&gt;Span filters&lt;/a&gt;: Refine results in the trace detail view&lt;/li&gt;
&lt;/ul&gt;
]]></content><description>&lt;h1 id="search-traces-using-the-query-builder">Search traces using the query builder&lt;/h1>
&lt;p>The &lt;strong>Search&lt;/strong> query builder lets you create TraceQL queries using drop-down lists and text fields instead of writing syntax directly.
Each selection you make generates a TraceQL query behind the scenes.
You can view the generated query and copy it to the &lt;a href="../traceql-editor/">TraceQL editor&lt;/a> at any time.&lt;/p></description></item><item><title>Write TraceQL queries with the editor</title><link>https://grafana.com/docs/grafana/v13.0/datasources/tempo/query-editor/traceql-editor/</link><pubDate>Tue, 14 Apr 2026 14:59:56 +0000</pubDate><guid>https://grafana.com/docs/grafana/v13.0/datasources/tempo/query-editor/traceql-editor/</guid><content><![CDATA[&lt;h1 id=&#34;write-traceql-queries-with-the-editor&#34;&gt;Write TraceQL queries with the editor&lt;/h1&gt;
&lt;p&gt;Use the &lt;strong&gt;TraceQL&lt;/strong&gt; editor when you need structural queries across parent and child spans, aggregations, or other features that the &lt;a href=&#34;../traceql-search/&#34;&gt;Search query builder&lt;/a&gt; doesn&amp;rsquo;t support.
TraceQL queries follow the pattern &lt;code&gt;{ conditions } | pipeline&lt;/code&gt;.
Refer to 
    &lt;a href=&#34;/docs/tempo/latest/traceql/construct-traceql-queries/&#34;&gt;Construct a TraceQL query&lt;/a&gt; for the full syntax.&lt;/p&gt;
&lt;p&gt;To get started, paste this query into the editor and select &lt;strong&gt;Run query&lt;/strong&gt;:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;traceql&lt;/span&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 class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-traceql&#34;&gt;{ resource.service.name = &amp;#34;frontend&amp;#34; &amp;amp;&amp;amp; span:status = error }&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;This returns all error spans from the &lt;code&gt;frontend&lt;/code&gt; service.
Replace &lt;code&gt;frontend&lt;/code&gt; with your service name.
For more examples, refer to &lt;a href=&#34;../traceql-query-examples/&#34;&gt;TraceQL query examples&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;If queries return no results, check that your &lt;a href=&#34;../../configure-tempo-data-source/&#34;&gt;Tempo data source is configured and connected&lt;/a&gt;.&lt;/p&gt;


&lt;div data-shared=&#34;datasources/tempo-editor-traceql.md&#34;&gt;
            &lt;!-- # Write TraceQL queries using the query editor --&gt;
&lt;p&gt;Inspired by PromQL and LogQL, TraceQL is a query language designed for selecting traces.
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 is searched.&lt;/p&gt;
&lt;p&gt;To learn more about how to query by TraceQL, refer to the &lt;a href=&#34;/docs/tempo/latest/traceql/&#34;&gt;TraceQL documentation&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The TraceQL query editor in Grafana &lt;strong&gt;Explore&lt;/strong&gt; lets you search by trace ID and write TraceQL queries using autocomplete.&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;h2 id=&#34;before-you-begin&#34;&gt;Before you begin&lt;/h2&gt;
&lt;p&gt;This feature is automatically available in Grafana 10 (and newer) and Grafana Cloud.&lt;/p&gt;
&lt;p&gt;To use the TraceQL query editor in self-hosted Grafana 9.3.2 and older, you need to &lt;a href=&#34;/docs/grafana/latest/setup-grafana/configure-grafana/feature-toggles/&#34;&gt;enable the &lt;code&gt;traceqlEditor&lt;/code&gt; feature toggle&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&#34;streaming-and-grpc&#34;&gt;Streaming and gRPC&lt;/h3&gt;
&lt;p&gt;If you&amp;rsquo;re trying to query a self-managed Grafana Tempo or Grafana Enterprise Traces database with a gateway, such as nginx, in front of it from your hosted Grafana, that gateway (for example, nginx) must allow gRPC connections.
If it doesn&amp;rsquo;t, streaming won&amp;rsquo;t work and queries will fail to return results.&lt;/p&gt;
&lt;p&gt;If you can&amp;rsquo;t configure your gateway to allow gRPC, deactivate streaming in your hosted Grafana.
In Grafana 11.2 and newer, you can deactivate the &lt;strong&gt;Streaming&lt;/strong&gt; option in your Tempo data source settings from &lt;strong&gt;Connections&lt;/strong&gt; &amp;gt; &lt;strong&gt;Data sources&lt;/strong&gt; in the Grafana main menu.
You can also open a support escalation to request streaming query results be disabled in your hosted Grafana.&lt;/p&gt;
&lt;h2 id=&#34;write-traceql-queries-using-the-query-editor&#34;&gt;Write TraceQL queries using the query editor&lt;/h2&gt;
&lt;p&gt;The Tempo data source’s TraceQL query editor helps you query and display traces from Tempo in &lt;strong&gt;Explore&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;To access the query editor, follow these steps:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Sign into Grafana or Grafana Cloud.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Select &lt;strong&gt;Explore&lt;/strong&gt; from the main menu.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Select a Tempo data source.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Select the &lt;strong&gt;TraceQL&lt;/strong&gt; tab.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Start your query on the text line by entering &lt;code&gt;{&lt;/code&gt;. For help with TraceQL syntax, refer to the &lt;a href=&#34;/docs/tempo/latest/traceql/#construct-a-traceql-query&#34;&gt;Construct a TraceQL query documentation&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Optional: Select &lt;strong&gt;Copy query from Search&lt;/strong&gt; to transfer a builder query to the editor.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Optional: Use the &lt;strong&gt;Time picker&lt;/strong&gt; drop-down list to change the time and range for the query (refer to the &lt;a href=&#34;/docs/grafana/latest/dashboards/use-dashboards/#set-dashboard-time-range&#34;&gt;documentation for instructions&lt;/a&gt;).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Once you&amp;rsquo;ve finished your query, select &lt;strong&gt;Run query&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&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-ed-example-v11-a.png&#34;
  alt=&#34;Query editor showing span results&#34; width=&#34;1367&#34;
     height=&#34;908&#34;/&gt;&lt;/p&gt;
&lt;p&gt;This video provides an example of creating a TraceQL query using the custom tag grouping.&lt;/p&gt;
&lt;iframe width=&#34;560&#34; height=&#34;315&#34; src=&#39;https://www.youtube.com/embed/fraepWra00Y&#39; title=&#34;YouTube video player&#34; frameborder=&#34;0&#34; allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; allowfullscreen&gt;&lt;/iframe&gt;
&lt;h2 id=&#34;query-by-traceid&#34;&gt;Query by TraceID&lt;/h2&gt;
&lt;p&gt;To query a particular trace by its trace ID:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;From the menu, choose &lt;strong&gt;Explore&lt;/strong&gt;, select the desired Tempo data source, and navigate to the &lt;strong&gt;TraceQL&lt;/strong&gt; tab.&lt;/li&gt;
&lt;li&gt;Enter the trace ID into the query field. For example: &lt;code&gt;41928b92edf1cdbe0ba6594baee5ae9&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Run query&lt;/strong&gt; or use the keyboard shortcut Shift &#43; Enter.&lt;/li&gt;
&lt;/ol&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-trace-id-v11.png&#34;
  alt=&#34;Search for a trace ID using the TraceQL query editor&#34; width=&#34;1022&#34;
     height=&#34;693&#34;/&gt;&lt;/p&gt;
&lt;h2 id=&#34;use-autocomplete-to-write-queries&#34;&gt;Use autocomplete to write queries&lt;/h2&gt;
&lt;p&gt;You can use the query editor’s autocomplete suggestions to write queries.
The editor detects spansets to provide relevant autocomplete options.
It uses regular expressions (regex) to detect where it&amp;rsquo;s inside a spanset and provide attribute names, scopes, intrinsic names, logic operators, or attribute values from the Tempo API, depending on what&amp;rsquo;s expected for the current situation.&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-editor-autocomplete.png&#34;
  alt=&#34;Query editor showing the auto-complete feature&#34; width=&#34;1014&#34;
     height=&#34;290&#34;/&gt;&lt;/p&gt;
&lt;h3 id=&#34;anchored-regular-expressions&#34;&gt;Anchored regular expressions&lt;/h3&gt;
&lt;p&gt;Regular expressions are anchored at both ends.
This anchoring makes the queries faster and matches the behavior of PromQL, where regular expressions are also fully anchored.&lt;/p&gt;
&lt;p&gt;An unanchored query, such as:
&lt;code&gt;{ span.foo =~ &amp;quot;bar&amp;quot; }&lt;/code&gt;
is now treated as:
&lt;code&gt;{ span.foo =~ &amp;quot;^bar$&amp;quot; }&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;If you use TraceQL with regular expressions in your Grafana dashboards and you want the unanchored behavior, update the queries to use the unanchored version, such as &lt;code&gt;{ span.foo =~ &amp;quot;.*bar.*&amp;quot;}&lt;/code&gt;.&lt;/p&gt;
&lt;h3 id=&#34;create-a-query-with-autocomplete&#34;&gt;Create a query with autocomplete&lt;/h3&gt;
&lt;p&gt;To create a query using autocomplete, follow these steps:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;From the menu, choose &lt;strong&gt;Explore&lt;/strong&gt;, select the desired Tempo data source, and navigate to the &lt;strong&gt;TraceQL&lt;/strong&gt; tab.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Enter your query. As you type your query, autocomplete suggestions appear as a drop-down. Each letter you enter refines the autocomplete options to match.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Use your mouse or arrow keys to select any option you wish. When the desired option is highlighted, press Tab on your keyboard to add the selection to your query.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Once your query is complete, select &lt;strong&gt;Run query&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;view-query-results&#34;&gt;View query results&lt;/h2&gt;
&lt;p&gt;Query results appear in a table, such as &lt;strong&gt;Table - Traces&lt;/strong&gt;, under the query editor.
Each span (and the trace it belongs to) matching the query conditions is returned by the query.
If there are no filter conditions, all spans are matching and thus returned with their associated traces.&lt;/p&gt;
&lt;p&gt;A 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-v11.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 with the Trace.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Selecting the trace ID from the returned results opens a trace diagram.
Selecting a span from the returned results opens a trace diagram and reveals the relevant span in the trace diagram.&lt;/p&gt;
&lt;p&gt;For more information on span details, refer to &lt;a href=&#34;/docs/grafana/latest/explore/trace-integration/#span-details&#34;&gt;Traces in Explore&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-span-details-v11.png&#34;
  alt=&#34;Selecting a trace ID or a span to view span details&#34; width=&#34;1481&#34;
     height=&#34;1068&#34;/&gt;&lt;/p&gt;
&lt;p&gt;Querying spansets with a large number of spans can negatively impact performance.
You can use the &lt;strong&gt;Span Limit&lt;/strong&gt; field in &lt;strong&gt;Options&lt;/strong&gt; section of the TraceQL query editor.
This field sets the maximum number of spans to return for each span set.
By default, the maximum value that you can set for the &lt;strong&gt;Span Limit&lt;/strong&gt; value (or the spss query) is 100.
In Tempo configuration, this value is controlled by the &lt;code&gt;max_spans_per_span_set&lt;/code&gt; parameter and can be modified by your Tempo administrator.
Entering a value higher than the default results in an error.&lt;/p&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;Changing the value of &lt;code&gt;max_spans_per_span_set&lt;/code&gt; isn&amp;rsquo;t supported in Grafana Cloud.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;h3 id=&#34;focus-on-traces-or-spans&#34;&gt;Focus on traces or spans&lt;/h3&gt;
&lt;p&gt;Under &lt;strong&gt;Options&lt;/strong&gt;, you can choose to display the table as &lt;strong&gt;Traces&lt;/strong&gt; or &lt;strong&gt;Spans&lt;/strong&gt; focused.&lt;/p&gt;
&lt;p&gt;When the &lt;strong&gt;Table Type&lt;/strong&gt; option is set to &lt;strong&gt;Spans&lt;/strong&gt;, the traces and spansets are flattened into a list of spans.
The trace service and trace name are added to the row of each span to add context.&lt;/p&gt;
&lt;p&gt;Using the &lt;strong&gt;Spans&lt;/strong&gt; option makes it easier access the spans to apply transformations and plot them in dashboards.&lt;/p&gt;
&lt;h3 id=&#34;stream-results&#34;&gt;Stream results&lt;/h3&gt;
&lt;p&gt;The Tempo data source supports streaming responses to TraceQL queries so you can see partial query results as they come in without waiting for the whole query to finish.&lt;/p&gt;
&lt;p&gt;Streaming is available for both the &lt;strong&gt;Search&lt;/strong&gt; and &lt;strong&gt;TraceQL&lt;/strong&gt; query types, and you&amp;rsquo;ll get immediate visibility of incoming traces on the results table.&lt;/p&gt;
&lt;p&gt;To learn how to activate streaming, refer to 
    &lt;a href=&#34;/docs/grafana/v13.0/datasources/tempo/configure-tempo-data-source/#streaming&#34;&gt;Streaming&lt;/a&gt; in the Tempo data source documentation.&lt;/p&gt;
&lt;div class=&#34;&#34;&gt;
  &lt;figure class=&#34;p-0 m-0 &#34;&gt;
    &lt;video 
      width=&#34;&#34; 
      controls
      muted
      playsinline
      
        class=&#34;lazyload&#34;
        preload=&#34;none&#34;
        
             
      
      
        loop
      
      src=&#34;/media/docs/grafana/data-sources/tempo-streaming-v2.mp4&#34;
      type=&#34;video/mp4&#34;
    &gt;
    &lt;/video&gt;&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;

        
&lt;h2 id=&#34;next-steps&#34;&gt;Next steps&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;../traceql-query-examples/&#34;&gt;TraceQL query examples&lt;/a&gt;: Copy-paste query examples for common use cases&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;../traceql-search/&#34;&gt;Search traces using the query builder&lt;/a&gt;: Build queries visually&lt;/li&gt;
&lt;li&gt;
    &lt;a href=&#34;/docs/tempo/latest/traceql/construct-traceql-queries/&#34;&gt;Construct a TraceQL query&lt;/a&gt;: Full TraceQL syntax reference&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;../../service-graph/&#34;&gt;Service Graph and Service Graph view&lt;/a&gt;: Visualize service dependencies&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;../../span-filters/&#34;&gt;Span filters&lt;/a&gt;: Refine results in the trace detail view&lt;/li&gt;
&lt;/ul&gt;
]]></content><description>&lt;h1 id="write-traceql-queries-with-the-editor">Write TraceQL queries with the editor&lt;/h1>
&lt;p>Use the &lt;strong>TraceQL&lt;/strong> editor when you need structural queries across parent and child spans, aggregations, or other features that the &lt;a href="../traceql-search/">Search query builder&lt;/a> doesn&amp;rsquo;t support.
TraceQL queries follow the pattern &lt;code>{ conditions } | pipeline&lt;/code>.
Refer to
&lt;a href="/docs/tempo/latest/traceql/construct-traceql-queries/">Construct a TraceQL query&lt;/a> for the full syntax.&lt;/p></description></item><item><title>TraceQL query examples</title><link>https://grafana.com/docs/grafana/v13.0/datasources/tempo/query-editor/traceql-query-examples/</link><pubDate>Tue, 14 Apr 2026 14:59:56 +0000</pubDate><guid>https://grafana.com/docs/grafana/v13.0/datasources/tempo/query-editor/traceql-query-examples/</guid><content><![CDATA[&lt;h1 id=&#34;traceql-query-examples&#34;&gt;TraceQL query examples&lt;/h1&gt;
&lt;p&gt;Use these TraceQL queries in Grafana &lt;strong&gt;Explore&lt;/strong&gt; with a Tempo data source.
Adjust service names, routes, and attribute values to match your environment.&lt;/p&gt;
&lt;p&gt;These examples use &lt;a href=&#34;https://opentelemetry.io/docs/specs/semconv/general/trace/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;OpenTelemetry semantic conventions&lt;/a&gt;.
If your instrumentation uses different attribute names, substitute them in the queries.&lt;/p&gt;
&lt;p&gt;For the full TraceQL syntax, refer to 
    &lt;a href=&#34;/docs/tempo/latest/traceql/construct-traceql-queries/&#34;&gt;Construct a TraceQL query&lt;/a&gt;.
For an extended recipe collection, refer to the &lt;a href=&#34;/docs/grafana-cloud/send-data/traces/traces-query-editor/traceql-cookbook/&#34;&gt;TraceQL cookbook for Grafana Cloud Traces&lt;/a&gt;.&lt;/p&gt;


&lt;div class=&#34;admonition admonition-tip&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Tip&lt;/p&gt;&lt;p&gt;If a query returns no results, widen the time range and confirm the correct Tempo data source is selected.
Prefer trace-level intrinsic fields like &lt;code&gt;trace:duration&lt;/code&gt; and &lt;code&gt;trace:rootService&lt;/code&gt; for faster queries.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;h2 id=&#34;find-error-spans&#34;&gt;Find error spans&lt;/h2&gt;
&lt;p&gt;Filter by error status or HTTP error codes:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;traceql&lt;/span&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 class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-traceql&#34;&gt;{ status = error }&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;traceql&lt;/span&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 class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-traceql&#34;&gt;{ span.http.status_code &amp;gt;= 500 }&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;traceql&lt;/span&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 class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-traceql&#34;&gt;{ span.http.status_code &amp;gt; 399 }&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;find-slow-requests&#34;&gt;Find slow requests&lt;/h2&gt;
&lt;p&gt;Filter by span duration.
Common thresholds are 1 second and 5 seconds:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;traceql&lt;/span&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 class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-traceql&#34;&gt;{ duration &amp;gt; 1s }&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;traceql&lt;/span&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 class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-traceql&#34;&gt;{ duration &amp;gt; 5s }&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Filter a specific endpoint by duration:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;traceql&lt;/span&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 class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-traceql&#34;&gt;{ span.http.url = &amp;#34;/api/checkout&amp;#34; &amp;amp;&amp;amp; duration &amp;gt; 2s }&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;find-exceptions-by-type&#34;&gt;Find exceptions by type&lt;/h2&gt;
&lt;p&gt;Query exception events recorded on spans.
Exception data uses the &lt;code&gt;event&lt;/code&gt; scope because OpenTelemetry records exceptions as span events:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;traceql&lt;/span&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 class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-traceql&#34;&gt;{ event.exception.message =~ &amp;#34;context cancelled&amp;#34; }&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;traceql&lt;/span&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 class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-traceql&#34;&gt;{ event.exception.type = &amp;#34;NotFoundException&amp;#34; }&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Find error spans that have an exception message:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;traceql&lt;/span&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 class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-traceql&#34;&gt;{ status = error &amp;amp;&amp;amp; event.exception.message != &amp;#34;&amp;#34; }&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;filter-by-service&#34;&gt;Filter by service&lt;/h2&gt;
&lt;p&gt;Select spans from a specific service or match services by pattern.
You can use the 
    &lt;a href=&#34;/docs/grafana/v13.0/datasources/tempo/service-graph/&#34;&gt;Service Graph view&lt;/a&gt; to identify which services have high error rates or latency, then query those services with TraceQL.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;traceql&lt;/span&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 class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-traceql&#34;&gt;{ resource.service.name = &amp;#34;checkout&amp;#34; }&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;traceql&lt;/span&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 class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-traceql&#34;&gt;{ resource.service.name =~ &amp;#34;payment.*&amp;#34; &amp;amp;&amp;amp; status = error }&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;find-errors-and-slow-spans-together&#34;&gt;Find errors and slow spans together&lt;/h2&gt;
&lt;p&gt;Combine error status and duration filters to identify likely root causes:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;traceql&lt;/span&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 class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-traceql&#34;&gt;{ resource.service.name = &amp;#34;api&amp;#34; &amp;amp;&amp;amp; status = error &amp;amp;&amp;amp; duration &amp;gt; 1s }&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;analyze-service-dependencies&#34;&gt;Analyze service dependencies&lt;/h2&gt;
&lt;p&gt;Find errors on a specific API path:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;traceql&lt;/span&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 class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-traceql&#34;&gt;{ span.http.url =~ &amp;#34;.*/api/.*&amp;#34; &amp;amp;&amp;amp; span.http.status_code &amp;gt;= 500 }&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Use the descendant operator (&lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt;) to find traces where a frontend service calls a downstream service that errors:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;traceql&lt;/span&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 class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-traceql&#34;&gt;{ resource.service.name = &amp;#34;frontend&amp;#34; } &amp;gt;&amp;gt; { resource.service.name = &amp;#34;database&amp;#34; &amp;amp;&amp;amp; status = error }&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;query-rate-and-count-metrics&#34;&gt;Query rate and count metrics&lt;/h2&gt;
&lt;p&gt;Run these in &lt;strong&gt;Metrics&lt;/strong&gt; mode in Explore.
TraceQL metrics queries have a default 24-hour time-range limit:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;traceql&lt;/span&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 class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-traceql&#34;&gt;{ } | rate()&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;traceql&lt;/span&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 class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-traceql&#34;&gt;{ status = error } | rate()&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;traceql&lt;/span&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 class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-traceql&#34;&gt;{ resource.service.name = &amp;#34;api&amp;#34; } | count_over_time()&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;traceql&lt;/span&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 class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-traceql&#34;&gt;{ duration &amp;gt; 1s } | rate()&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;filter-by-region-or-environment&#34;&gt;Filter by region or environment&lt;/h2&gt;
&lt;p&gt;Narrow results to a specific cloud region or deployment environment:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;traceql&lt;/span&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 class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-traceql&#34;&gt;{ resource.cloud.region = &amp;#34;us-east-1&amp;#34; &amp;amp;&amp;amp; status = error }&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;traceql&lt;/span&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 class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-traceql&#34;&gt;{ resource.deployment.environment = &amp;#34;production&amp;#34; &amp;amp;&amp;amp; duration &amp;gt; 2s }&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;use-dashboard-variables&#34;&gt;Use dashboard variables&lt;/h2&gt;
&lt;p&gt;Replace hard-coded values with 
    &lt;a href=&#34;/docs/grafana/v13.0/dashboards/variables/&#34;&gt;dashboard variables&lt;/a&gt; when using these queries in panels.
For example, using a &lt;code&gt;$service&lt;/code&gt; variable:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;traceql&lt;/span&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 class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-traceql&#34;&gt;{ resource.service.name = &amp;#34;$service&amp;#34; &amp;amp;&amp;amp; status = error }&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;more-resources&#34;&gt;More resources&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;/docs/grafana-cloud/send-data/traces/traces-query-editor/traceql-cookbook/&#34;&gt;TraceQL cookbook for Grafana Cloud Traces&lt;/a&gt; - Extended recipe collection with additional examples&lt;/li&gt;
&lt;li&gt;
    &lt;a href=&#34;/docs/tempo/latest/traceql/construct-traceql-queries/&#34;&gt;Construct a TraceQL query&lt;/a&gt; - Full TraceQL syntax, scopes, and operators&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;_index.md&#34;&gt;Query tracing data&lt;/a&gt; - Query editor modes and options&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;../service-graph/&#34;&gt;Service Graph and Service Graph view&lt;/a&gt; - Visualize service dependencies&lt;/li&gt;
&lt;/ul&gt;
]]></content><description>&lt;h1 id="traceql-query-examples">TraceQL query examples&lt;/h1>
&lt;p>Use these TraceQL queries in Grafana &lt;strong>Explore&lt;/strong> with a Tempo data source.
Adjust service names, routes, and attribute values to match your environment.&lt;/p></description></item></channel></rss>