<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Use traces to find solutions on Grafana Labs</title><link>https://grafana.com/docs/tempo/v2.10.x/solutions-with-traces/</link><description>Recent content in Use traces to find solutions on Grafana Labs</description><generator>Hugo -- gohugo.io</generator><language>en</language><atom:link href="/docs/tempo/v2.10.x/solutions-with-traces/index.xml" rel="self" type="application/rss+xml"/><item><title>Identify bottlenecks and establish SLOs</title><link>https://grafana.com/docs/tempo/v2.10.x/solutions-with-traces/traces-app-insights/</link><pubDate>Thu, 09 Apr 2026 14:59:14 +0000</pubDate><guid>https://grafana.com/docs/tempo/v2.10.x/solutions-with-traces/traces-app-insights/</guid><content><![CDATA[&lt;h1 id=&#34;identify-bottlenecks-and-establish-slos&#34;&gt;Identify bottlenecks and establish SLOs&lt;/h1&gt;
&lt;p&gt;Traces give a window into an application&amp;rsquo;s performance, and the insights that go along with that. Using traces, you can discover bottlenecks and potential optimizations that can decrease latency and response times and increase application throughput.&lt;/p&gt;
&lt;h2 id=&#34;meet-handy-site-corp&#34;&gt;Meet Handy Site Corp&lt;/h2&gt;
&lt;p&gt;Handy Site Corp, a fake website company, runs an ecommerce application that includes user authentication, a product catalog, order management, payment processing, and other services.&lt;/p&gt;
&lt;h3 id=&#34;define-realistic-slos&#34;&gt;Define realistic SLOs&lt;/h3&gt;
&lt;!-- vale Grafana.Acronyms = NO --&gt;
&lt;p&gt;Handy Site’s engineers start by establishing service level objectives, or SLOs, around latency ensure that customers have a good experience when trying to complete the checkout process.
To do this, they use metrics generated from their span data.&lt;/p&gt;
&lt;p&gt;Their service level objective should be a realistic target based on previous history during times of normal operation.
Once they&amp;rsquo;ve agreed upon their service level objective, they set up alerts to signal risk of failing to meet that objective.&lt;/p&gt;
&lt;h3 id=&#34;utilize-span-metrics-to-define-your-slo-and-sli&#34;&gt;Utilize span metrics to define your SLO and SLI&lt;/h3&gt;
&lt;p&gt;After evaluating options, they decide to use 
    &lt;a href=&#34;/docs/tempo/v2.10.x/metrics-from-traces/span-metrics/&#34;&gt;span metrics&lt;/a&gt; as a service-level indicator (SLI) to measure SLO compliance.&lt;/p&gt;
&lt;p&gt;&lt;img
  class=&#34;lazyload d-inline-block&#34;
  data-src=&#34;/media/docs/tempo/intro/traces-metrics-gen-exemplars.png&#34;
  alt=&#34;Metrics generator and exemplars&#34; width=&#34;1600&#34;
     height=&#34;848&#34;/&gt;&lt;/p&gt;
&lt;p&gt;Tempo can generate metrics using the 
    &lt;a href=&#34;/docs/tempo/v2.10.x/metrics-from-traces/metrics-generator/&#34;&gt;metrics-generator component&lt;/a&gt;.
These metrics are created based on spans from incoming traces and demonstrate immediate usefulness with respect to application flow and overview.
This includes rate, error, and duration (RED) metrics.&lt;/p&gt;
&lt;p&gt;Span metrics also make it easy to use exemplars.
An 
    &lt;a href=&#34;/docs/grafana/next/basics/exemplars/&#34;&gt;exemplar&lt;/a&gt; serves as a detailed example of one of the observations aggregated into a metric. An exemplar contains the observed value together with an optional timestamp and arbitrary trace IDs, which are typically used to reference a trace.
