Explore: Traces query that will work with either logs drilldown or explore (#115837)

* fix: use query that will work with either logs drilldown or explore
This commit is contained in:
Galen Kistler
2026-01-08 06:55:01 -06:00
committed by GitHub
parent 088bab8b38
commit 19cfab89f3
2 changed files with 7 additions and 7 deletions
@@ -200,7 +200,7 @@ describe('createSpanLinkFactory', () => {
datasource: 'loki1_uid',
queries: [
{
expr: '{cluster="cluster1", hostname="hostname1", service_namespace="namespace1"} | label_format log_line_contains_trace_id=`{{ contains "7946b05c2e2e4e5a" __line__ }}` | log_line_contains_trace_id="true" or trace_id="7946b05c2e2e4e5a" | label_format log_line_contains_span_id=`{{ contains "6605c7b08e715d6c" __line__ }}` | log_line_contains_span_id="true" or span_id="6605c7b08e715d6c"',
expr: '{cluster="cluster1", hostname="hostname1", service_namespace="namespace1"} | logfmt | json | drop __error__, __error_details__ | trace_id="7946b05c2e2e4e5a" | span_id="6605c7b08e715d6c"',
refId: '',
datasource: { uid: 'loki1_uid' },
},
@@ -446,12 +446,12 @@ function getQueryForLoki(
let expr = '{${__tags}}';
if (filterByTraceID && span.traceID) {
expr +=
' | label_format log_line_contains_trace_id=`{{ contains "${__span.traceId}" __line__ }}` | log_line_contains_trace_id="true" or trace_id="${__span.traceId}"';
}
if (filterBySpanID && span.spanID) {
expr +=
' | label_format log_line_contains_span_id=`{{ contains "${__span.spanId}" __line__ }}` | log_line_contains_span_id="true" or span_id="${__span.spanId}"';
expr += ' | logfmt | json | drop __error__, __error_details__ | trace_id="${__span.traceId}"';
if (filterBySpanID && span.spanID) {
expr += ' | span_id="${__span.spanId}"';
}
} else if (filterBySpanID && span.spanID) {
expr += ' | logfmt | json | drop __error__, __error_details__ | span_id="${__span.spanId}"';
}
return {