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

[ML] Move Index Data Visualizer into separate plugin (Part 1) #100922

Merged
merged 59 commits into from
Jun 8, 2021

Conversation

qn895
Copy link
Member

@qn895 qn895 commented May 28, 2021

Summary

This PR is a follow up of #96408 (comment) and is part of the migration to move the index based Data Visualizer into its own separate plugin. Changes include:

  • Migrate index based files to new plugin
  • Move get_overall_stats and get_field_stats routes and services to internal/data_visualizer
  • Re-organize structure of folders into common, file_data_visualizer, and index_data_visualizer
  • Update types
    • Replace deprecated IIndexPattern with IndexPattern and replace deprecated IFieldType with IndexPatternField
    • Replace RuntimeMappings with estypes.RuntimeFields
  • Add back preview for Boolean type
  • Rename file_data_visualizer → data_visualizer
  • Rename test subjects to no longer include ml prefix
  • Add runtime_mappings support to file_upload/time_field_range

To follow-up in future PR

  • Add back links to ML job creation cards
  • Add back View in Data Visualizer card after file import is successful
  • Move data_loader outside of ML data_visualizer folder

Reviewer tips

  • Kibana Design Team: no styling changes were made, only moving the files inside plugins/ml toplugins/file_data_visualizer
  • QA: some functional tests are commented, to be re-enabled in a follow up PR

Testing the Index Data Visualizer

  • Should work correctly with index pattern and saved search
  • Should work correctly with all controls (e.g. shard sample, field types, show empty fields)
  • Refreshing the page should restore previously set controls and table sorting
  • If user has permission to use Discover, the Discover card should show up in right action panel
  • In this PR, we are not displaying the Anomaly Detection job creation cards or Data Frame Analytics creation card in the right action panel (to be added in a follow up)
  • Clicking View in Lens should navigate to Lens page with previously set query, time range, and prefilled chart for the field
  • Expanding a geo_point or geo_shape field row should show a map with shapes as a layer

Checklist

Delete any items that are not applicable to this PR.