Since traces and metrics co-exist in the metrics-generator, exemplars can be automatically added to those metrics, allowing you to quickly jump from a metric showing aggregate latency over time into an individual trace that represents a low, medium, or high latency request. Similarly, you can quickly jump from a metric showing error rate over time into an individual erroring trace.&lt;/p&gt;
&lt;h3 id=&#34;monitor-latency&#34;&gt;Monitor latency&lt;/h3&gt;
&lt;p&gt;Handy Site decides they&amp;rsquo;re most interested in monitoring the latency of requests processed by their checkout service and want to set an objective that 99.5% of requests in a given month should complete within 2 seconds.
To define a service-level indicator (SLI) that they can use to track their progress against their objective, they use the &lt;code&gt;traces_spanmetrics_latency&lt;/code&gt; metric with the proper label selectors, such as &lt;code&gt;service name = checkoutservice&lt;/code&gt;.
The metrics-generator adds a default set of labels to the metrics it generates, including &lt;code&gt;span_kind&lt;/code&gt; and &lt;code&gt;status_code&lt;/code&gt;.
If they want to calculate checkout service latency per endpoint or per version of the software, they could change the configuration of the Tempo metrics-generator to add these custom dimensions as labels to their span metrics.&lt;/p&gt;
&lt;p&gt;With all of this in place, Handy Site opens the &lt;a href=&#34;/docs/grafana-cloud/alerting-and-irm/slo/&#34;&gt;Grafana SLO&lt;/a&gt; application and follows the setup flow to establish an &lt;a href=&#34;/docs/grafana-cloud/alerting-and-irm/slo/create/&#34;&gt;SLI&lt;/a&gt; for their checkout service around the &lt;code&gt;traces_spanmetrics_latency&lt;/code&gt; metric.
They can be alerted to degradations in service quality that directly impact their end user experience.
SLO-based alerting also ensures that they don&amp;rsquo;t suffer from noisy alerts.
Alerts are only triggered when the value of the SLI is such that the team is in danger of missing their SLO.&lt;/p&gt;
&lt;p&gt;&lt;img
  class=&#34;lazyload d-inline-block&#34;
  data-src=&#34;/media/docs/tempo/intro/traces-metrics-gen-SLO.png&#34;
  alt=&#34;Latency SLO dashboard&#34; width=&#34;720&#34;
     height=&#34;356&#34;/&gt;&lt;/p&gt;
&lt;!-- vale Grafana.Acronyms = YES--&gt;
]]></content><description>&lt;h1 id="identify-bottlenecks-and-establish-slos">Identify bottlenecks and establish SLOs&lt;/h1>
&lt;p>Traces give a window into an application&amp;rsquo;s performance, and the insights that go along with that. Using traces, you can discover bottlenecks and potential optimizations that can decrease latency and response times and increase application throughput.&lt;/p></description></item><item><title>Diagnose errors with traces</title><link>https://grafana.com/docs/tempo/v2.10.x/solutions-with-traces/traces-diagnose-errors/</link><pubDate>Thu, 09 Apr 2026 14:59:14 +0000</pubDate><guid>https://grafana.com/docs/tempo/v2.10.x/solutions-with-traces/traces-diagnose-errors/</guid><content><![CDATA[&lt;h1 id=&#34;diagnose-errors-with-traces&#34;&gt;Diagnose errors with traces&lt;/h1&gt;
&lt;p&gt;Traces allow you to quickly diagnose errors in your application, ensuring that you can perform Root Cause Analysis (RCA) on request failures.
Trace visualizations help you determine the spans in which errors occur, along with the context behind those errors, leading to a lower mean time to repair.&lt;/p&gt;
&lt;h2 id=&#34;meet-handy-site-corp&#34;&gt;Meet Handy Site Corp&lt;/h2&gt;
&lt;p&gt;Handy Site Corp, a fake website company, runs an e-commerce application that includes user authentication, a product catalog, order management, payment processing, and other services.&lt;/p&gt;
&lt;p&gt;Handy Site&amp;rsquo;s operations team receives several alerts for their error service-level objectives, or SLOs, for monitored endpoints in their services.
Using their Grafana dashboards, they notice that there are several issues.
The dashboard provides the percentages of errors:&lt;/p&gt;
&lt;p&gt;&lt;img
  class=&#34;lazyload d-inline-block&#34;
  data-src=&#34;/media/docs/tempo/intro/traces-error-SLO.png&#34;
  alt=&#34;Dashboard showing errors in services&#34; width=&#34;1775&#34;
     height=&#34;859&#34;/&gt;&lt;/p&gt;
&lt;p&gt;More than 5% of the requests from users are resulting in an error across several endpoints, such as &lt;code&gt;/beholder&lt;/code&gt;, &lt;code&gt;/owlbear&lt;/code&gt;, and &lt;code&gt;/illithid&lt;/code&gt;, which causes a degradation in performance and usability.
It&amp;rsquo;s imperative for the operations team at Handy Site to quickly troubleshoot the issue.
The elevated error rates indicate that the Handy Site is unable to provide valid responses to their users&amp;rsquo; requests, which in addition to threatening the operation team&amp;rsquo;s SLO error budget also affects profitability overall for Handy Site.&lt;/p&gt;
&lt;h2 id=&#34;use-traceql-to-query-data&#34;&gt;Use TraceQL to query data&lt;/h2&gt;
&lt;p&gt;Tempo has a traces-first query language, 
    &lt;a href=&#34;/docs/tempo/v2.10.x/traceql/&#34;&gt;TraceQL&lt;/a&gt;, that provides a unique toolset for selecting and searching tracing data.
TraceQL can match traces based on span and resource attributes, duration, and ancestor&amp;lt;&amp;gt;descendant relationships.
The language also can compute aggregate statistics, such as &lt;code&gt;rate&lt;/code&gt; over a set of spans.&lt;/p&gt;
&lt;p&gt;Handy Site&amp;rsquo;s has instrumented their  services and applications for tracing, so they can use TraceQL as a debugging tool.
Using three TraceQL queries, the team identifies and validates the root cause of the issue.&lt;/p&gt;
&lt;h3 id=&#34;find-http-errors&#34;&gt;Find HTTP errors&lt;/h3&gt;
&lt;p&gt;The top-level service, &lt;code&gt;mythical-requester&lt;/code&gt; receives requests and returns responses to users. When it receives a request, it calls numerous downstream services whose responses it relies on to send a response to the user request.
Using Grafana Explore, the operations team starts with a simple TraceQL query to find all traces from this top-level service, where an HTTP response code sent to a user is &lt;code&gt;400&lt;/code&gt; or above. Status codes in this range include &lt;code&gt;Forbidden&lt;/code&gt;, &lt;code&gt;Not found&lt;/code&gt;, &lt;code&gt;Unauthorized&lt;/code&gt;, and other client and server 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;mythical-requester&amp;#34; &amp;amp;&amp;amp; span.http.status_code &amp;gt;= 400 } | select(span.http.target)&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Adding the &lt;code&gt;select&lt;/code&gt; statement to this query (after the &lt;code&gt;|&lt;/code&gt;) ensures that the query response includes not only the set of matched spans, but also the &lt;code&gt;http.target&lt;/code&gt; attribute (for example, the endpoints for the SaaS service) for each of those spans.&lt;/p&gt;
&lt;p&gt;&lt;img
  class=&#34;lazyload d-inline-block&#34;
  data-src=&#34;/media/docs/tempo/intro/traceql-http-target-handy-site.png&#34;
  alt=&#34;Query results showing http.target attribute&#34; width=&#34;1789&#34;
     height=&#34;973&#34;/&gt;&lt;/p&gt;
&lt;h3 id=&#34;pinpoint-the-error&#34;&gt;Pinpoint the error&lt;/h3&gt;
&lt;p&gt;Looking at the set of returned spans, the most concerning ones are those with the &lt;code&gt;HTTP 500&lt;/code&gt; status code. Those are internal server errors.&lt;/p&gt;
&lt;p&gt;The team decides to use structural operators to follow an error chain from the top-level &lt;code&gt;mythical-requester&lt;/code&gt; service to any descendant spans that also have an error status.
Descendant spans can be any span that&amp;rsquo;s descended from the parent span, such as a child or a further child at any depth.
Using this query, the team can pinpoint the downstream service that might be causing the issue.
The query below says &amp;ldquo;Find spans where &lt;code&gt;status = error&lt;/code&gt; that are descendants of spans from the &lt;code&gt;mythical-requester&lt;/code&gt; service that have status code &lt;code&gt;500&lt;/code&gt;.&amp;rdquo;&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;mythical-requester&amp;#34; &amp;amp;&amp;amp; span.http.status_code = 500 } &amp;gt;&amp;gt; { status = error }&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;img
  class=&#34;lazyload d-inline-block&#34;
  data-src=&#34;/media/docs/tempo/intro/traceql-error-insert-handy-site.png&#34;
  alt=&#34;TraceQL results showing expanded span&#34; width=&#34;1789&#34;
     height=&#34;1318&#34;/&gt;&lt;/p&gt;
