Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

top pipe not supported in pie chart #126

Open
tiny-pangolin opened this issue Nov 29, 2024 · 7 comments
Open

top pipe not supported in pie chart #126

tiny-pangolin opened this issue Nov 29, 2024 · 7 comments
Assignees
Labels
bug Something isn't working

Comments

@tiny-pangolin
Copy link
Contributor

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() 
@hagen1778 hagen1778 added the bug Something isn't working label Dec 1, 2024
@dmitryk-dk
Copy link
Contributor

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.

@dmitryk-dk
Copy link
Contributor

Hi @tiny-pangolin ! Could you try to build the pie chart with the new version of the plugin?

@tiny-pangolin
Copy link
Contributor Author

I'm now able to use the top pipe in queries, and it behaves as it did before

@tenmozes
Copy link
Contributor

tenmozes commented Dec 4, 2024

i have a similar problem today, i guess the transform is the right option to do fix that

@tiny-pangolin
Copy link
Contributor Author

tiny-pangolin commented Dec 4, 2024

The top pipe only works with the raw query type, but it doesn't work with the instant or range queries. When I run a range query or instant with the top pipe then I receive the following error.

error: the "top 20" pipe cannot be put after "stats by (RequestPath) count(*) as \"count(*)\"" pipe in the query [_time:[1733335485,1733339085] tags.appname:traefik tags.host:armin.local.shiftsystems.net | unpack_json | stats by (RequestPath) count(*) as "count(*)" | top 20]

image

@tenmozes the pie chart will work with the raw query and top pipe with transforms, or using an instant query with no transforms and no top pipe #61 has some examples for transforms

@dmitryk-dk
Copy link
Contributor

At that moment, the only way to build a pie chart is to use transform functions and raw queries. Because the VLogs don't support the pipe when we are using stats queries. Maybe we need to update the logic on VL side.
Why should we use transform? - A pie chart needs numbers to render the pipe, but logs return something like
{"count": "123", "hits": "1"} etc.

@tiny-pangolin
Copy link
Contributor Author

At that moment, the only way to build a pie chart is to use transform functions and raw queries.

As of 0.10.0 the plugin supports 3 types of query raw, range, and instant, and a pie chart can be made with 0 transforms using an instant query, but the top isn't supported as seen in my previous screenshot. If you need to use the top pipe in your query right now, it requires using a raw query plus transforms

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants