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

[Infra UI] Provide routes for accessing pre-filtered log views #23246

Conversation

weltenwort
Copy link
Member

@weltenwort weltenwort commented Sep 17, 2018

This PR introduces a set of routes that can be used as stable entry points into the infra ui with partly pre-populated stated (e.g. filters and time):

  • app/infra/#/link-to/container-logs/:containerId[?time=${TIMESTAMP}]
  • app/infra/#/link-to/host-logs/:hostname[?time=${TIMESTAMP}]
  • app/infra/#/link-to/pod-logs/:podId[?time=${TIMESTAMP}]

It also fixes the links from the waffle map to the logging ui to result in an appropriately filtered view.

A follow-up PR will add uiExports to make similar factory functions available to other Kibana plugins.

Notes and Limitations

  • The current implementation of the <Node> component does not know its own true type, which is hard-coded to host. The url generation should already work for container and pod types as well, though. So once the <Node> is fixed in that regard, appropriate urls would be generated.
  • The redirection logic might seem a bit more complex than immediately required. It is written such that it supports future linking from outside the infra ui. That means that the exact field names to filter by for various node types are not known in advance. To accommodate that fact, the intermediate routes first resolve the configured sources before redirecting to the final URLs with pre-populated state (as per [Infra UI] Selectively persist UI state in the url (via container components) #22980). This also allows for the urls to act as stable external APIs while leaving us free to change state structure or the way it is represented in the URL.

@weltenwort weltenwort added WIP Work in progress :Ingest UI Feature:Metrics UI Metrics UI feature loe:medium Medium Level of Effort labels Sep 17, 2018
@weltenwort weltenwort self-assigned this Sep 17, 2018
@weltenwort weltenwort changed the title [Infra UI] [WIP] [needs rebase] Provide entry points for pre-filtered logs [Infra UI] [WIP] [needs rebase] Provide routes for accessing pre-filtered log views Sep 17, 2018
@weltenwort weltenwort changed the title [Infra UI] [WIP] [needs rebase] Provide routes for accessing pre-filtered log views [Infra UI] [needs rebase] Provide routes for accessing pre-filtered log views Sep 17, 2018
@weltenwort weltenwort added review and removed WIP Work in progress labels Sep 17, 2018
@weltenwort weltenwort requested a review from skh September 17, 2018 19:46
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@elasticmachine
Copy link
Contributor

💔 Build Failed

@weltenwort
Copy link
Member Author

looks like a failure during test setup. jenkins, test this again

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@elasticmachine
Copy link
Contributor

💔 Build Failed

@weltenwort
Copy link
Member Author

flaky reporting test - jenkins, test this

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@weltenwort weltenwort force-pushed the infra-ui-enhancement-url-factory branch from 68a1558 to 50ae47e Compare September 18, 2018 17:18
@weltenwort weltenwort changed the title [Infra UI] [needs rebase] Provide routes for accessing pre-filtered log views [Infra UI] Provide routes for accessing pre-filtered log views Sep 18, 2018
@weltenwort
Copy link
Member Author

@skh I rebased this on the feature branch

@elasticmachine
Copy link
Contributor

💔 Build Failed

@weltenwort
Copy link
Member Author

flaky reporting test - jenkins, test this again

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@skh
Copy link
Contributor

skh commented Sep 19, 2018

Can you elaborate how the timestamp value passed in through the link is used?

When I use the URL path app/infra/#/link-to/container-logs/carlos_metricbeat_1?time=1537302288116 the resulting graphql query uses start: 1537172688116, end: 1537431888116. The URL after redirect uses the timestamp 1537302309387 in the position argument. I'm not sure I understand what's happening there.

@skh
Copy link
Contributor

skh commented Sep 19, 2018

I have tested with the following URL paths:

app/infra/#/link-to/container-logs/carlos_metricbeat_1?time=1537302288116
app/infra/#/link-to/container-logs/carlos_metricbeat_1

app/infra/#/link-to/host-logs/demo-stack-apache-01?time=1537302288116
app/infra/#/link-to/host-logs/demo-stack-apache-01

app/infra/#/link-to/pod-logs/kube-dns-5dcfcbf5fb-h6j25?time=1537302288116
app/infra/#/link-to/pod-logs/kube-dns-5dcfcbf5fb-h6j25

They behave as expected.

Copy link
Contributor

@skh skh left a comment

Choose a reason for hiding this comment

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

Looks good 👍

@weltenwort
Copy link
Member Author

weltenwort commented Sep 19, 2018

@skh What you are observing there is the result of the asymmetry between what the position being read from the URL is interpreted as and what is being written to the url under that key:

(TL;DR: It's being read as the "desired position" and written as the reported visible position.)

  1. A change of (or initialization with) a valid position value causes the xpack/infra/local/log_position/JUMP_TO_TARGET_POSITION action the dispatched.
  2. The remote/log_entries and remote/log_summary epics react to that by fetching the log entries and summary buckets surrounding that point in time.
  3. The text stream and minimap render those fetched data and report the visible intervals (using xpack/infra/local/log_position/REPORT_VISIBLE_POSITION in the case of the text stream).
  4. Those newly reported time key of the "middle visible entry on screen" is then written back to the position search param in the URL.

If, after this sequence of events, the position URL param is different from what was initially passed, that means that no log entry matched the timestamp directly. Instead the position of closest log entry that could be found is written back.

I suspect the request with start and end you mention is the log_summary request that covers an interval centered on the reported middle text stream time key (with some overscan on both sides).

I hope that was somewhat helpful. Let me know if I should try harder to explain. 😉

@skh
Copy link
Contributor

skh commented Sep 20, 2018

I hope that was somewhat helpful. Let me know if I should try harder to explain.

Indeed it was, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Metrics UI Metrics UI feature loe:medium Medium Level of Effort review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants