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

[Monitoring] Ensure all charts use the configured timezone #45949

Merged
merged 7 commits into from
Oct 2, 2019

Conversation

chrisronline
Copy link
Contributor

@chrisronline chrisronline commented Sep 17, 2019

Resolves #29010

This PR ensures all monitoring charts respect the configured time zone.

TODO

  • Use a simpler way to fetch uiSettings -> await request.getUiSettingsService().get('dateFormat:tz')

Testing

  1. Load up Kibana with monitoring enabled
  2. Go to Kibana Management -> Advanced Settings
  3. Change the dateFormat:tz to something other than Browser
  4. Go to the monitoring UI and ensure all charts x-axis respects the configured timezone

@elasticmachine
Copy link
Contributor

Pinging @elastic/stack-monitoring

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@cachedout
Copy link
Contributor

I cannot get this fix to work. No matter what time zone I set Kibana to, I see the same times shown in the X-axis on Stack Monitoring charts. Happy to Zoom to show you what I'm seeing if it helps.

@ycombinator
Copy link
Contributor

With this PR, no matter what time zone I set in Kibana Advanced Settings (browser, America/New_York, etc.), all monitoring charts always displayed times on the x-axis in UTC.

For comparison, on master, no matter what time zone I set in Kibana Advanced Settings (browser, America/New_York, etc.), all monitoring charts always displayed times on the x-axis in my browser's time zone.

@chrisronline
Copy link
Contributor Author

Okay thanks for the time and feedback all!

I went back to the drawing board and think we have a better solution.

At a high level, we are fetching the data from ES in the same fashion as before, which is in UTC timestamps. Once we receive the data back, we are offsetting the UTC timestamps based on the dateFormat:tz configured timezone (which is what the flot docs recommend). Then, we are passing down the offsetted UTC timestamps back to the client and telling the client that they are UTC timestamps (so nothing on the client attempts to format or convert to the browser timezone). As a result, if you are looking some chart for a certain time period, changing dateFormat:tz will only change the numbers on the x-axis - the data will remain the same.

This should work fine, but it's a significant change that might require messaging somehow. We might also need to give support a heads up in case issues/questions arise as a result from this.

Let's start a conversation here about this and figure out our exact approach moving forward. I'm going to CC some parties that might have some thoughts, or historical reasons why this change hasn't been done in the past.

cc @pickypg @skearns64

@pickypg
Copy link
Member

pickypg commented Sep 20, 2019

I can't think of any reason why we wouldn't honor the setting. For a long time, Monitoring did not touch Kibana Advanced Settings though, so historically that's probably the reason.

