diff --git a/docs/VictoriaLogs/CHANGELOG.md b/docs/VictoriaLogs/CHANGELOG.md index df69bc6c8..cc19893ba 100644 --- a/docs/VictoriaLogs/CHANGELOG.md +++ b/docs/VictoriaLogs/CHANGELOG.md @@ -19,6 +19,7 @@ according to [these docs](https://docs.victoriametrics.com/VictoriaLogs/QuickSta ## tip +* FEATURE: support [comparing](https://docs.victoriametrics.com/victorialogs/logsql/#range-filter) log field values with [special numeric values](https://docs.victoriametrics.com/victorialogs/logsql/#numeric-values). For example, `duration:>1.5s` and `response_size:<15KiB` are valid filters now. * FEATURE: add an ability to preserve the original non-empty field values when performing [`extract`](https://docs.victoriametrics.com/victorialogs/logsql/#extract-pipe), [`unpack_json`](https://docs.victoriametrics.com/victorialogs/logsql/#unpack_json-pipe), [`unpack_logfmt`](https://docs.victoriametrics.com/victorialogs/logsql/#unpack_logfmt-pipe) and [`format`](https://docs.victoriametrics.com/victorialogs/logsql/#format-pipe) pipes. ## [v0.10.0](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v0.10.0-victorialogs) diff --git a/docs/VictoriaLogs/LogsQL.md b/docs/VictoriaLogs/LogsQL.md index 944d1abc7..047050c5d 100644 --- a/docs/VictoriaLogs/LogsQL.md +++ b/docs/VictoriaLogs/LogsQL.md @@ -857,7 +857,7 @@ The following query returns logs with request durations smaller or equal to 1.5 request.duration:<=1.5 ``` -The lower and the upper bounds of the range are excluded by default. If they must be included, then substitute the corresponding +The lower and the upper bounds of the `range(lower, upper)` are excluded by default. If they must be included, then substitute the corresponding parentheses with square brackets. For example: - `range[1, 10)` includes `1` in the matching range @@ -2188,7 +2188,6 @@ LogsQL supports the following transformations on the log entries selected with [ LogsQL will support the following transformations in the future: - Creating a new field according to math calculations over existing [log fields](https://docs.victoriametrics.com/VictoriaLogs/keyConcepts.html#data-model). -- Parsing duration strings into floating-point seconds for further [stats calculations](#stats-pipe). See the [Roadmap](https://docs.victoriametrics.com/VictoriaLogs/Roadmap.html) for details. diff --git a/lib/logstorage/filter_range.go b/lib/logstorage/filter_range.go index dad9e0608..3ca6f0125 100644 --- a/lib/logstorage/filter_range.go +++ b/lib/logstorage/filter_range.go @@ -289,13 +289,32 @@ func matchUint64ByRange(bs *blockSearch, ch *columnHeader, bm *bitmap, minValue, } func matchRange(s string, minValue, maxValue float64) bool { - f, ok := tryParseFloat64(s) + f, ok := tryParseNumber(s) if !ok { return false } return f >= minValue && f <= maxValue } +func tryParseNumber(s string) (float64, bool) { + if len(s) == 0 { + return 0, false + } + f, ok := tryParseFloat64(s) + if ok { + return f, true + } + nsecs, ok := tryParseDuration(s) + if ok { + return float64(nsecs), true + } + bytes, ok := tryParseBytes(s) + if ok { + return float64(bytes), true + } + return 0, false +} + func toUint64Range(minValue, maxValue float64) (uint64, uint64) { minValue = math.Ceil(minValue) maxValue = math.Floor(maxValue)