elastic / kibana

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

[Agg-Based] Fill missing values setting seems to not be applied #186640

Open dej611 opened 3 weeks ago

dej611 commented 3 weeks ago

Describe the bug:

No matter what's the missing value setting chosen on the UI, the tool seems to only apply the Linear one.

Take this visualization with missing values to zero setting:

Screenshot 2024-06-21 at 17 37 48

Same chart in Lens

Screenshot 2024-06-21 at 17 37 55
elasticmachine commented 3 weeks ago

Pinging @elastic/kibana-visualizations (Team:Visualizations)

nickofthyme commented 3 weeks ago

The chart fitting requires the full data to be passed, including null buckets, in order to fill the null buckets given the fitting function.

In the case of the aggs_based chart, we are sending the request with min_doc_count set to 1, thus filtering all null/empty buckets given the time interval. We are not defining min_doc_count is the Lens request.

{
  "aggs": {
    "2": {
      "date_histogram": {
        "field": "timestamp",
        "calendar_interval": "1m",
        "time_zone": "America/Phoenix",
        "min_doc_count": 1
      }
    }
  },
...

If we add the min_doc_count: controls.MinDocCountParamEditor option here...

https://github.com/elastic/kibana/blob/9009cb8cf2f2719604232a4cdc75061bf94b89af/src/plugins/vis_default_editor/public/components/agg_params_map.ts#L16-L20

...I get the Show empty buckets option, which if I disable that switch (seems opposite based on the wording but whatever), then I get all the buckets in that date range and the fitting functions work as expected.

Zight Recording 2024-06-24 at 12 38 17 PM

Note, this is not the case with the count aggregation as Elasticsearch will return 0 instead of null preventing the fitting of the values.