TraceQL search to get all the DB queries in a specific trace ID

We are looking for setting up the all the DB query statements from a specific traceID. Currently we get all the information and need to apply the transformations on the tags column to extract the DB statement. could you please let us know if there is any other better way to get the DB statements from the specific trace ID?

Can you clarify more on what your current process is?

There are a few things that come to mind that might help, but I don’t think there is a perfect solution.

  1. When doing a TraceQL search you can do select(.db.statement) or .db.statement != "" to make the attribute appear in the search results columns. This only shows the first 3 spans per trace though.
  2. When viewing a trace, you can use the new Span Filters UI to show only the db query spans. This makes it easy to click on and view each span.
  3. You could download the trace json from tempo curl /api/traces/<traceid> and then write a custom app to extract the db statements.

Thanks a lot for the response.

I will give the Span Filters UI a try, i believe that works for my use case. Will keep the thread posted on the progress.

Could you please let me know if the feature is available for Grafana version 9.3.6 ?