elastic / kibana

Your window into the Elastic Stack
https://www.elastic.co/products/kibana
Other
19.62k stars 8.22k forks source link

[Unified histogram][ES|QL] Extra fetches in specific scenarios #165192

Open stratoula opened 1 year ago

stratoula commented 1 year ago

Describe the feature: For some reason when we enabled EQSL in Discover the esql request is sent 4 times (instead of 2) when opening a saved search https://github.com/elastic/kibana/pull/146971#discussion_r1308475929

In all other cases it works as expected. I tried to understand what is going on but I can't, possibly because I am not very comfortable with the unified histogram case.

It will be cool to investigate and understand what is going on here.

Other cases with extra fetches are:

elasticmachine commented 1 year ago

Pinging @elastic/kibana-data-discovery (Team:DataDiscovery)

jughosta commented 11 months ago

Hi @stratoula,

Can you please check if there are less requests with https://github.com/elastic/kibana/pull/171638 ? I think it's because of the logic in src/plugins/unified_histogram/public/chart/hooks/use_total_hits.ts which I am changing in that PR but would like to verify.

If it works, I can create another PR for backporting.

jughosta commented 11 months ago

Okay, created a smaller PR https://github.com/elastic/kibana/pull/172880 just for this issue.

stratoula commented 10 months ago

@jughosta I totally missed the mention 🙈 I am reviewing the first PR now!

stratoula commented 10 months ago

I can't reproduce the first 2 with this PR 🙌

jughosta commented 6 months ago

An update here:

Apparently request count e2e tests for ES|QL were deleted at some point and we are not testing it right now. I tried to restore the tests but they are quite flaky https://github.com/elastic/kibana/pull/181184

The main problem is that now the text based editor also triggers esql requests (for fields autocomplete) and this operation is unpredictable (sometimes several requests, sometimes none). I could not find a solution yet to isolate discover requests (chart + table) in e2e tests from the editor requests so it could be actually tested in a more controlled way.

Besides that, here are various types of fetches the Discover page makes:

Screenshot 2024-04-24 at 16 47 57 Screenshot 2024-04-24 at 16 28 58

The embeddable requests are particularly interesting because they are triggered by different app logic so there could be some concurrent triggers:

Screenshot 2024-04-24 at 16 47 32 Screenshot 2024-04-24 at 16 27 31 Screenshot 2024-04-24 at 16 25 38

Once I even caught that for ES|QL query with stats, the embeddable made a separate request although we passed the prefetched data from Discover via table prop to actually avoid extra requests: Screenshot 2024-04-11 at 11 31 48 Screenshot 2024-04-11 at 11 32 59