You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/victorialogs/CHANGELOG.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,6 +18,8 @@ according to [these docs](https://docs.victoriametrics.com/victorialogs/quicksta
18
18
19
19
## tip
20
20
21
+
* FEATURE: [LogsQL](https://docs.victoriametrics.com/victorialogs/logsql/): add [pattern match filter](https://docs.victoriametrics.com/victorialogs/logsql/#pattern-match-filter) for searching logs by the given patterns such as `<DATETIME>: user_id=<N>, ip=<IP4>, trace_id=<UUID>`. These filters are needed for [#518](https://github.com/VictoriaMetrics/VictoriaLogs/issues/518).
Copy file name to clipboardExpand all lines: docs/victorialogs/LogsQL.md
+45-2Lines changed: 45 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -264,15 +264,18 @@ The list of LogsQL filters:
264
264
-[Phrase filter](#phrase-filter) - matches logs with the given phrase
265
265
-[Prefix filter](#prefix-filter) - matches logs with the given word prefix or phrase prefix
266
266
-[Substring filter](#substring-filter) - matches logs with the given substring
267
+
-[Pattern match filter](#pattern-match-filter) - matches logs by the given pattern
267
268
-[Range comparison filter](#range-comparison-filter) - matches logs with field values in the provided range
268
269
-[Empty value filter](#empty-value-filter) - matches logs without the given [log field](https://docs.victoriametrics.com/victorialogs/keyconcepts/#data-model)
269
270
-[Any value filter](#any-value-filter) - matches logs with the given non-empty [log field](https://docs.victoriametrics.com/victorialogs/keyconcepts/#data-model)
270
271
-[Exact filter](#exact-filter) - matches logs with the exact value for the given [log field](https://docs.victoriametrics.com/victorialogs/keyconcepts/#data-model)
271
272
-[Exact prefix filter](#exact-prefix-filter) - matches logs starting with the given prefix for the given [log field](https://docs.victoriametrics.com/victorialogs/keyconcepts/#data-model)
272
273
-[Multi-exact filter](#multi-exact-filter) - matches logs with one of the specified exact values for the given [log field](https://docs.victoriametrics.com/victorialogs/keyconcepts/#data-model)
273
274
-[Subquery filter](#subquery-filter) - matches logs with [log field](https://docs.victoriametrics.com/victorialogs/keyconcepts/#data-model) values matching the results of another query
274
-
-[`contains_all` filter](#contains_any-filter) - matches logs with [log field](https://docs.victoriametrics.com/victorialogs/keyconcepts/#data-model) containing all the provided [words](#word) / phrases
275
-
-[`contains_any` filter](#contains_any-filter) - matches logs with [log field](https://docs.victoriametrics.com/victorialogs/keyconcepts/#data-model) containing at least one of the provided [words](#word) / phrases
275
+
-[`contains_all` filter](#contains_any-filter) - matches logs with [log field](https://docs.victoriametrics.com/victorialogs/keyconcepts/#data-model) containing
276
+
all the provided [words](#word) / phrases
277
+
-[`contains_any` filter](#contains_any-filter) - matches logs with [log field](https://docs.victoriametrics.com/victorialogs/keyconcepts/#data-model) containing
278
+
at least one of the provided [words](#word) / phrases
276
279
-[Case-insensitive filter](#case-insensitive-filter) - matches logs with the given case-insensitive word, phrase or prefix
277
280
-[Sequence filter](#sequence-filter) - matches logs with the given sequence of words or phrases
278
281
-[Regexp filter](#regexp-filter) - matches logs for the given regexp
@@ -720,6 +723,41 @@ See also:
720
723
-[Exact-filter](#exact-filter)
721
724
-[Logical filter](#logical-filter)
722
725
726
+
### Pattern match filter
727
+
728
+
VictoriaLogs supports filtering logs by patterns with the `pattern_match("pattern")` filter. This filter matches logs where
729
+
[`_msg` field](https://docs.victoriametrics.com/victorialogs/keyconcepts/#message-field) contains the given `"pattern"`.
730
+
731
+
The filter can be applied to any given log field with the `log_field:pattern_match("pattern")` syntax.
732
+
733
+
The `"pattern"` must contain the text to match, plus arbitrary number of the following placeholders:
734
+
735
+
-`<N>` - matches any integer number. It also matches hexadecimal numbers with the length of 4 chars and longer. For example, it matches `123` and `12abcdEF`.
736
+
It doesn't match floating point numbers such as `123.456`. Use `<N>.<N>` pattern for matching such numbers.
737
+
-`<UUID>` - matches any UUID such as `2edfed59-3e98-4073-bbb2-28d321ca71a7`.
738
+
-`<IP4>` - matches IPv4 such as `123.45.67.89`. Use `<IP4>/<N>` for matching IPv4 masks.
739
+
-`<TIME>` - matches time strings such as `10:20:30`. It also captures fractional seconds such as `10:20:30.123` and `10:20:30,123`.
740
+
-`<DATE>` - matches date strings such as `2025-10-20` and `2025/10/20`.
741
+
-`<DATETIME>` - matches datetime strings such as `2025-10-20T08:09:11` and `2025-10-20 08:09:11`. It also captures fractional seconds and timezones.
742
+
743
+
Such patterns are generated by the [`collapse_nums` pipe](#collapse_nums-pipe).
744
+
745
+
For example, the following filter matches `_msg` field with the `<arbitrary_prefix>user_id=123, ip=45.67.89.12, time=2025-10-20T23:32:12Z<aribtrary_suffix>` contents:
If you need matching the whole `_msg` field value, then use `pattern_match_full("pattern")` filter.
752
+
753
+
See also:
754
+
755
+
-[`collapse_nums` pipe](#collapse_nums-pipe)
756
+
-[Sequence filter](#sequence-filter)
757
+
-[Phrase filter](#phrase-filter)
758
+
-[Substring filter](#substring-filter)
759
+
-[Logical filter](#logical-filter)
760
+
723
761
### Substring filter
724
762
725
763
If it is needed to find logs with some substring, then `*substring*` filter can be used. The substring can be but in quotes according to [these docs](#string-literals) if needed.
@@ -741,6 +779,7 @@ Performance tip: prefer using [word filter](#word-filter) and [phrase filter](#p
741
779
742
780
See also:
743
781
782
+
-[Pattern match filter](#pattern-match-filter)
744
783
-[Word filter](#word-filter)
745
784
-[Phrase filter](#phrase-filter)
746
785
-[Regexp filter](#regexp-filter)
@@ -1106,6 +1145,7 @@ For example, the following query matches `event:original` field containing `(err
1106
1145
1107
1146
See also:
1108
1147
1148
+
-[Pattern match filter](#pattern-match-filter)
1109
1149
-[`contains_all` filter](#contains_all-filter)
1110
1150
-[Word filter](#word-filter)
1111
1151
-[Phrase filter](#phrase-filter)
@@ -1606,12 +1646,15 @@ when the following query is executed:
1606
1646
_time:1h | collapse_nums prettify
1607
1647
```
1608
1648
1649
+
The patterns returned by `collapse_nums prettify` pipe can be used in [pattern match filter](#pattern-match-filter).
1650
+
1609
1651
`collapse_nums` can miss some numbers or can collapse unexpected numbers. In this case [conditional `collapse_nums`](#conditional-collapse_nums) can be used
1610
1652
for skipping such values and pre-processing them separately with [`replace_regexp`](#replace_regexp-pipe).
0 commit comments