Open valyala opened 2 months ago
Update: it looks like it is better using the standard bar chart
panel instead of timeseries panel from VictoriaMetrics web UI for displaying /select/logsql/stats_query_range
results because of the following reason:
Timeseries panel from VictoriaMetrics web UI assumes that every point on the graph shows the value for on the time range (t-step ... t]
, where t
is the timestamp of the point, and step
is the duration between points on the graph. This doesn't align well with results returned from VictoriaLogs querying APIs, including /select/logsql/stats_query_range
, since they return values on the time range [t ... t+step)
. So they are ideally displayed as filled bars according to https://github.com/VictoriaMetrics/VictoriaMetrics/issues/7101 .
Is your feature request related to a problem? Please describe
VictoriaLogs' query lanugage - LogsQL - provides
stats
pipe, which can be used for calculating various stats over the selected logs. For example, the following LogsQL query calculates the number of logs with the error word on the selected time range in web UI:Another example - the following query selects the number of logs per each
level
field on the selected time range:The problem is that by default these queries show numbers for the whole time range selected in the web UI, while sometimes it is more interesting on how these numbers were changed over time on the selected time range.
Describe the solution you'd like
Try automatically switching the
hits
panel totime series
panel if the query containsstats
pipe.Implementation details.
How to determine whether the query contains
stats
pipe?If the query matches the
/|\s+stats/i
regexp, then there are high chances it containsstats
pipe. Also, thestats
word can be omitted. For example,* | by (foo, bar) count()
is a valid query. Another example -* | count()
is also valid query. So the regexp should look like/|\s+(stats|by|count|<all_the_other_stats_funcs>)\b/i
.How to get time series data from VictoriaLogs if the query contains
stats
pipe?Try sending the request to
/select/logsql/stats_query_range
endpoint. If the endpoint returns a JSON with"status":"success"
field, then the response can be used for building time series graphs in the same way as it is used in the web UI for VictoriaMetrics. If the"status"
field contains other than"success"
word, then the web UI must gracefully switch back to hits panel.Describe alternatives you've considered
There is a feature request for adding support of time series panel in the Grafana plugin for VictoriaLogs.
Additional information
The related feature request - https://github.com/VictoriaMetrics/VictoriaMetrics/issues/6943 .