Skip to content

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

Open
@BenB196

Description

@BenB196

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions