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

[7.5] [Discover] fix histogram min interval #52758

Merged

Conversation

markov00
Copy link
Member

@markov00 markov00 commented Dec 11, 2019

Summary

This commit fix the missing bars on the histogram of Discover.
Discover is passing a minInterval parameter in milliseconds that is not
the the minimum interval in milliseconds between the buckets. Calendar intervals
are not fixed and this value change depending on time range and the time zone.
To avoid patching the elastic-chart and upgrading the dependency we applied a temporary patch
to the histogram code. For the feature version this patch will be removed
and a correct minInterval computation will be done directly in elastic-charts.

fix #52152

to test:
add some data that spans multiple years (possibly leap years, last one was 2016)

node scripts/makelogs.js -c 1m -d 2200/1
// or import the esArchived dataset
node scripts/es_archiver.js --es-url elastic:changeme@localhost:9275 --kibana-url http://elastic:changeme@localhost:5675 load long_window_logstash

create the index pattern for that index: logstash-* or long_window_logstash*
check the behaviour on histogram when the timerange spans several years (including leap years) with different interval configuration. The issue is visible when:

  • visualizing a timerange with monthly intervals that contains data in the February bucket
    timezone: all
    time range: Nov 1, 2017 @ 01:00:00.000 - Mar 21, 2018 @ 02:00:00.000
    intervals: Monthly

  • visualizing a timerange with a DST time change within the range. The DST change needs to be a positive change like when the time is moved forward (= that day last less than 24 hours) like in the following situation:
    timezone: Europe/Berlin (doesn't happen with UTC timezone)
    time range: Mar 1, 2018 @ 00:00:00.000 - May 1, 2018 @ 00:00:00.000
    intervals: all except Monthly and Yearly

  • visualizing a timerange with a DST time change with auto interval on a fixed/multi days interval:
    timezone: Europe/Berlin
    time range: Last 15 years - now
    intervals: every interval smaller than month (be sure that the scaled interval is scaled to 30days)

Checklist

Use strikethroughs to remove checklist items you don't feel are applicable to this PR.

For maintainers

@markov00 markov00 added bug Fixes for quality problems that affect the customer experience release_note:fix v8.0.0 v7.6.0 v7.5.1 labels Dec 11, 2019
@markov00 markov00 requested a review from a team as a code owner December 11, 2019 15:28
Copy link
Contributor

@nickofthyme nickofthyme left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, Tested on Firefox and Chrome

Screen Recording 2019-12-11 at 02 35 PM

This commit fix the missing bars on the histogram of Discover.
Discover is passing a minInterval parameter in milliseconds that is not
the the minimum interval in milliseconds between the buckets. Calendar intervals
are not fixed and this value change depending on time range and the time zone.
To avoid patching the elastic-chart and upgrading the dependency we applied a temporary patch
to the histogram code. For the feature version this patch will be removed
and a correct minInterval computation will be done directly in elastic-charts.

fix elastic#52152
@markov00 markov00 force-pushed the 2019-12-11_fix-discover-histogram-min-interval branch from d473816 to e614953 Compare December 11, 2019 22:53
@markov00 markov00 requested review from a team as code owners December 11, 2019 22:53
@markov00 markov00 requested a review from a team December 11, 2019 22:54
@markov00 markov00 changed the base branch from master to 7.5 December 11, 2019 22:54
@markov00 markov00 changed the title [Discover] fix histogram min interval [7.5] [Discover] fix histogram min interval Dec 11, 2019
@jbudz jbudz requested review from a team and removed request for a team December 11, 2019 23:33
Copy link
Member

@kertal kertal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just tested it, and while the issue is solved in the suggested tests, there seems to be a problem with very long time ranges
Bildschirmfoto 2019-12-12 um 14 44 35

@markov00
Copy link
Member Author

markov00 commented Dec 12, 2019

@kertal thanks for the check let me see if this is related to this other ES bug just discovered: elastic/elasticsearch#50139

@markov00
Copy link
Member Author

I can confirm that I can reproduce the @kertal reported error. It's related to the discovered bug elastic/elasticsearch#50139: when using fixed_interval the returning set of buckets are not all equally distant but they differs. a 30d fixed interval could return a 30d -1h or a 30+1h intervals.... Let me find an way to fix the Discover histogram avoiding that bug

@LeeDr LeeDr added the blocker label Dec 12, 2019
@kertal
Copy link
Member

kertal commented Dec 12, 2019

Issue I've reported was saved 👍
I may have found another one, when I'm defining a very short time range for e.g. 2 sec, I'm getting an ES error

Bildschirmfoto 2019-12-12 um 17 54 52

this is the request sent to ES:

{
  "version": true,
  "size": 500,
  "sort": [
    {
      "@timestamp": {
        "order": "desc",
        "unmapped_type": "boolean"
      }
    }
  ],
  "_source": {
    "excludes": []
  },
  "aggs": {
    "2": {
      "date_histogram": {
        "field": "@timestamp",
        "fixed_interval": "40ms",
        "time_zone": "US/Arizona",
        "min_doc_count": 1
      }
    }
  },
  "stored_fields": [
    "*"
  ],
  "script_fields": {},
  "docvalue_fields": [
    {
      "field": "@timestamp",
      "format": "date_time"
    },
    {
      "field": "relatedContent.article:modified_time",
      "format": "date_time"
    },
    {
      "field": "relatedContent.article:published_time",
      "format": "date_time"
    },
    {
      "field": "utc_time",
      "format": "date_time"
    }
  ],
  "query": {
    "bool": {
      "must": [],
      "filter": [
        {
          "match_all": {}
        },
        {
          "range": {
            "@timestamp": {
              "format": "strict_date_optional_time",
              "gte": "2019-10-01T03:37:57.890Z",
              "lte": "2019-10-01T03:37:59.890Z"
            }
          }
        }
      ],
      "should": [],
      "must_not": []
    }
  },
  "highlight": {
    "pre_tags": [
      "@kibana-highlighted-field@"
    ],
    "post_tags": [
      "@/kibana-highlighted-field@"
    ],
    "fields": {
      "*": {}
    },
    "fragment_size": 2147483647
  }
}

@markov00
Copy link
Member Author

@kertal that seems to an ES issue with some time_zones.
If you query an index with that timezone or with some similar one

GET logstash-*/_search
{
  "aggs": {
    "2": {
      "date_histogram": {
        "field": "@timestamp",
        "fixed_interval": "1ms",
        "time_zone": "America/Phoenix",
        "min_doc_count": 1
      }
    }
  }
}

you will get the same error. With other timezones it doesn't happen

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@kertal kertal self-requested a review December 12, 2019 17:59
Copy link
Member

@kertal kertal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code LGTM, Issue is now solve. The latest error I've found is unrelated to this issue, but a separate issue should be opened. appreciate if someone takes care of this, since I'm OOO, but else I can do this tomorrow

@markov00 markov00 merged commit d21d969 into elastic:7.5 Dec 12, 2019
@rayafratkina rayafratkina added Feature:Discover Discover Application Team:Visualizations Visualization editors, elastic-charts and infrastructure labels Dec 13, 2019
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app (Team:KibanaApp)

KOTungseth added a commit to KOTungseth/kibana that referenced this pull request Dec 16, 2019
KOTungseth added a commit that referenced this pull request Dec 16, 2019
* [DOCS} 7.5.1 Release Nottes

* Changed Visualizations heading and added #52758
@kertal
Copy link
Member

kertal commented Dec 17, 2019

@kertal that seems to an ES issue with some time_zones.
If you query an index with that timezone or with some similar one

GET logstash-*/_search
{
  "aggs": {
    "2": {
      "date_histogram": {
        "field": "@timestamp",
        "fixed_interval": "1ms",
        "time_zone": "America/Phoenix",
        "min_doc_count": 1
      }
    }
  }
}

you will get the same error. With other timezones it doesn't happen

thx I've opened the following issue : elastic/elasticsearch#50265

KOTungseth added a commit to KOTungseth/kibana that referenced this pull request Dec 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocker bug Fixes for quality problems that affect the customer experience Feature:Discover Discover Application release_note:fix Team:Visualizations Visualization editors, elastic-charts and infrastructure v7.5.1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants