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

[ES|QL] When using BUCKET not in conjunction with SORT "weird" things happen #122858

Open
BenB196 opened this issue Feb 18, 2025 · 4 comments
Open
Labels
:Analytics/ES|QL AKA ESQL >bug Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo)

Comments

@BenB196
Copy link

BenB196 commented Feb 18, 2025

Elasticsearch Version

8.17.1

Installed Plugins

No response

Java Version

bundled

OS Version

Docker

Problem Description

(Disclaimer, I'm not 100% sure if this is a problem with ES|QL or with how Kibana handles the data returned by ES|QL)

When running a query, and using the BUCKET function over a timestamp, if SORT is not applied to the timestamp, data/graphs become inconsistent

Steps to Reproduce

  1. Run the following ES|QL query
FROM metrics-system.cpu-*
| STATS AVG(system.cpu.total.norm.pct) BY time = BUCKET(@timestamp, 30 seconds)

Note: I recommend using a "wide" time range (48 hours) seems to reproduce regularly

Observe that it will get graphed/visualized in "weird" ways:

Image

Image

Image

  1. Run the same query, but add a SORT at the end
FROM metrics-system.cpu-*
| STATS AVG(system.cpu.total.norm.pct) BY time = BUCKET(@timestamp, 30 seconds)
| SORT time

Observe that the data will now graph/visualize correctly/consistently

Image

Logs (if relevant)

No response

@BenB196 BenB196 added >bug needs:triage Requires assignment of a team area label labels Feb 18, 2025
@jozala jozala added the :Analytics/ES|QL AKA ESQL label Feb 18, 2025
@elasticsearchmachine elasticsearchmachine added Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) and removed needs:triage Requires assignment of a team area label labels Feb 18, 2025
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-analytical-engine (Team:Analytics)

@astefan
Copy link
Contributor

astefan commented Feb 19, 2025

Since the description of the issue is exclusively UI related, a first step would be to establish if this is Kibana related or ES|QL related. @stratoula could you please have a look at this report and see if it rings any bells in terms of already fixed issues on the UI side?

@stratoula
Copy link

I think it is related with the limit 1000 which is the default at ES level.

I can also replicate it locally. It is how the data is coming. Check here:

FROM logstash*
  | STATS AVG(bytes) BY time = BUCKET(@timestamp, 30 seconds)
  | SORT time

This results to this:

Image

The max time I get is: Feb 4, 2025 @ 08:41:30.000
and is correctly depicted in the histogram

When I dont sort:

FROM logstash*
 | STATS AVG(bytes) BY time = BUCKET(@timestamp, 30 seconds)
Image

I get max time: Feb 4, 2025 @ 10:26:30.000

and is correctly depicted in the histogram

If I increase the limit (and remove the sort)

FROM logstash*
  | STATS AVG(bytes) BY time = BUCKET(@timestamp, 30 seconds)
 | limit 10000
Image

Max time: Feb 4, 2025 @ 10:26:30.000

and is correctly depicted in the histogram

So my guess is that when you dont sort and you have the limit 1000 some values are missing resulting in a not so accurate histogram. But this is an ES|QL limitation atm. The UI draws the data points it gets

@stratoula
Copy link

stratoula commented Feb 19, 2025

I wonder if it makes sense to return the buckets sorted by default. Ideally we want to increase the limit 1000 too but I understand that atm there are some performance concerns (?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Analytics/ES|QL AKA ESQL >bug Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo)
Projects
None yet
Development

No branches or pull requests

5 participants