-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Discover] Add a default "All logs" temporary data view in the Observability Solution view #205991
[Discover] Add a default "All logs" temporary data view in the Observability Solution view #205991
Conversation
913f96f
to
4fbccf0
Compare
666f98e
to
58862da
Compare
getDefaultAdHocDataViews
extension16a7682
to
8e2e630
Compare
Flaky Test Runner Stats🎉 All tests passed! - kibana-flaky-test-suite-runner#7771[✅] test/functional/apps/discover/context_awareness/config.ts: 25/25 tests passed. |
@@ -91,7 +94,7 @@ export interface DiscoverSavedSearchContainer { | |||
* @param id | |||
* @param dataView | |||
*/ | |||
load: (id: string, dataView?: DataView) => Promise<SavedSearch>; | |||
load: (id: string) => Promise<SavedSearch>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The dataView
param didn't seem to be referenced anywhere in code, so I removed it.
// This can happen when default profile data views are created without fields | ||
// to avoid unnecessary requests on startup. | ||
if (!nextDataView.isPersisted() && !nextDataView.fields.length) { | ||
await dataViews.refreshFields(nextDataView); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm doing this in two separate places and I don't like it, but the alternative seems to be loading all fields up front when the data views are initialized, which would be worse. There are better ways to address this, but it would require refactoring how we handle InternalState.adHocDataViews
, which I wanted to avoid in this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While working in this file, I found the logic hard to follow, and there was some dead code for things that have since changed, so I refactored it some. I feel like it's a bit easier to follow now, but I can revert all but necessary changes if there are concerns.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While working on the extension point, adding an "All logs" data view was easy and helpful for testing, so I figured I might as well just include it with the PR. But the Logs UX team can make whatever changes they'd like to it (feel free to push to the branch), since I wasn't sure exactly how the implementation should work and just made some guesses.
9d699e8
to
751f366
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the changes!
const props: MainRouteProps = { | ||
customizationCallbacks: [], | ||
customizationContext: mockCustomizationContext, | ||
}; | ||
|
||
return mountWithIntl( | ||
<MemoryRouter> | ||
<KibanaContextProvider services={getServicesMock(hasESData, hasUserDataView)}> | ||
<KibanaContextProvider services={getServicesMock(hasESData, hasUserDataView, locationState)}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we want the Discover URL with "All logs" to be remembered in session storage for restoring when user presses Discover in the Kibana main nav, we could extend this logic:
kibana/src/platform/plugins/shared/discover/public/application/main/hooks/use_url_tracking.ts
Lines 27 to 33 in bb877cf
const trackingEnabled = | |
// Disable for ad-hoc data views as it can't be restored after a page refresh | |
Boolean(dataView.isPersisted() || savedSearch.id) || | |
// Enable for ES|QL, although it uses ad-hoc data views | |
isOfAggregateQueryType(savedSearch.searchSource.getField('query')); | |
urlTracker.setTrackingEnabled(trackingEnabled); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! I think it makes sense to support that. Updated and added tests here: 991548e.
import { i18n } from '@kbn/i18n'; | ||
import type { ObservabilityRootProfileProvider } from '../types'; | ||
|
||
const ALL_LOGS_DATA_VIEW_ID = 'discover-observability-root-profile-all-logs'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this id is a part of Discover URL now, can we add a test that nobody renames it? Otherwise, saved bookmarks would break.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had some tests for the profile that would catch if this changed, but a dedicated test explaining why is a good idea. Added here: 7306fc1.
name: i18n.translate('discover.savedSearch.defaultProfileDataViewCopyName', { | ||
defaultMessage: '{name} (copy)', | ||
values: { name: dataView.name ?? dataView.getIndexPattern() }, | ||
}), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unified Search managed data views addition LGTM! Code review only, but everything makes sense!
💛 Build succeeded, but was flaky
Failed CI StepsTest FailuresMetrics [docs]Module Count
Public APIs missing comments
Async chunks
Page load bundle
Unknown metric groupsAPI count
ESLint disabled line counts
Total ESLint disabled count
History
cc @davismcphee |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All looking good but I've got a question on how we can link to this data view from within Observability since this temporary data view is not guaranteed to be there (only when solution view is enabled)
The issue I'm seeing is the following:
To link to this new All Logs managed data view we can do the following:
discoverAppLocator.getLocation({
dataViewId: 'discover-observability-root-profile-all-logs'
})
This works as long as the solution view is set but in classic mode these links would break.
Alternatively we could specify both dataViewId
and dataViewSpec
but that would cause the dataViewId
to be ignored:
discoverAppLocator.getLocation({
dataViewId: 'discover-observability-root-profile-all-logs', // Is ignored when `dataViewSpec` is set
dataViewSpec: { title: 'logs-*,...' }
})
And if we only specify our own dataViewSpec
in the locator then we have the issue that Discover would display both the managed "All logs" data view and our own "All logs" temporary data view that was defined in the locator making for a confusing UX.
Can we either get a guarantee that when we link to one of these managed data views using dataViewId
that they will be present irregardless of whether we are in a solution view or alternatively have a way of defining in fallback in the discover locator?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changes to unified search LGTM
@thomheymann Thanks for the review, and I get the concern. I don't think we can guarantee that passing just the ID will work across any solution view since the profile that generates it is linked to the O11y solution view. I'm also not sure the Security or Search solutions use the central log sources setting currently. That said, there are still a couple of ways to do what you're asking:
|
Thanks @davismcphee! I'm not completely convinced by these options. Feedback below:
The main issue with this approach is that we're not actually checking whether Discover knows about the data view we want to link to or not but are simply using the solution view setting as a proxy for that. This could cause bugs when that logic changes inside Discover without us knowing.
We could do this as a workaround but I'm not sure if this is a great user experience. It could be confusing for users when the "All Logs" data view keeps changing from managed to temporary. This might also impact the sort order in the dropdown which we should try to avoid. @davismcphee When solution view is set to classic then Kibana shows all 3 solutions in the navigation. Doesn't that imply that Discover should also support the data views each solution defines? What's the concern with making these available in classic mode? |
This is true, but I think it's ok for other apps to know about Discover's behaviour without having to explicitly check each time. This functionality is part of Discover's public contract now and has to be maintained for users who will rely on it, so it's similar to using any other API that defines some behaviour. The logic should not change in Discover without a consumer knowing, and the way to validate that is with proper automated testing (which we've added).
It shouldn't keep changing from managed to temporary on users, it only changes between solution views which reflects the implementation -- it's only actually managed in O11y solution and not others where it is actually a temporary data view that's been passed through the link to Discover. The sort order of data views in the picker is alphabetical by name, so this should not have an impact.
No, it doesn't -- at least not with how this work was defined, which was specific to the O11y solution view. The concern with me unilaterally deciding to add it to the common Discover experience is that other solution views would get a default data view called "All logs" which is linked to an O11y specific setting, which they may not want. The Discover architecture allows us to move this to a common profile in the future and make it available across all solution views + classic without a breaking change, but it's a product decision I'm not in a position to make alone (especially not on the day of FF) and needs alignment across solutions. I do not think this should be considered a blocker for now, and should be discussed separately in the One Discover sync to align if O11y thinks this should be included for all solution views + classic. |
Starting backport for target branches: 8.x |
💔 All backports failed
Manual backportTo create the backport manually run:
Questions ?Please refer to the Backport tool documentation |
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
Summary
This PR adds an "All logs" ad hoc (temporary) data view to the Discover Observability root profile based on the central log sources setting, allowing quick access to logs (with the most up to date log sources) without needing to first manually create a data view:
To support this, a new
getDefaultAdHocDataViews
extension point has been added to Discover, allowing profiles to specify an array of ad hoc data view specs would should be created by default when the profile is resolved, and automatically cleaned up when the profile changes or the user leaves Discover.Resolves #201669.
Resolves #189166.
Notes
getDefaultAdHocDataViews
must include consistent IDs across resolutions in order for Discover to manage them correctly (e.g. to find and reload the data view after a page refresh). Situations where we'd expect a change in ID (e.g. when saving to a Discover session) are handled internally by Discover.getDefaultAdHocDataViews
will be used as the default.{DATA_VIEW_NAME} (copy)
. This allows us to assign a unique ID to the version that gets saved with the Discover session, and avoids having to choose between the profile data view or the embedded data view when reopening the session, which has drawbacks:Checklist
release_note:breaking
label should be applied in these situations.release_note:*
label is applied per the guidelines