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

Reporting: Fix _index and _id columns in CSV export #96097

Merged
merged 15 commits into from
Apr 13, 2021

Conversation

tsullivan
Copy link
Member

@tsullivan tsullivan commented Apr 1, 2021

Summary

Closes: #96000

Elasticsearch has a bugfix change in 7.13 that invalidates certain metadata fields from being allowed in the fields API of a search request. Previously these fields would be ignored. See elastic/elasticsearch#70575

Kibana CSV Reporting populates the list of fields in the searchSource object with the columns selected in Discover. Since users can select metadata fields in Discover, it opened up the CSV export code to have metadata fields to exist in the list of fields in the searchSource. It did not matter that these fields were ignored by Elasticsearch. The set of fields were later used when generating the CSV to get the order of the columns.

This PR addresses the issue that Elasticsearch now throws an error when invalid metadata fields are passed in the fields API of a search. JobParamsCSV, which is the job payload for CSV report, previously only featured a searchSource object. A new columns string array is added to the params in this PR, which provides CSV generation with the selection and ordering of the columns. The columns param can contain the ID any field that is selectable in Discover, including metadata fields.

This screenshot of a select area of the code diff illustrates the change to the job params, in some mock code:

image

Checklist

For maintainers

@tsullivan tsullivan force-pushed the tests/reporting-unskip-5 branch 3 times, most recently from ec4630e to 51dd5da Compare April 2, 2021 19:47
@tsullivan
Copy link
Member Author

@elasticmachine merge upstream

@tsullivan tsullivan marked this pull request as ready for review April 5, 2021 23:04
@tsullivan tsullivan requested a review from a team April 5, 2021 23:04
@tsullivan tsullivan added release_note:skip Skip the PR/issue when compiling release notes v7.13.0 (Deprecated) Feature:Reporting Use Reporting:Screenshot, Reporting:CSV, or Reporting:Framework instead Team:AppServices labels Apr 5, 2021
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app-services (Team:AppServices)

Copy link
Contributor

@dokmic dokmic left a comment

Choose a reason for hiding this comment

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

LGTM, great job! I left a few minor suggestions.

…generate_csv/generate_csv.ts

Co-authored-by: Michael Dokolin <dokmic@gmail.com>
@tsullivan
Copy link
Member Author

@elasticmachine merge upstream

import { getSortForSearchSource } from '../angular/doc_table';

export interface ISharingData {
columns: string[];
Copy link
Member

Choose a reason for hiding this comment

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

lets make this optional

Copy link
Member

Choose a reason for hiding this comment

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

never mind i see its optional on the report type

Copy link
Member

@ppisljar ppisljar 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

@tsullivan
Copy link
Member Author

@elasticmachine merge upstream

@tsullivan
Copy link
Member Author

@elasticmachine merge upstream

@@ -12,3 +12,5 @@
export async function loadSharingDataHelpers() {
return await import('../application/helpers/get_sharing_data');
}

export { ISharingData } from '../application/helpers/get_sharing_data';
Copy link
Member

Choose a reason for hiding this comment

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

just a quick look, it's late and my local Kibana refuses to bootstrap. could you check the build stats of this PR once it's finished, to be sure there is no significant change because of this? I can review it tomorrow for sure

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure -- nothing actually imports this interface, but Typescript complained without the export

Copy link
Member Author

Choose a reason for hiding this comment

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

@kertal - I noticed that this PR added an extra 25K to the discover page load bundle, which is unexpected. I added fc16f85 and watching for how the bundle sizes changes in CI metrics.

Copy link
Member Author

Choose a reason for hiding this comment

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

fc16f85 brought the discover page load bundle size back down. Thanks for the tip @kertal!

Copy link
Member

Choose a reason for hiding this comment

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

even better, this PR saves a few bytes now!

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Async chunks

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

id before after diff
discover 397.0KB 396.7KB -386.0B

Page load bundle

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

id before after diff
reporting 86.8KB 86.8KB -25.0B

History

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

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, tested locally, CSV export with _index and _id works again 👍 , thx for taking care of the bundle size

@tsullivan tsullivan merged commit f67f0e8 into elastic:master Apr 13, 2021
@tsullivan tsullivan deleted the tests/reporting-unskip-5 branch April 13, 2021 15:03
tsullivan added a commit to tsullivan/kibana that referenced this pull request Apr 13, 2021
* Reporting: Fix _index and _id columns in CSV export

* optimize - cache _columns and run getColumns once per execution

* Update x-pack/plugins/reporting/server/export_types/csv_searchsource/generate_csv/generate_csv.ts

Co-authored-by: Michael Dokolin <dokmic@gmail.com>

* feedback

* fix typescripts

* fix plugin list test

* fix plugin list

* take away the export interface to test CI build stats

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Michael Dokolin <dokmic@gmail.com>
tsullivan added a commit that referenced this pull request Apr 13, 2021
* Reporting: Fix _index and _id columns in CSV export

* optimize - cache _columns and run getColumns once per execution

* Update x-pack/plugins/reporting/server/export_types/csv_searchsource/generate_csv/generate_csv.ts

Co-authored-by: Michael Dokolin <dokmic@gmail.com>

* feedback

* fix typescripts

* fix plugin list test

* fix plugin list

* take away the export interface to test CI build stats

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Michael Dokolin <dokmic@gmail.com>

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Michael Dokolin <dokmic@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
(Deprecated) Feature:Reporting Use Reporting:Screenshot, Reporting:CSV, or Reporting:Framework instead release_note:skip Skip the PR/issue when compiling release notes v7.13.0 v8.0.0
Projects
None yet
6 participants