@qn895 qn895 added :ml v8.0.0 release_note:skip Skip the PR/issue when compiling release notes Feature:File and Index Data Viz ML file and index data visualizer labels May 28, 2021
@@ -0,0 +1,6 @@
/*
Copy link
Member

Choose a reason for hiding this comment

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

is this file needed?

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for catching that. Deleted here 76a7b5b

share,
security,
fileUpload,
indexPatternFieldEditor,
Copy link
Member

Choose a reason for hiding this comment

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

it might be worth adding a comment here to say that indexPatternFieldEditor isn't used by the file data visualizer, but we need to add it here as we're sharing a context with the index data visualizer.
At least, that's my assumption as to why it's being added here.
Same for fileUpload in the index data visualizer

Copy link
Member

Choose a reason for hiding this comment

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

It might be better to create a shared component which provides the KibanaContextProvider wrapper. as this code is duplicated across both data visualizers.

Copy link
Member

Choose a reason for hiding this comment

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

it looks like lens should also be added to these lists of services

Copy link
Member Author

@qn895 qn895 Jun 7, 2021

Choose a reason for hiding this comment

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

Thanks for catching that. The indexPatternFieldEditor should not have been in the file data visualizer and have been removed here 76a7b5b. For now the index data visualizer and file data visualizer have different contexts.

Also added lens to the list of services for the index data here visualizer 267d3b7

) => {
core.capabilities.registerProvider(() => {
return {
dataVisualizer: {
Copy link
Member

Choose a reason for hiding this comment

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

i don't think we need this capability at all. as the switcher does not contain any logic, this will aways be true.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point 👍 I removed capabilities registration altogether here b043d6e

@@ -0,0 +1,1385 @@
/*
Copy link
Member

@jgowdyelastic jgowdyelastic Jun 7, 2021

Choose a reason for hiding this comment

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

This file is a bit too big IMO.
This might be a good opportunity to separate out util functions and types to make this more manageable.
Or for a follow up...

Copy link
Member Author

Choose a reason for hiding this comment

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

Split up the model into other files here 403a8e3

body: results,
});
} catch (e) {
logger.warn(e);
Copy link
Member

Choose a reason for hiding this comment

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

This should probably be logger.error
but i'm not sure we should be just throwing the error to the log like this without any context of where it has come from.
As these errors are passed to the client for display, do we even need to add them to the kibana log?

Copy link
Member Author

Choose a reason for hiding this comment

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

Removed logging and Logger here 403a8e3

export class FileDataVisualizerPlugin implements Plugin {
setup() {}
start() {}
export interface StartDeps {
Copy link
Member

Choose a reason for hiding this comment

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

StartDeps should live next to SetupDeps
This file probably isn't needed and StartDeps can be moved to the plugin.ts

Copy link
Member Author

Choose a reason for hiding this comment

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

I think originally StartDeps was in a different types in order avoid circular dependencies because it was also used in server/routes. For now, I moved SetupDeps into the same file for better consistency.


type RuntimeType = typeof RUNTIME_FIELD_TYPES[number];

export const isPopulatedObject = <U extends string = string>(
Copy link
Member

Choose a reason for hiding this comment

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

this has already been added to common
x-pack/plugins/data_visualizer/common/utils/object_utils.ts

There would be no harm in moving the two functions below to common too.

Copy link
Member Author

Choose a reason for hiding this comment

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

This addition is unfortunately in the file_upload plugin, which the data_visualizer plugin depends on. We had to add runtime mapping support for the file_upload/time_field_range end point in this PR and these two functions are used to validate the runtimeMappingsSchema. I think this is something we can consolidate later once we have a way to share utility functions across all of our plugins.

Copy link
Member

Choose a reason for hiding this comment

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

ah ok, sorry i missed the file path and didn't realise this was in a different plugin.

@@ -1,9 +1,9 @@
.mlDataGridChart__histogram {
Copy link
Member

Choose a reason for hiding this comment

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

why do these classes need renaming when they are in ML?
The data visualizer should not rely on any styles in ML

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for catching that. Reverted the ML changes here aaf142c

getIndexDataVisualizerComponent().then(setIndexDataVisualizer);
}
}, []);
return IndexDataVisualizer ? (
Copy link
Member

@jgowdyelastic jgowdyelastic Jun 7, 2021

Choose a reason for hiding this comment

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

not for this PR, but it would be good to switch this and the file data viz to use React.lazy rather than these custom lazy loaders.
file data viz has FileDataVisualizerWrapper to do this when embedding in home, but I didn't change how ML was doing it as I intended to change it after this PR was in.

Copy link
Member Author

@qn895 qn895 Jun 7, 2021

Choose a reason for hiding this comment

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

I'll add this item to the meta issue #101435 👍

Copy link
Member

@jbudz jbudz left a comment

Choose a reason for hiding this comment

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

limits.yml LGTM


const [lastRefresh, setLastRefresh] = useState(0);

useEffect(() => {
timeBasedIndexCheck(currentIndexPattern, true);
}, []);
if (!currentIndexPattern.isTimeBased()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Note that this check and warning probably only apply when using the data visualizer inside of ML.

Copy link
Member Author

Choose a reason for hiding this comment

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

Added this item to the meta issue #101435 👍

Copy link
Contributor

@peteharverson peteharverson left a comment

Choose a reason for hiding this comment

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

Gave this a test and functionally LGTM. Just left a couple of earlier comments.

Copy link
Member

@jgowdyelastic jgowdyelastic left a comment

Choose a reason for hiding this comment

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

LGTM!

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
dataVisualizer - 236 +236
fileDataVisualizer 181 - -181
ml 1756 1688 -68
total -13

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
dataVisualizer - 59 +59
fileDataVisualizer 19 - -19
total +40

Any counts in public APIs

Total count of every any typed public API. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats any for more detailed information.

id before after diff
dataVisualizer - 1 +1

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
dataVisualizer - 1.1MB ⚠️ +1.1MB
fileDataVisualizer 1.0MB - -1.0MB
ml 5.9MB 5.8MB -118.2KB
total -21.1KB

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
dataVisualizer - 13.6KB +13.6KB
fileDataVisualizer 12.7KB - -12.7KB
ml 67.1KB 66.8KB -255.0B
total +651.0B
Unknown metric groups

API count

id before after diff
dataVisualizer - 59 +59
fileDataVisualizer 19 - -19
total +40

async chunk count

id before after diff
dataVisualizer - 2 +2
fileDataVisualizer 2 - -2
total -0

References to deprecated APIs

id before after diff
ml 121 99 -22

History

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

cc @qn895

@qn895 qn895 added the auto-backport Deprecated - use backport:version if exact versions are needed label Jun 8, 2021
@qn895 qn895 merged commit 65b8dda into elastic:master Jun 8, 2021
@kibanamachine
Copy link
Contributor

💔 Backport failed

Status Branch Result
7.x Commit could not be cherrypicked due to conflicts

To backport manually run:
node scripts/backport --pr 100922

gmmorris added a commit to gmmorris/kibana that referenced this pull request Jun 9, 2021
* master: (54 commits)
  Implement "select all" rules feature (elastic#100554)
  [ML] Remove script fields from the Anomaly detection alerting rule executor  (elastic#101607)
  [Security solutions][Endpoint] Update event filtering texts (elastic#101563)
  [Enterprise Search] Mocks/tests tech debt - avoid hungry mocking (elastic#101107)
  [FTR] Updates esArchive paths
  [FTR] Updates esArchive paths
  [Security Solution][Detection Engine] Adds runtime field tests (elastic#101664)
  Added APM PHP agent to the list of agent names (elastic#101062)
  [CI] Restore old version_info behavior when .git directory is present (elastic#101642)
  [Fleet] Add fleet server telemetry (elastic#101400)
  [APM] Syncs agent config settings to APM Fleet policies (elastic#100744)
  [esArchiver] drop support for --dir, use repo-relative paths instead (elastic#101345)
  Revert "[xpack/test] restore incremental: false in ts project"
  [Security Solution] Remove Host Isolation feature flag (elastic#101655)
  [xpack/test] restore incremental: false in ts project
  [DOCS] Adds link to video landing page (elastic#101413)
  [ML] Move Index Data Visualizer into separate plugin (Part 1) (elastic#100922)
  Improve security plugin return types (elastic#101492)
  [ts] migrate `x-pack/test` to composite ts project (elastic#101441)
  [App Search] Updated Search UI to new URL (elastic#101320)
  ...
qn895 added a commit that referenced this pull request Jun 9, 2021
…100922) (#101665)

* Resolve merge conflicts

* Make sure CODEOWNERS file is empty
@qn895 qn895 deleted the ml-move-index-data-visualizer branch December 21, 2021 18:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Deprecated - use backport:version if exact versions are needed Feature:File and Index Data Viz ML file and index data visualizer :ml release_note:skip Skip the PR/issue when compiling release notes v7.14.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants