<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>TraceQL metrics queries on Grafana Labs</title><link>https://grafana.com/docs/enterprise-traces/v2.8.x/traceql/metrics-queries/</link><description>Recent content in TraceQL metrics queries on Grafana Labs</description><generator>Hugo -- gohugo.io</generator><language>en</language><atom:link href="/docs/enterprise-traces/v2.8.x/traceql/metrics-queries/index.xml" rel="self" type="application/rss+xml"/><item><title>Solve problems with trace metrics queries</title><link>https://grafana.com/docs/enterprise-traces/v2.8.x/traceql/metrics-queries/solve-problems-metrics-queries/</link><pubDate>Mon, 16 Jun 2025 14:41:50 +0000</pubDate><guid>https://grafana.com/docs/enterprise-traces/v2.8.x/traceql/metrics-queries/solve-problems-metrics-queries/</guid><content><![CDATA[&lt;h1 id=&#34;solve-problems-with-trace-metrics-queries&#34;&gt;Solve problems with trace metrics queries&lt;/h1&gt;
&lt;!-- Using a custom admonition because no feature flag is required. --&gt;


&lt;div data-shared=&#34;traceql-metrics-admonition.md&#34;&gt;
            &lt;!-- Using a custom admonition because no feature flag is required. --&gt;


&lt;div class=&#34;admonition admonition-caution&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Caution&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.
Contact Grafana Support to enable this feature in Grafana Cloud.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;/div&gt;

        
&lt;p&gt;You can query data generated by TraceQL metrics in a similar way that you would query results stored in Prometheus, Grafana Mimir, or other Prometheus-compatible Time-Series-Database (TSDB).
TraceQL metrics queries allows you to calculate metrics on trace span data on-the-fly with Tempo (your tracing database), without requiring a time-series-database like Prometheus.&lt;/p&gt;
&lt;p&gt;This page provides an example of how you can investigate the rate of incoming requests using both PromQL and TraceQL.&lt;/p&gt;
&lt;h2 id=&#34;red-metrics-and-queries&#34;&gt;RED metrics and queries&lt;/h2&gt;
&lt;p&gt;The Tempo metrics-generator emits metrics with pre-configured labels for Rate, Error, and Duration (RED) metrics and service graph edges.
Generated metric labels vary, but always include the service name.
For example, in service graph metrics, as a client or a server type, or both.
For more information, refer to the 
    &lt;a href=&#34;/docs/enterprise-traces/v2.8.x/metrics-generator/&#34;&gt;metrics-generator documentation&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;You can use these metrics to get an overview of application performance.
The metrics can be directly correlated to the trace spans that are available for querying.&lt;/p&gt;
&lt;p&gt;TraceQL metrics allow a user to query metrics from traces directly from Tempo instead of requiring the metrics-generator component and an accompanying TSDB.&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;TraceQL metrics are constrained to a 24-hour range window, and aren&amp;rsquo;t available as a Grafana Managed Alerts source.
For any metrics that you want to query over longer time ranges, use for alerting, or retain for more than 30 days, use the metrics-generator to store these metrics in Prometheus, Mimir, or other Prometheus-compatible TSDB and continue to use PromQL for querying.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;h2 id=&#34;investigate-the-rate-of-incoming-requests&#34;&gt;Investigate the rate of incoming requests&lt;/h2&gt;
&lt;p&gt;Let&amp;rsquo;s say that you want to know how many requests are being serviced both by your application, but also by each service that comprises your application.
This allows you to ensure that your application scales appropriately, can help with capacity planning, and can show you which services may be having problems and are taking up load in fail-over scenarios.
In PromQL, these values are calculated over counters that increase each time a service is called. These metrics provide the Rate (R) in RED.&lt;/p&gt;
&lt;p&gt;If you are familiar with PromQL, then you&amp;rsquo;re used to constructing queries.
You can create an equivalent queries in TraceQL.
Here&amp;rsquo;s the two queries for the different data sources (PromQL for Mimir and TraceQL for Tempo), shown side by side over a 6 hour time-range.&lt;/p&gt;
&lt;p&gt;&lt;img
  class=&#34;lazyload d-inline-block&#34;
  data-src=&#34;/media/docs/tempo/traceql/TraceQL-metrics-query-example-1.png&#34;
  alt=&#34;Equivalent PromQL and TraceQL queries&#34; width=&#34;1805&#34;
     height=&#34;812&#34;/&gt;&lt;/p&gt;
&lt;h3 id=&#34;how-the-query-looks-in-promql&#34;&gt;How the query looks in PromQL&lt;/h3&gt;
&lt;p&gt;The Tempo metrics-generator outputs a metric, &lt;code&gt;traces_spanmetrics_calls_total&lt;/code&gt;, a counter that increases each time a named span in a service is called.
RED data generated by the metrics-generator includes the service name and span kind.
You can use this to only show call counts when a service was called externally by filtering via the &lt;code&gt;SERVER&lt;/code&gt; span kind, thus showing the total number of times the service has been called.&lt;/p&gt;
&lt;p&gt;You can use the PromQL &lt;code&gt;rate()&lt;/code&gt; and &lt;code&gt;sum()&lt;/code&gt; functions to examine the counter and determine the per-second rate of calls occurring, summing them by each service.
In addition to only looking at spans of &lt;code&gt;kind=server&lt;/code&gt;, you can also focus on spans coming from a particular Kubernetes namespace (&lt;code&gt;ditl-demo-prod&lt;/code&gt;).&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;sum by (service_name)(rate(traces_spanmetrics_calls_total{service_namespace=&amp;#34;ditl-demo-prod&amp;#34;, span_kind=&amp;#34;SPAN_KIND_SERVER&amp;#34;}[2m]))&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;how-the-query-looks-in-traceql&#34;&gt;How the query looks in TraceQL&lt;/h3&gt;
&lt;p&gt;TraceQL metrics queries let you similarly examine a particular subset of your spans.
As in the example above, you can start by filtering down to spans that occur in a particular Kubernetes namespace (&lt;code&gt;ditl-demo-prod&lt;/code&gt;), and are of kind &lt;code&gt;SERVER&lt;/code&gt;.
That resulting set of spans is piped to the TraceQL &lt;code&gt;rate&lt;/code&gt; function, which then calculates the rate (in spans/sec) at which spans matches your filters are received.
By adding the &lt;code&gt;by (resource.service.name)&lt;/code&gt; term, the query returns spans per second rates per service, rather than an aggregate across all services.&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;{ resource.service.namespace=&amp;#34;ditl-demo-prod&amp;#34; &amp;amp;&amp;amp; kind=server } | rate() by (resource.service.name)&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
]]></content><description>&lt;h1 id="solve-problems-with-trace-metrics-queries">Solve problems with trace metrics queries&lt;/h1>
&lt;!-- Using a custom admonition because no feature flag is required. -->
&lt;div data-shared="traceql-metrics-admonition.md">
&lt;!-- Using a custom admonition because no feature flag is required. -->
&lt;div class="admonition admonition-caution">&lt;blockquote>&lt;p class="title text-uppercase">Caution&lt;/p></description></item><item><title>TraceQL metrics functions</title><link>https://grafana.com/docs/enterprise-traces/v2.8.x/traceql/metrics-queries/functions/</link><pubDate>Mon, 16 Jun 2025 14:41:50 +0000</pubDate><guid>https://grafana.com/docs/enterprise-traces/v2.8.x/traceql/metrics-queries/functions/</guid><content><![CDATA[&lt;h1 id=&#34;traceql-metrics-functions&#34;&gt;TraceQL metrics functions&lt;/h1&gt;
&lt;!-- Using a custom admonition because no feature flag is required. --&gt;


&lt;div data-shared=&#34;traceql-metrics-admonition.md&#34;&gt;
            &lt;!-- Using a custom admonition because no feature flag is required. --&gt;


&lt;div class=&#34;admonition admonition-caution&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Caution&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.
Contact Grafana Support to enable this feature in Grafana Cloud.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;/div&gt;

        
&lt;!-- If you add a new function to this page, make sure you also add it to the _index.md#functions section.--&gt;
&lt;p&gt;TraceQL supports &lt;code&gt;rate&lt;/code&gt;, &lt;code&gt;count_over_time&lt;/code&gt;, &lt;code&gt;sum_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; functions.&lt;/p&gt;
&lt;h2 id=&#34;available-functions&#34;&gt;Available functions&lt;/h2&gt;
&lt;p&gt;These functions can be added as an operator at the end of any TraceQL query.&lt;/p&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;code&gt;rate&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;Calculates the number of matching spans per second.&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;count_over_time&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;Counts the number of matching spans per time interval (refer to the 
    &lt;a href=&#34;/docs/enterprise-traces/v2.8.x/api_docs/&#34;&gt;
&lt;code&gt;step&lt;/code&gt; API parameter&lt;/a&gt;).&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;sum_over_time&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;Sums the value for the specified attribute across all matching spans per time interval (refer to the 
    &lt;a href=&#34;/docs/enterprise-traces/v2.8.x/api_docs/&#34;&gt;
&lt;code&gt;step&lt;/code&gt; API parameter&lt;/a&gt;).&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;min_over_time&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;Returns the minimum value for the specified attribute across all matching spans per time interval (refer to the 
    &lt;a href=&#34;/docs/enterprise-traces/v2.8.x/api_docs/#traceql-metrics&#34;&gt;
&lt;code&gt;step&lt;/code&gt; API parameter&lt;/a&gt;).&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;max_over_time&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;Returns the maximum value for the specified attribute across all matching spans per time interval (refer to the 
    &lt;a href=&#34;/docs/enterprise-traces/v2.8.x/api_docs/#traceql-metrics&#34;&gt;
&lt;code&gt;step&lt;/code&gt; API parameter&lt;/a&gt;).&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;avg_over_time&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;Returns the average value for the specified attribute across all matching spans per time interval (refer to the 
    &lt;a href=&#34;/docs/enterprise-traces/v2.8.x/api_docs/#traceql-metrics&#34;&gt;
&lt;code&gt;step&lt;/code&gt; API parameter&lt;/a&gt;).&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;quantile_over_time&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;The quantile of the values in the specified interval.&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;histogram_over_time&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;Evaluate frequency distribution over time. Example: &lt;code&gt;histogram_over_time(duration) by (span.foo)&lt;/code&gt;.&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;compare&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;Used to split the stream of spans into two groups: a selection and a baseline. The function returns time-series for
all attributes found on the spans to highlight the differences between the two groups.&lt;/dd&gt;
&lt;/dl&gt;
&lt;h2 id=&#34;the-rate-function&#34;&gt;The &lt;code&gt;rate&lt;/code&gt; function&lt;/h2&gt;
&lt;p&gt;The &lt;code&gt;rate&lt;/code&gt; function calculates the number of matching spans per second that match the given span selectors.&lt;/p&gt;
&lt;h3 id=&#34;parameters&#34;&gt;Parameters&lt;/h3&gt;
&lt;p&gt;None.&lt;/p&gt;
&lt;h3 id=&#34;examples&#34;&gt;Examples&lt;/h3&gt;
&lt;p&gt;The following query shows the rate of errors by service and span name.
This is a TraceQL specific way of gathering rate metrics that would otherwise be generated by the span metrics
processor.&lt;/p&gt;
&lt;p&gt;For example, this query:&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;{ status = error } | rate() by (resource.service.name, name)&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Is an equivalent to using span-generated metrics and running the query.&lt;/p&gt;
&lt;p&gt;This example calculates the rate of the erroring spans coming from the service &lt;code&gt;foo&lt;/code&gt;.
Rate is a &lt;code&gt;spans/sec&lt;/code&gt; quantity.&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;{ resource.service.name = &amp;#34;foo&amp;#34; &amp;amp;&amp;amp; status = error } | rate()&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Combined with the &lt;code&gt;by()&lt;/code&gt; operator, this can be even more powerful.&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;{ resource.service.name = &amp;#34;foo&amp;#34; &amp;amp;&amp;amp; status = error } | rate() by (span.http.route)&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;This example still rates the erroring spans in the service &lt;code&gt;foo&lt;/code&gt; but the metrics are broken
down by HTTP route.
This might let you determine that &lt;code&gt;/api/sad&lt;/code&gt; had a higher rate of erroring
spans than &lt;code&gt;/api/happy&lt;/code&gt;, for example.&lt;/p&gt;
&lt;h2 id=&#34;the-count_over_time-function&#34;&gt;The &lt;code&gt;count_over_time&lt;/code&gt; function&lt;/h2&gt;
&lt;p&gt;The &lt;code&gt;count_over_time()&lt;/code&gt; function counts the number of matching spans per time interval.
The time interval that the count is computed over is set by the &lt;code&gt;step&lt;/code&gt; parameter.&lt;/p&gt;
&lt;h3 id=&#34;the-step-parameter&#34;&gt;The &lt;code&gt;step&lt;/code&gt; parameter&lt;/h3&gt;
&lt;p&gt;Ths &lt;code&gt;step&lt;/code&gt; parameter defines the granularity of the returned time-series.
For example, &lt;code&gt;step=15s&lt;/code&gt; returns a data point every 15s within the time range.
By default, &lt;code&gt;step&lt;/code&gt; automatically chooses a dynamic value based on the query start time and end time.&lt;/p&gt;
&lt;p&gt;Any value used for &lt;code&gt;step&lt;/code&gt; needs to include a duration value, such as &lt;code&gt;30s&lt;/code&gt; for &lt;code&gt;s&lt;/code&gt;econds or &lt;code&gt;1m&lt;/code&gt; for &lt;code&gt;m&lt;/code&gt;inutes.&lt;/p&gt;
&lt;p&gt;You can configure this parameter using Grafana Explore or using the Tempo API.
Refer to the 
    &lt;a href=&#34;/docs/enterprise-traces/v2.8.x/api_docs/#traceql-metrics&#34;&gt;&lt;code&gt;step&lt;/code&gt; API parameter&lt;/a&gt; for information about using the API.&lt;/p&gt;
&lt;p&gt;To check or change the &lt;code&gt;step&lt;/code&gt; value using Grafana Explore:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Select your Tempo data source.&lt;/li&gt;
&lt;li&gt;Select either the &lt;strong&gt;Search&lt;/strong&gt; or &lt;strong&gt;TraceQL&lt;/strong&gt; query type tab.&lt;/li&gt;
&lt;li&gt;Expand the &lt;strong&gt;Metrics options&lt;/strong&gt; to view the &lt;strong&gt;Step&lt;/strong&gt; value.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;img
  class=&#34;lazyload d-inline-block&#34;
  data-src=&#34;/media/docs/tempo/tempo-ds-query-metrics-options-step.png&#34;
  alt=&#34;The Step value in the Metrics options in Grafana Explore&#34; width=&#34;1268&#34;
     height=&#34;392&#34;/&gt;&lt;/p&gt;
&lt;h3 id=&#34;example&#34;&gt;Example&lt;/h3&gt;
&lt;p&gt;This example counts the number of spans with name &lt;code&gt;&amp;quot;GET /:endpoint&amp;quot;&lt;/code&gt; broken down by status code. You might see that
there are 10 &lt;code&gt;&amp;quot;GET /:endpoint&amp;quot;&lt;/code&gt; spans with status code 200 and 15 &lt;code&gt;&amp;quot;GET /:endpoint&amp;quot;&lt;/code&gt; spans with status code 400.&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;{ name = &amp;#34;GET /:endpoint&amp;#34; } | count_over_time() by (span.http.status_code)&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;the-sum_over_time-min_over_time-max_over_time-and-avg_over_time--functions&#34;&gt;The &lt;code&gt;sum_over_time&lt;/code&gt;, &lt;code&gt;min_over_time&lt;/code&gt;, &lt;code&gt;max_over_time&lt;/code&gt;, and &lt;code&gt;avg_over_time&lt;/code&gt;  functions&lt;/h2&gt;
&lt;p&gt;The &lt;code&gt;sum_over_time()&lt;/code&gt; lets you aggregate numerical values by computing the sum value of them.
The time interval that the sum is computed over is set by the &lt;code&gt;step&lt;/code&gt; parameter.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;min_over_time()&lt;/code&gt; function lets you aggregate numerical attributes by calculating their minimum value.
For example, you could choose to calculate the minimum duration of a group of spans, or you could choose to calculate
the minimum value of a custom attribute you&amp;rsquo;ve attached to your spans, like &lt;code&gt;span.shopping.cart.entries&lt;/code&gt;.
The time interval that the minimum is computed over is set by the &lt;code&gt;step&lt;/code&gt; parameter.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;max_over_time()&lt;/code&gt; lets you aggregate numerical values by computing the maximum value of them, such as the all
important span duration.
The time interval that the maximum is computed over is set by the &lt;code&gt;step&lt;/code&gt; parameter.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;avg_over_time()&lt;/code&gt; function lets you aggregate numerical values by computing the maximum value of them, such as the
all important span duration.
The time interval that the maximum is computer over is set by the &lt;code&gt;step&lt;/code&gt; parameter.&lt;/p&gt;
&lt;p&gt;For more information, refer to the 
    &lt;a href=&#34;/docs/enterprise-traces/v2.8.x/api_docs/#traceql-metrics&#34;&gt;
&lt;code&gt;step&lt;/code&gt; API parameter&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&#34;parameters-1&#34;&gt;Parameters&lt;/h3&gt;
&lt;p&gt;Numerical field that you want to calculate the minimum, maximum, or average of.&lt;/p&gt;
&lt;h3 id=&#34;examples-1&#34;&gt;Examples&lt;/h3&gt;
&lt;p&gt;This example computes the minimum duration for each &lt;code&gt;http.target&lt;/code&gt; of all spans named &lt;code&gt;&amp;quot;GET /:endpoint&amp;quot;&lt;/code&gt;.
Any numerical attribute on the span is fair game.&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;{ name = &amp;#34;GET /:endpoint&amp;#34; } | min_over_time(duration) by (span.http.target)&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;This example computes the minimum status code value of all spans named &lt;code&gt;&amp;quot;GET /:endpoint&amp;quot;&lt;/code&gt;.&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;{ name = &amp;#34;GET /:endpoint&amp;#34; } | min_over_time(span.http.status_code)&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;This example computes the maximum duration for each &lt;code&gt;http.target&lt;/code&gt; of all spans named &lt;code&gt;&amp;quot;GET /:endpoint&amp;quot;&lt;/code&gt;.&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;{ name = &amp;#34;GET /:endpoint&amp;#34; } | max_over_time(duration) by (span.http.target)&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&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;{ name = &amp;#34;GET /:endpoint&amp;#34; } | max_over_time(span.http.response.size)&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;This example computes the average duration for each &lt;code&gt;http.status_code&lt;/code&gt; of all spans named &lt;code&gt;&amp;quot;GET /:endpoint&amp;quot;&lt;/code&gt;.&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;{ name = &amp;#34;GET /:endpoint&amp;#34; } | avg_over_time(duration) by (span.http.status_code)&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&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;{ name = &amp;#34;GET /:endpoint&amp;#34; } | avg_over_time(span.http.response.size)&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;the-quantile_over_time-and-histogram_over_time-functions&#34;&gt;The &lt;code&gt;quantile_over_time&lt;/code&gt; and &lt;code&gt;histogram_over_time&lt;/code&gt; functions&lt;/h2&gt;
&lt;p&gt;The &lt;code&gt;quantile_over_time()&lt;/code&gt; and &lt;code&gt;histogram_over_time()&lt;/code&gt; functions let you aggregate numerical values, such as the all
important span duration.
You can specify multiple quantiles in the same query.&lt;/p&gt;
&lt;p&gt;The example below computes the 99th, 90th, and 50th percentile of the duration attribute on all spans with name
&lt;code&gt;GET /:endpoint&lt;/code&gt;.&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;{ name = &amp;#34;GET /:endpoint&amp;#34; } | quantile_over_time(duration, .99, .9, .5)&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;You can group by any span or resource attribute.&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;{ name = &amp;#34;GET /:endpoint&amp;#34; } | quantile_over_time(duration, .99) by (span.http.target)&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Quantiles aren&amp;rsquo;t limited to span duration.
Any numerical attribute on the span is fair game.
To demonstrate this flexibility, consider this nonsensical quantile on &lt;code&gt;span.http.status_code&lt;/code&gt;:&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;{ name = &amp;#34;GET /:endpoint&amp;#34; } | quantile_over_time(span.http.status_code, .99, .9, .5)&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;This computes the 99th, 90th, and 50th percentile of the values of the &lt;code&gt;status_code&lt;/code&gt; attribute for all spans named
&lt;code&gt;GET /:endpoint&lt;/code&gt;.
This is unlikely to tell you anything useful (what does a median status code of &lt;code&gt;347&lt;/code&gt; mean?), but it works.&lt;/p&gt;
&lt;p&gt;As a further example, imagine a custom attribute like &lt;code&gt;span.temperature&lt;/code&gt;.
You could use a similar query to know what the 50th percentile and 95th percentile temperatures were across all your
spans.&lt;/p&gt;
&lt;h2 id=&#34;topk-and-bottomk-functions&#34;&gt;&lt;code&gt;topk&lt;/code&gt; and &lt;code&gt;bottomk&lt;/code&gt; functions&lt;/h2&gt;
&lt;p&gt;TraceQL supports the &lt;code&gt;topk&lt;/code&gt; and &lt;code&gt;bottomk&lt;/code&gt; functions that let you aggregate and process TraceQL metrics.
These functions are similar to their equivalent PromQL functions. For example:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;{ } | rate() by(resource.service.name) | bottomk(5)&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;{ } | rate() by(resource.service.name) | topk(5)&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;When a query response is larger than the maximum, you can use these functions to return only the specified number
from 1 through &lt;code&gt;k&lt;/code&gt; of the number of the top or bottom results.&lt;/p&gt;
&lt;p&gt;For 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;`{ resource.service.name = &amp;#34;foo&amp;#34; } | rate() by (span.http.url)  | topk(10)`&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The first part, &lt;code&gt;{ resource.service.name = &amp;quot;foo&amp;quot; }&lt;/code&gt;, takes all spans in the service &lt;code&gt;foo&lt;/code&gt;.
The spans are rated by the URL, for example, the most active endpoints on a service.&lt;/p&gt;
&lt;p&gt;Adding &lt;code&gt;topk(10)&lt;/code&gt; returns the top 10 most common instead of the entire list.
Conversely, you can use &lt;code&gt;bottomk(10)&lt;/code&gt; to see the least most used ones.&lt;/p&gt;
&lt;p&gt;In TraceQL, &lt;code&gt;topk&lt;/code&gt; and &lt;code&gt;bottomk&lt;/code&gt; work similar to how they function in PromQL. Both &lt;code&gt;topk&lt;/code&gt; and &lt;code&gt;bottomk&lt;/code&gt;
are evaluated at each data point.&lt;/p&gt;
&lt;p&gt;If you do a &lt;code&gt;topk&lt;/code&gt; of 10, you might get a 20 series. For example, on this data point, the top 10 are &lt;code&gt;A&lt;/code&gt; through &lt;code&gt;J&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;On the next data point, &lt;code&gt;A&lt;/code&gt; through &lt;code&gt;I&lt;/code&gt; might still be the top 9, but &lt;code&gt;J&lt;/code&gt; might have fallen off for &lt;code&gt;K&lt;/code&gt;.
Because it&amp;rsquo;s evaluated at each data point, you&amp;rsquo;ll get the top series for each data point.&lt;/p&gt;
&lt;h2 id=&#34;the-compare-function&#34;&gt;The &lt;code&gt;compare&lt;/code&gt; function&lt;/h2&gt;
&lt;p&gt;The &lt;code&gt;compare&lt;/code&gt; function is used to split a set of spans into two groups: a selection and a baseline.
It returns time-series for all attributes found on the spans to highlight the differences between the two groups.&lt;/p&gt;
&lt;p&gt;This powerful function is best understood by using the 
    &lt;a href=&#34;/docs/grafana/next/explore/simplified-exploration/traces/investigate/#comparison&#34;&gt;&lt;strong&gt;Comparison&lt;/strong&gt; tab in Traces Drilldown&lt;/a&gt;.
You can also under this function by looking at example outputs below.&lt;/p&gt;
&lt;p&gt;The function is used like other metrics functions: when it&amp;rsquo;s placed after any trace query, it converts the query into a
metrics query:
&lt;code&gt;...any spanset pipeline... | compare({subset filters}, &amp;lt;topN&amp;gt;, &amp;lt;start timestamp&amp;gt;, &amp;lt;end timestamp&amp;gt;)&lt;/code&gt;&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;{ resource.service.name=&amp;#34;a&amp;#34; &amp;amp;&amp;amp; span.http.path=&amp;#34;/myapi&amp;#34; } | compare({status=error})&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;This function is generally run as an instant query.
An instant query gives a single value at the end of the selected time range.
&lt;a href=&#34;https://prometheus.io/docs/prometheus/latest/querying/api/#instant-queries&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Instant queries&lt;/a&gt; are quicker to execute and
it often easier to understand their results
The returns may exceed gRPC payloads when run as a range query.&lt;/p&gt;
&lt;h3 id=&#34;parameters-2&#34;&gt;Parameters&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;compare&lt;/code&gt; function has four parameters:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Required. The first parameter is a spanset filter for choosing the subset of spans. This filter is executed against
the incoming spans. If it matches, then the span is considered to be part of the selection. Otherwise, it is part of
the baseline. Common filters are expected to be things like &lt;code&gt;{status=error}&lt;/code&gt; (what is different about errors?) or
&lt;code&gt;{duration&amp;gt;1s}&lt;/code&gt; (what is different about slow spans?)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Optional. The second parameter is the top &lt;code&gt;N&lt;/code&gt; values to return per attribute. If an attribute exceeds this limit in
either the selection group or baseline group, then only the top &lt;code&gt;N&lt;/code&gt; values (based on frequency) are returned, and an
error indicator for the attribute is included output (see below). Defaults to &lt;code&gt;10&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Optional. Start and End timestamps in Unix nanoseconds, which can be used to constrain the selection window by time,
in addition to the filter. For example, the overall query could cover the past hour, and the selection window only a
5 minute time period in which there was an anomaly. These timestamps must both be given, or neither.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&#34;output&#34;&gt;Output&lt;/h3&gt;
&lt;p&gt;The outputs are flat time-series for each attribute/value found in the spans.&lt;/p&gt;
&lt;p&gt;Each series has a label &lt;code&gt;__meta_type&lt;/code&gt; which denotes which group it is in, either &lt;code&gt;selection&lt;/code&gt; or &lt;code&gt;baseline&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Example output series:&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;{ __meta_type=&amp;#34;baseline&amp;#34;, resource.cluster=&amp;#34;prod&amp;#34; } 123
{ __meta_type=&amp;#34;baseline&amp;#34;, resource.cluster=&amp;#34;qa&amp;#34; } 124
{ __meta_type=&amp;#34;selection&amp;#34;, resource.cluster=&amp;#34;prod&amp;#34; } 456   &amp;lt;--- significant difference detected
{ __meta_type=&amp;#34;selection&amp;#34;, resource.cluster=&amp;#34;qa&amp;#34; } 125
{ __meta_type=&amp;#34;selection&amp;#34;, resource.cluster=&amp;#34;dev&amp;#34;} 126  &amp;lt;--- cluster=dev was found in the highlighted spans but not in the baseline&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;When an attribute reaches the topN limit, there will also be present an error indicator.
This example means the attribute &lt;code&gt;resource.cluster&lt;/code&gt; had too many values.&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;{ __meta_error=&amp;#34;__too_many_values__&amp;#34;, resource.cluster=&amp;lt;nil&amp;gt; }&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
]]></content><description>&lt;h1 id="traceql-metrics-functions">TraceQL metrics functions&lt;/h1>
&lt;!-- Using a custom admonition because no feature flag is required. -->
&lt;div data-shared="traceql-metrics-admonition.md">
&lt;!-- Using a custom admonition because no feature flag is required. -->
&lt;div class="admonition admonition-caution">&lt;blockquote>&lt;p class="title text-uppercase">Caution&lt;/p></description></item></channel></rss>