&lt;p&gt;Expanding the span with errors that&amp;rsquo;s a descendant of the span for the &lt;code&gt;mythical-server&lt;/code&gt; service shows the team that there is a problem with the data inserted into the database.
Specifically, the service is passing a &lt;code&gt;null&lt;/code&gt; value for a column in a database table where &lt;code&gt;null&lt;/code&gt; values are invalid.&lt;/p&gt;
&lt;p&gt;&lt;img
  class=&#34;lazyload d-inline-block&#34;
  data-src=&#34;/media/docs/tempo/intro/traceql-insert-postgres-handy-site.png&#34;
  alt=&#34;Error span for INSERT&#34; width=&#34;830&#34;
     height=&#34;660&#34;/&gt;&lt;/p&gt;
&lt;h3 id=&#34;verify-root-cause&#34;&gt;Verify root cause&lt;/h3&gt;
&lt;p&gt;After identifying the specific cause of this internal server error,
the team wants to know if there are errors in any database operations other than the &lt;code&gt;null&lt;/code&gt; &lt;code&gt;INSERT&lt;/code&gt; error found above.
Their updated query uses a negated regular expression to find any spans where the database statement either doesn&amp;rsquo;t exist, or doesn&amp;rsquo;t start with an &lt;code&gt;INSERT&lt;/code&gt; clause.
This should expose any other issues causing an internal server error and filter out the class of issues that they already diagnosed.&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;mythical-requester&amp;#34; &amp;amp;&amp;amp; span.http.status_code = 500 } &amp;gt;&amp;gt; { status = error &amp;amp;&amp;amp; span.db.statement !~ &amp;#34;INSERT.*&amp;#34; }&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;This query yields no results, suggesting that the root cause of the issues the operations team are seeing is exclusively due to the failing database &lt;code&gt;INSERT&lt;/code&gt; statement.
At this point, they can roll back to a known working version of the service, or deploy a fix to ensure that the service rejects &lt;code&gt;null&lt;/code&gt; data appropriately.
After it completes, the team marks the issue resolved.
The Handy team&amp;rsquo;s error rate SLI should return back to acceptable levels.&lt;/p&gt;
&lt;p&gt;&lt;img
  class=&#34;lazyload d-inline-block&#34;
  data-src=&#34;/media/docs/tempo/intro/traceql-no-results-handy-site.png&#34;
  alt=&#34;Empty query results&#34; width=&#34;1792&#34;
     height=&#34;531&#34;/&gt;&lt;/p&gt;
]]></content><description>&lt;h1 id="diagnose-errors-with-traces">Diagnose errors with traces&lt;/h1>
&lt;p>Traces allow you to quickly diagnose errors in your application, ensuring that you can perform Root Cause Analysis (RCA) on request failures.
Trace visualizations help you determine the spans in which errors occur, along with the context behind those errors, leading to a lower mean time to repair.&lt;/p></description></item><item><title>Solve problems with TraceQL metrics queries</title><link>https://grafana.com/docs/tempo/v2.10.x/solutions-with-traces/solve-problems-metrics-queries/</link><pubDate>Thu, 09 Apr 2026 14:59:14 +0000</pubDate><guid>https://grafana.com/docs/tempo/v2.10.x/solutions-with-traces/solve-problems-metrics-queries/</guid><content><![CDATA[&lt;h1 id=&#34;solve-problems-with-traceql-metrics-queries&#34;&gt;Solve problems with TraceQL 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;public preview feature&lt;/a&gt;. Grafana Labs offers limited support, and breaking changes might occur prior to the feature being made generally available
TraceQL metrics are enabled by default 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/tempo/v2.10.x/metrics-from-traces/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-traceql-metrics-queries">Solve problems with TraceQL 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></channel></rss>