Reporting integration

Integrating a Kibana application with the reporting features requires a minimum amount of code, and the goal is to not have to modify the reporting code as we add additional applications. Instead, applications abide by a contract that reporting features use to determine the information that is required to export CSVs and PDFs.

These pages document internal APIs and are not guaranteed to be supported across future versions of Kibana. However, these docs will be kept up-to-date to reflect the current implementation of Reporting integration in Kibana.

Share menu extensions

X-Pack uses the share plugin of the Kibana platform to register actions in the share menu.

Generate job URL

To generate a new reporting job, different export types require different jobParams that are Rison encoded into a URL that abide by the following convention: /api/reporting/generate?jobParams=${rison.encode(jobParams)}. If you use the aforementioned nav bar extensions then this detail will be abstracted away, but if you provide a custom UI for generating the report, you will have to generate the URL and create a POST request to the URL.

CSV

Job parameters

If integrating with Reporting via a custom UI, the following job parameters must be Rison encoded and posted to the aforementioned generate job url:

  1. interface jobParameters {
  2. type: string;
  3. title: string;
  4. searchRequest: {
  5. index: string;
  6. body: object;
  7. };
  8. fields: string[];
  9. metaFields: string[];
  10. conflictedTypesFields: string[];
  11. indexPatternId: string;
  12. }

The searchRequest.body should abide by the Elasticsearch Search Request Body syntax

export-config Directive

If integrating with Reporting via the export-config directive, the AngularJS controller that contains the directive should expose the following methods and the export-config directive will POST them to the reporting API:

  1. interface sharingData {
  2. searchRequest: {
  3. index: string;
  4. body: object;
  5. };
  6. fields: string[];
  7. metaFields: string[];
  8. conflictedTypesFields: string[];
  9. indexPatternId: string;
  10. }
  11. function getSharingData(): sharingData;
  12. function getSharingType(): string;
  13. function getSharingTitle() string;

The sharingData.searchRequest.body should abide by the Elasticsearch Search Request Body syntax

PDF

Job parameters

If integrating with Reporting via a custom UI, the following job parameters must be Rison encoded and posted to the aforementioned generate job url:

  1. interface jobParameters {
  2. objectType: string;
  3. title: string;
  4. browserTimezone: string;
  5. relativeUrls: string[];
  6. layout: {
  7. id: string;
  8. dimensions: {
  9. height: number;
  10. width: number;
  11. };
  12. };
  13. }

jobParameters.browserTimezone is a string that appears in the tz database jobParameters.layout.id presently only accepts “print” and “preserve_layout” jobParameters.layout.dimensions is only currently used by “preserve_layout”

export-config directive

If integrating with Reporting via the export-config directive, the AngularJS controller that contains the directive should expose the following methods and the export-config directive will POST them to the reporting API:

  1. function getSharingType(): string;
  2. function getSharingTitle(): string;

The export-config directive will use the browser’s current URL and timezone when generating the job parameters automatically. The export-config directive will also grab the height/width of the element with the data-shared-items-container attribute and use this as the dimensions.

Screenshot capturing attributes

When generating the PDF, reporting looks for a number of attributes in the DOM to determine which elements should have their screenshot taken and when the Visualizations are done rendering.

The print layout takes a screenshot of every element with the data-shared-item attribute and includes the individual screenshots in the PDF. The print layout also uses the data-title and data-description attributes on the same HTMLElement as the data-shared-item to specify the title and description.

The preserve layout takes a screenshot of the element with the data-shared-items-container attribute. Additionally, reporting will resize the element with the data-shared-items-container to be the size specified in the layout dimensions. The preserve layout also uses the data-title and data-description attributes on the HTMLElement with the data-shared-items-container attribute to specify the title/description for the entire PDF.

Reporting needs to determine when all of the visualizations have completed rendering, so that it can begin taking screenshots. If there are multiple visualizations, the data-shared-items-count attribute should be specified to let Reporting know how many Visualizations to look for. Reporting will look at every element with the data-shared-item attribute and use the corresponding data-render-complete attribute and renderComplete events to listen for rendering to complete. When rendering is complete for a visualization the data-render-complete attribute should be set to “true” and it should dispatch a custom DOM renderComplete event.

If the reporting job uses multiple URLs, before looking for any of the data-shared-item or data-shared-items-count attributes, it waits for a data-shared-page attribute that specifies which page is being loaded.

Most Popular