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
lib/logstorage: treat row_any, row_min and row_max results as labels instead of metrics when executing /select/logsql/stats_query and /select/logsql/stats_query_range
row_any, row_min and row_max return string values, so they cannot be used as numeric metrics by clients
requesting /select/logsql/stats_query and /select/logsql/stats_query_range (for example, vmalert and Grafana plugin for VictoriaLogs).
It is better to treat them as labels. This allows obtaining a sample of some label (for example, log message)
at vmalert, and use it in the created alert annotation / description, via the following query:
error | stats count() errors, row_any(_msg) msg_sample | filter errors:>0
The row_*() funtions return JSON-encoded string. It can be unpacked into the needed fields via unpack_json pipe if needed,
while the JSON-encoded string can be removed from the output if needed with the delete pipe:
error
| stats by (path)
count() as errors,
row_any(_msg) as msg_sample
| filter errors:>0
| unpack_json from msg_sample fields (_msg)
| delete msg_sample
See #81
Copy file name to clipboardExpand all lines: docs/victorialogs/CHANGELOG.md
+5-4Lines changed: 5 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,6 +21,7 @@ according to the follosing docs:
21
21
22
22
## tip
23
23
24
+
* FEATURE: [HTTP querying API](https://docs.victoriametrics.com/victorialogs/querying/#http-api): automatically convert the results of [`row_any()`](https://docs.victoriametrics.com/victorialogs/logsql/#row_any-stats), [`row_min()`](https://docs.victoriametrics.com/victorialogs/logsql/#row_min-stats) and [`row_max()`](https://docs.victoriametrics.com/victorialogs/logsql/#row_max-stats) stats functions to labels in [`/select/logsql/stats_query`](https://docs.victoriametrics.com/victorialogs/querying/#querying-log-stats) and [`/select/logsql/stats_query_range`](https://docs.victoriametrics.com/victorialogs/querying/#querying-log-range-stats) functions. This allows obtaining a sample of log message in alerting rules with the following query: `... | stats count() as hits, row_any(_msg) as msg_sample`. See [#81](https://github.com/VictoriaMetrics/VictoriaLogs/issues/81).
24
25
* FEATURE: [vmui](https://docs.victoriametrics.com/victoriametrics/single-server-victoriametrics/#vmui): show VictoriaLogs version in the vmui's footer. See [#116](https://github.com/VictoriaMetrics/VictoriaLogs/issues/116).
* FEATURE: [`sum_len` stats function](https://docs.victoriametrics.com/victorialogs/logsql/#sum_len-stats): allow calculating the sum of byte lengths for all the fields with common prefix via `sum_len(prefix*)` syntax.
347
348
* FEATURE: [`count` stats function](https://docs.victoriametrics.com/victorialogs/logsql/#count-stats): allow calculating the number of logs with at least a single non-empty field across fields with common prefix via `count(prefix*)` syntax.
348
349
* FEATURE: [`count_empty` stats function](https://docs.victoriametrics.com/victorialogs/logsql/#count_empty-stats): allow calculating the number of logs with empty fields with common prefix via `count_empty(prefix*)` syntax.
349
-
* FEATURE: [`rate_sum` stats function](https://docs.victoriametrics.com/victorialogs/logsql/#avg-stats): allow calculating the per-second rate over the sum of all the fields with common prefix via `rate_sum(prefix*)` syntax.
350
-
* FEATURE: [`row_any` stats function](https://docs.victoriametrics.com/victorialogs/logsql/#avg-stats): allow returning all the fields with common prefix via `row_any(prefix*)` syntax.
351
-
* FEATURE: [`row_max` stats function](https://docs.victoriametrics.com/victorialogs/logsql/#avg-stats): allow returning all the fields with common prefix via `row_max(max_field, prefix*)` syntax.
352
-
* FEATURE: [`row_min` stats function](https://docs.victoriametrics.com/victorialogs/logsql/#avg-stats): allow returning all the fields with common prefix via `row_min(min_field, prefix*)` syntax.
350
+
* FEATURE: [`rate_sum` stats function](https://docs.victoriametrics.com/victorialogs/logsql/#rate_sum-stats): allow calculating the per-second rate over the sum of all the fields with common prefix via `rate_sum(prefix*)` syntax.
351
+
* FEATURE: [`row_any` stats function](https://docs.victoriametrics.com/victorialogs/logsql/#row_any-stats): allow returning all the fields with common prefix via `row_any(prefix*)` syntax.
352
+
* FEATURE: [`row_max` stats function](https://docs.victoriametrics.com/victorialogs/logsql/#row_max-stats): allow returning all the fields with common prefix via `row_max(max_field, prefix*)` syntax.
353
+
* FEATURE: [`row_min` stats function](https://docs.victoriametrics.com/victorialogs/logsql/#row_min-stats): allow returning all the fields with common prefix via `row_min(min_field, prefix*)` syntax.
353
354
* FEATURE: [`uniq_values` stats function](https://docs.victoriametrics.com/victorialogs/logsql/#uniq_values-stats): allow fetching unique values for all the fields with common prefix via `uniq_values(prefix*)` syntax.
354
355
* FEATURE: [`values` stats function](https://docs.victoriametrics.com/victorialogs/logsql/#values-stats): allow fetching values for all the fields with common prefix via `values(prefix*)` syntax.
355
356
* FEATURE: [`json_values` stats function](https://docs.victoriametrics.com/victorialogs/logsql/#json_values-stats): allow fetching values for all the fields with common prefix via `json_values(prefix*)` syntax.
0 commit comments