From daa8672ae2b23f7d149744119f02ceaa28b3414c Mon Sep 17 00:00:00 2001 From: Hamid Date: Thu, 5 Mar 2026 23:52:43 +0300 Subject: [PATCH 1/5] added regex based searching for tags --- app/vtselect/traces/query/query.go | 7 ++++++- docs/victoriatraces/querying/README.md | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/vtselect/traces/query/query.go b/app/vtselect/traces/query/query.go index 0391eb8e2..b67c533f9 100644 --- a/app/vtselect/traces/query/query.go +++ b/app/vtselect/traces/query/query.go @@ -229,7 +229,12 @@ func getTraceIDList(ctx context.Context, cp *tracecommon.CommonParams, param *Tr } if len(param.Attributes) > 0 { for k, v := range param.Attributes { - qStr += fmt.Sprintf(`AND %q:=%q `, k, v) + if strings.HasPrefix(v, "~") { + // ~ prefix forces regex (e.g. tags={"key":"~value.*"}) + qStr += fmt.Sprintf(`AND %q:re(%s) `, k, strconv.Quote(v[1:])) + } else { + qStr += fmt.Sprintf(`AND %q:=%q `, k, v) + } } } if param.DurationMin > 0 { diff --git a/docs/victoriatraces/querying/README.md b/docs/victoriatraces/querying/README.md index f1f0a9e35..eb4c60ba9 100644 --- a/docs/victoriatraces/querying/README.md +++ b/docs/victoriatraces/querying/README.md @@ -59,7 +59,7 @@ The `/select/jaeger/api/traces` HTTP endpoint provides the following params: - `service`: the service name. - `operation`: the span name (also known as the operation name in Jaeger). -- `tags`: the attributes (also known as tags) filter, example: `{"key":"value"}` +- `tags`: the attributes (also known as tags) filter, example: `{"key":"value"}`. Prefix a value with `~` to use regex matching, e.g. `{"key":"~value.*"}` - `start`: the start timestamp in unix microseconds. - `end`: the end timestamp in unix microseconds. - `minDuration`: the minimum duration of the span, with units `ns`, `us`, `ms`, `s`, `m`, or `h`. @@ -216,3 +216,4 @@ Some valid filter examples: - Multiple span attribute filters: `error=unset otel.scope.name=redis-manual` - Single resource attribute filter: `resource_attr:telemetry.sdk.language=go` - Span attribute and resource attribute filters: `span.kind=client resource_attr:os.type=linux` +- Regex filter: prefix the value with `~` to match by regex, e.g. `{"order_id":"~abc.*"}` or `{"http.status_code":"~^2"}` for values starting with "2" From 075dbce3d1597589f5e7f9b3e6424cc2aa1f4d01 Mon Sep 17 00:00:00 2001 From: Hamid <33328203+emamihe@users.noreply.github.com> Date: Thu, 9 Apr 2026 16:33:42 +0300 Subject: [PATCH 2/5] Apply suggestion from @jiekun Co-authored-by: Zhu Jiekun Signed-off-by: Hamid <33328203+emamihe@users.noreply.github.com> --- docs/victoriatraces/querying/README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/victoriatraces/querying/README.md b/docs/victoriatraces/querying/README.md index eb4c60ba9..e9673ccb2 100644 --- a/docs/victoriatraces/querying/README.md +++ b/docs/victoriatraces/querying/README.md @@ -216,4 +216,6 @@ Some valid filter examples: - Multiple span attribute filters: `error=unset otel.scope.name=redis-manual` - Single resource attribute filter: `resource_attr:telemetry.sdk.language=go` - Span attribute and resource attribute filters: `span.kind=client resource_attr:os.type=linux` -- Regex filter: prefix the value with `~` to match by regex, e.g. `{"order_id":"~abc.*"}` or `{"http.status_code":"~^2"}` for values starting with "2" +- Multiple regex filters: `span.kind=~cli.* http.status_code:~^2` + +Note that the examples are for user input on the Jaeger frontend, which parses and sends the request in JSON format later. From 182a2f6b79cae31a2d5b881ce6604e2f7d6a2a47 Mon Sep 17 00:00:00 2001 From: Jiekun Date: Fri, 10 Apr 2026 11:06:59 +0800 Subject: [PATCH 3/5] docs: mentioning regex match in Jaeger --- docs/victoriatraces/changelog/CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/victoriatraces/changelog/CHANGELOG.md b/docs/victoriatraces/changelog/CHANGELOG.md index 01e1bf638..7a7ea0966 100644 --- a/docs/victoriatraces/changelog/CHANGELOG.md +++ b/docs/victoriatraces/changelog/CHANGELOG.md @@ -12,6 +12,8 @@ The following `tip` changes can be tested by building VictoriaTraces components ## tip +* FEATURE: [Single-node VictoriaTraces](https://docs.victoriametrics.com/victoriatraces/) and vtselect in [VictoriaTraces cluster](https://docs.victoriametrics.com/victoriatraces/cluster/): support positive regex matching in the Jaeger query API when filtering traces by tags. See [the pull request #100](https://github.com/VictoriaMetrics/VictoriaTraces/pull/116) for examples. Thank @emamihe for the pull request. + ## [v0.8.0](https://github.com/VictoriaMetrics/VictoriaTraces/releases/tag/v0.8.0) Released at 2026-03-02 From 293cf42a9991895c9116c599ed8d01cfa949992d Mon Sep 17 00:00:00 2001 From: Jiekun Date: Fri, 10 Apr 2026 11:14:39 +0800 Subject: [PATCH 4/5] test: add regex match to apptest --- apptest/tests/otlp_ingestion_test.go | 47 ++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/apptest/tests/otlp_ingestion_test.go b/apptest/tests/otlp_ingestion_test.go index f3d3b03a4..5355de4bf 100644 --- a/apptest/tests/otlp_ingestion_test.go +++ b/apptest/tests/otlp_ingestion_test.go @@ -250,6 +250,7 @@ func getDefaultIngestRequestAndAssertFunc(tc *at.TestCase, sut at.VictoriaTraces cmpopts.IgnoreFields(at.JaegerAPITracesResponse{}, "Errors", "Limit", "Offset", "Total"), }, }) + // check single trace data via /select/jaeger/api/traces/ tc.Assert(&at.AssertOptions{ Msg: "unexpected /select/jaeger/api/traces/ response", @@ -263,6 +264,52 @@ func getDefaultIngestRequestAndAssertFunc(tc *at.TestCase, sut at.VictoriaTraces cmpopts.IgnoreFields(at.JaegerAPITraceResponse{}, "Errors", "Limit", "Offset", "Total"), }, }) + + // check traces data via /select/jaeger/api/traces with regex tag filter: NOT match, empty result + tc.Assert(&at.AssertOptions{ + Msg: "unexpected /select/jaeger/api/traces response", + Got: func() any { + return sut.JaegerAPITraces(t, at.JaegerQueryParam{ + TraceQueryParam: query.TraceQueryParam{ + ServiceName: serviceName, + StartTimeMin: spanTime.Add(-10 * time.Minute), + StartTimeMax: spanTime.Add(10 * time.Minute), + Attributes: map[string]string{ + "testTag": "~INVALID.*", + }, + }, + }, at.QueryOpts{}) + }, + Want: &at.JaegerAPITracesResponse{ + Data: []at.TracesResponseData{}, + }, + CmpOpts: []cmp.Option{ + cmpopts.IgnoreFields(at.JaegerAPITracesResponse{}, "Errors", "Limit", "Offset", "Total"), + }, + }) + + // check traces data via /select/jaeger/api/traces with regex tag filter: match + tc.Assert(&at.AssertOptions{ + Msg: "unexpected /select/jaeger/api/traces response", + Got: func() any { + return sut.JaegerAPITraces(t, at.JaegerQueryParam{ + TraceQueryParam: query.TraceQueryParam{ + ServiceName: serviceName, + StartTimeMin: spanTime.Add(-10 * time.Minute), + StartTimeMax: spanTime.Add(10 * time.Minute), + Attributes: map[string]string{ + "testTag": "~test.*", + }, + }, + }, at.QueryOpts{}) + }, + Want: &at.JaegerAPITracesResponse{ + Data: expectTraceData, + }, + CmpOpts: []cmp.Option{ + cmpopts.IgnoreFields(at.JaegerAPITracesResponse{}, "Errors", "Limit", "Offset", "Total"), + }, + }) } return req, assertFunc } From 3132c5c27eaee87b289e2b4eb9838d312ea53c28 Mon Sep 17 00:00:00 2001 From: Zhu Jiekun Date: Fri, 10 Apr 2026 11:16:12 +0800 Subject: [PATCH 5/5] Update docs/victoriatraces/changelog/CHANGELOG.md Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com> Signed-off-by: Zhu Jiekun --- docs/victoriatraces/changelog/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/victoriatraces/changelog/CHANGELOG.md b/docs/victoriatraces/changelog/CHANGELOG.md index 7a7ea0966..aa6a850b4 100644 --- a/docs/victoriatraces/changelog/CHANGELOG.md +++ b/docs/victoriatraces/changelog/CHANGELOG.md @@ -12,7 +12,7 @@ The following `tip` changes can be tested by building VictoriaTraces components ## tip -* FEATURE: [Single-node VictoriaTraces](https://docs.victoriametrics.com/victoriatraces/) and vtselect in [VictoriaTraces cluster](https://docs.victoriametrics.com/victoriatraces/cluster/): support positive regex matching in the Jaeger query API when filtering traces by tags. See [the pull request #100](https://github.com/VictoriaMetrics/VictoriaTraces/pull/116) for examples. Thank @emamihe for the pull request. +* FEATURE: [Single-node VictoriaTraces](https://docs.victoriametrics.com/victoriatraces/) and vtselect in [VictoriaTraces cluster](https://docs.victoriametrics.com/victoriatraces/cluster/): support positive regex matching in the Jaeger query API when filtering traces by tags. See [the pull request #116](https://github.com/VictoriaMetrics/VictoriaTraces/pull/116) for examples. Thank @emamihe for the pull request. ## [v0.8.0](https://github.com/VictoriaMetrics/VictoriaTraces/releases/tag/v0.8.0)