VictoriaMetrics / victorialogs-datasource

Grafana datasource for VictoriaLogs
Apache License 2.0
96 stars 5 forks source link

top pipe not supported in pie chart #126

Open tiny-pangolin opened 4 days ago

tiny-pangolin commented 4 days ago

Dashboard visualizations fail with a 422 error when using the top pipe to limit the amount of values even using a stats before the top pipe. Currently the workaround is to let Grafana limit the number of results shown to the user.

example of a query that returns an error:

 _time:1h AND tags.appname:traefik AND tags.host:$host | unpack_json | stats by(RequestPath) count()  | top 20

fixed query:

 _time:1h AND tags.appname:traefik AND tags.host:$host | unpack_json | stats by(RequestPath) count() 
dmitryk-dk commented 1 day ago

Hi @tiny-pangolin ! The pie charts, by default, use stats query type, and in this case, the query goes through stats API. In the stats API, we can't use the top command.

{\"status\":\"error\",\"errorType\":\"422\",\"error\":\"the \\\"top 2\\\" pipe cannot be put after \\\"stats by (_time:20s) count(*) as \\\\\\\"count\\\\\\\"\\\" pipe in the query [* | stats by (_time:20s) count(*) as \\\"count\\\" | top 2]\"}"

I think this issue will be fixed when we implement the switch with different query types for different types of panels. Please check this issue.