Just wanted to add one thing to the review: make sure shared links where the time picker is used for something other than now-1h type searches, that it honors the timezone properly (doesn't shift).

@elasticmachine
Copy link
Contributor

💔 Build Failed

@igoristic
Copy link
Contributor

igoristic commented Sep 23, 2019

@chrisronline
I think date-picker's "from date/time" and "to date/time" should always match the chart's x values (timestamps). The only thing that should change is the data shift in the chart (based on the offset). For example if I pick a range from 1pm to 9pm and there is a single peek value at 5pm(utc) the chart should still show something like:

|          *           |
|                      |
|1pm ..... 5pm .... 9pm|

Now with a -4h timezone offset:

| *                    |
|                      |
|1pm ..... 5pm .... 9pm|

@chrisronline
Copy link
Contributor Author

@igoristic

This is what I'm seeing with this PR:

  1. Set dateFormat:tz to UTC
  2. Set the timeframe from 1pm - 5pm in a stack monitoring page with charts
  3. Note the url will look like: http://localhost:5601/app/monitoring#/elasticsearch?_g=(cluster_uuid:xk61MITwT2qYsjx0A4kFeQ,refreshInterval:(pause:!f,value:10000),time:(from:'Tue Sep 24 2019 13:00:00 GMT+0000',to:'Tue Sep 24 2019 21:00:00 GMT+0000'))
  4. Note the x-axis window is 13:00 - 21:00
  5. Change the dateFormat:tz to US/Pacific
  6. Refresh the stack monitoring page
  7. Observe that the url is: http://localhost:5601/app/monitoring#/elasticsearch?_g=(cluster_uuid:xk61MITwT2qYsjx0A4kFeQ,refreshInterval:(pause:!f,value:10000),time:(from:'Tue Sep 24 2019 13:00:00 GMT+0000',to:'Tue Sep 24 2019 21:00:00 GMT+0000')) (Which is unchanged)
  8. Now the chart x-axis window is 6:00 - 14:00
  9. The data shows up in the same place on the graph

I'm not sure what you're suggesting here. Are you suggesting this behavior isn't ideal? Maybe that in step 8, the x-axis window should remain unchanged and still show 13:00 - 21:00?

@igoristic
Copy link
Contributor

@chrisronline

Maybe that in step 8, the x-axis window should remain unchanged and still show 13:00 - 21:00

Exactly. This way we always maintain the from and to labels and it's 1:1 with the top right date-picker. I think only the values/data should shift left/right, and fall into their respective offset buckets instead of the timestamps changing.

@chrisronline
Copy link
Contributor Author

Exactly. This way we always maintain the from and to labels and it's 1:1 with the top right date-picker. I think only the values/data should shift left/right, and fall into their respective offset buckets instead of the timestamps changing.

I'm looking at other parts of Kibana and I'm seeing the behavior I described in this comment, notably, visualize. I'm assuming other parts of Kibana also follow this behavior, but happy to see examples if you know any.

Assuming this isn't deviating from the rest of Kibana, I think we should continue with how it works right now and we can open a ticket/discussion about possibly changing it and the implications that might have. WDYT?

@igoristic
Copy link
Contributor

@chrisronline

The behavior I'm trying to convey is actually very similar to Visualize and Discover.

Notice how the chart's timespan labels are always in sync with the top-right time-range picker (no matter the timezone). So, the url should always contain the UTC while the time-range and chart x labels should both have the timezone's relative offset

Screen Shot 2019-09-24 at 5 07 15 PM

Screen Shot 2019-09-24 at 5 15 33 PM

@chrisronline
Copy link
Contributor Author

@igoristic Are you not seeing this behavior in the PR? I'm seeing it work the way you're describing. Can you maybe include screenshots of the monitoring UI with specifics about what you're seeing?

@igoristic
Copy link
Contributor

@chrisronline

Sorry about the confusion. I guess I only tested browser timezone and didn't reset the link for other timezone tests which skewed my results. Here is a miss-match with the Browser timezone:
Screen Shot 2019-09-25 at 4 55 35 PM
As you can see the chart's labels are actually in UTC (if compared to timestamps in URL)

Also, another thing I noticed is that zooming (via scrub) is now broken since the selected range is the offset, but we're sending those same values as UTC

@chrisronline
Copy link
Contributor Author

@igoristic Solid catch! Fixed up now and ready for another round.

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Copy link
Contributor

@igoristic igoristic left a comment

Choose a reason for hiding this comment

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

Working as expected. Great job!

Copy link
Contributor

@ycombinator ycombinator left a comment

Choose a reason for hiding this comment

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

@chrisronline Functionality LGTM but I see there's a TODO in the PR description. Please let me know when you've resolved it and I'll re-review this PR. Thanks.

@chrisronline
Copy link
Contributor Author

@ycombinator Thanks for the reminder. This is done in 20a9d16

Copy link
Contributor

@ycombinator ycombinator left a comment

Choose a reason for hiding this comment

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

LGTM.

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@chrisronline chrisronline merged commit 3f7c3e0 into elastic:master Oct 2, 2019
@chrisronline chrisronline deleted the monitoring/timezones branch October 2, 2019 16:43
chrisronline added a commit to chrisronline/kibana that referenced this pull request Oct 2, 2019
…5949)

* Consistently apply dateFormat:tz to all monitoring time-series data

* Ensure browser timezone works properly

* Fix tests

* Fix other test

* Simplfy timezone fetching

* Fix tests
chrisronline added a commit to chrisronline/kibana that referenced this pull request Oct 2, 2019
…5949)

* Consistently apply dateFormat:tz to all monitoring time-series data

* Ensure browser timezone works properly

* Fix tests

* Fix other test

* Simplfy timezone fetching

* Fix tests
chrisronline added a commit that referenced this pull request Oct 2, 2019
…47137)

* Consistently apply dateFormat:tz to all monitoring time-series data

* Ensure browser timezone works properly

* Fix tests

* Fix other test

* Simplfy timezone fetching

* Fix tests
chrisronline added a commit that referenced this pull request Oct 2, 2019
…47138)

* Consistently apply dateFormat:tz to all monitoring time-series data

* Ensure browser timezone works properly

* Fix tests

* Fix other test

* Simplfy timezone fetching

* Fix tests
@chrisronline
Copy link
Contributor Author

Backport:

7.x: 46e6424
7.4: 953e76b

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[monitoring] X-axis is not honoring dateFormat:tz
6 participants