Tech Topics

Kibana Plugin API Changes in 7.5

Expose package info to Kibana Platform plugins

Kibana package information provided to the plugins in constructor as a part of PluginInitializerContext

class MyPlugin {
  constructor(context: PluginInitializerContext){
    const isDitribution = context.env.packageInfo.dist;
  }
}

via #48101

Reconstruct setup\start data shim APIs

savedObjects.client is not available in setup in Kibana platform. The following APIs were updated accordingly as well as their consumers.

  • filter service is available only on start.
  • indexPatterns.indexPatterns service is available only on start.
  • search.savedQueries service is available only on start.

via #47851

Supports metadata logging in the Kibana platform

Logging service allows attaching meta-data to the logging messages. Meta-data expected to be a valid JSON object.

log.info('server started', { port: 8088 });

output in json format:

{
  message: 'server started'
  port: 8088
  ...
}

via #47456

Get rid of addFiltersAndChangeTimeFilter

Deprecated addFiltersAndChangeTimeFilter. If needed, replace with

    const { timeRangeFilter, restOfFilters } = extractTimeFilter(indexPattern.timeFieldName, filters);
    queryFilter.addFilters(restOfFilters);
    if (timeRangeFilter) changeTimeFilter(timefilter, timeRangeFilter);

via #47450

Remove ui/persisted_log - Part 2

Moved persisted_log from src/legacy/ui/public/persisted_log/persisted_log.tssrc/legacy/core_plugins/data/public/query/persisted_log/persisted_log.ts No changes were made to interface.

via #47236

Advanced ui actions 2 np

advanced_ui_actions NP-ready plugin has been moved to the Kibana Platform X-Pack plugin.

via #46948

Embeddables 👉 Kibana Platform

Embeddables API has been moved from src/legacy/core_plugins/embeddable_api to the embeddable Kibana Platform plugin at src/plugins/embeddable.

Now you can use Embeddables API in the Kibana Platform by depending on embeddable plugin and receiving it through the plugin dependencies. In the legacy Kibana platform you can access Embeddables though ui/new_platform backdoor.

import { npSetup, npStart } from 'ui/new_platform';

npSetup.plugins.embeddable
npStart.plugins.embeddable

via #46771

Create a pre-wired version of SearchBar

In order to use any of our stateful components, you are going to have to wrap your application on the topmost level with a KibanaContextProvider:

Assuming new platform syntax:

          <KibanaContextProvider
            services={{
              uiSettings: core.uiSettings,
              docLinks: core.docLinks,
              data: plugins.data,
            }}
          >
            {content}
          </KibanaContextProvider>

Then, inside a react component, you may use our stateful component, that requires less input and confuguration:

   const {
     ui: { SearchBar },
   } = plugins.data;

   render() {
      return <SearchBar
          appName="myApp"
          ...
        />
   }

via #46702

FieldFormats Registry API change

byId[id] has been replaced with .getType(id) for accessing individual field formatters.

via #46395

Move ui/value_suggestions ⇒ NP data plugin

Move value_suggestions into NP and expose data.getSuggestions on start contract.

In old platform:

    import { npStart } from 'ui/new_platform';
    const suggestions = await npStart.plugins.data.getSuggestions(indexPattern.title, field, value);

In new platform:

    public start(core, plugins) {
       ...
       const suggestions = await plugins.data.getSuggestions(indexPattern.title, field, value);
    }

via #45762

Moved KbnError base class ⇒ kibana_utils

  • Moved errors base class to kibana_utils, along with:
    • DuplicateField
    • SavedObjectNotFound
    • InvalidJSONProperty
  • Moved specific error types to appropriate modules
    • PersistedStateErrorui/persisted_state
    • VislibError and its children ⇒ ui/vislib
    • RequestFailureui/courier
  • Delete unused errors:
    • VersionConflict
    • MappingConflict
    • FetchFailure
    • RestrictedMapping
    • CacheWriteFailure
    • FieldNotFoundInCache
    • FetchFailure

via #45532

Rename QueryBar to QueryBarTopRow

  • Rename QueryBar to QueryBarTopRow
  • Stop exporting QueryBar on the public contract.

via #45250

Move ExpressionRenderer to setup instead of start

Plugins may now access the expression renderer in their setup phase as well as their start phase.

via #45141

Add x-pack plugin for Kibana platform browser licensing information

Add x-pack plugin for new Kibana platform public licensing information. This will eventually replace the licensing information consumed via xpack_main. Upon setup, this plugin exposes an observable API for inspecting and making checks against the license information.

license$.subscribe(license => {
   console.log(license.uid);
   console.log(license.isActive);
   console.log(license.type);

   const { state } = license.check('my-plugin', LICENSE_TYPE.gold);

   if (state !== LICENSE_STATUS.Valid) {
     disableSomething();
   }
});

via #44922

Move timefilter and timehistory instantiation ⇒ data plugin

Move value_suggestions into NP and expose data.getSuggestions on start contract.

In old platform:

    import { npStart } from 'ui/new_platform';
    const timefilter: TimefilterContract = npStart.plugins.data.timefilter.timefilter;
    const timeHistory: TimeHistoryContract = npStart.plugins.data.timefilter.timeHistory;

In new platform:

    public start(core, plugins) {
       ...
       const timefilter: TimefilterContract = plugins.data.timefilter.timefilter;
       const timeHistory: TimeHistoryContract = plugins.data.timefilter.timeHistory;
    }

Also, in timefilter the following API changes were made:

  • Replaced timefilter.isAutoRefreshSelectorEnabled member with timefilter.isAutoRefreshSelectorEnabled()
  • Replaced timefilter.isTimeRangeSelectorEnabled with timefilter.isTimeRangeSelectorEnabled()
  • timefilter.getForceNow is now private

via #44783

Move actions to Kibana Platform

The actions API that was previously a part of the Embeddable API is now it's own Kibana platform plugin.

via #44707

GUI enhancement: handle descriptions for visualizations (#20936)

  • Allow adding a description in the visualization save form.
  • Show the description in the visualizations list
  • Shows an "info" icon on the right of the visualization when in a dashboard; hovering the icon shows the description within a toolti.

via #44702

plugins/visualizations => src/legacy/core_plugins/visualizations/public/np_ready/public/

via #44644

Decouple actions from embeddables: step 1

The action interface no longer requires an embeddable and triggerContext to be passed in. The shape of ActionContext is now completely up to the specific action implementation.

Previously:

interface Action<
  TEmbeddable extends IEmbeddable = IEmbeddable,	
  TTriggerContext extends {} = {}
> {
  execute(context: { embeddable: TEmbeddable, triggerContext: TriggerContext });
}

Now:

interface Action<ActionContext extends {} = {}> {
  execute(context: ActionContext);
}

via #44503

Additional data plugin dependency clean up

  • Ipv4Addresssrc/plugins/kibana_utils/public
  • ObjDefinesrc/legacy/core_plugins/data/public/index_patterns/fields/obj_define.js

via #44080

Add x-pack plugin for Kibana platform server licensing information

Add x-pack plugin for Kibana platform server licensing information. This will eventually replace the licensing information consumed via xpack_main. Upon setup, this plugin exposes an observable API for inspecting and making checks against the license information.

license$.subscribe(license => {
   console.log(license.uid);
   console.log(license.isActive);
   console.log(license.type);

   const { check } = license.check('my-plugin', LICENSE_TYPE.gold);

   if (check !== LICENSE_STATUS.Valid) {
     disableSomething();
   }
});

via #43623

Saved objects React components

<SavedObjectFinder> and <SavedObjectSaveModal> React components have been moved to kibana_react Kibana Platform plugin. Usage of the new components:

import { SavedObjectFinder, SavedObjectSavedModal } from 'src/plugins/kibana_react';

<SavedObjectFinder savedObjects={core.savedObjects} uiSettings={core.uiSettings} />
<SavedObjectSaveModal />

via #43416

exit_full_screen_button -> Kibana Platform

ui/exit_full_screen_button has been moved to the Kibana Platform. Now you should import it like this

import { ExitFullScreenButton } from 'src/plugins/kibana_react/public';

via #43414

Make request and response properties conditionally available during HTTP interception

Make request and response properties conditionally available during HTTP response interception. Adds request instance property to HTTP Fetch Errors. Prevents HTTP interception halting from settling associated fetch promises.

via #42755

Add KQL functionality in the find function of the saved objects

SavedObjectsClient.find now supports filtering using KQL string with the caveat that if you filter with an attribute from your type saved object. It should look like that savedObjectType.attributes.name: "SayMyName". However, If you used a direct attribute of a saved object like updatedAt, you will have to define your filter like that savedObjectType.updatedAt > 2018-12-22.

savedObjectsClient.find({
      type: 'savedObjectType',
      sortField: '@timestamp',
      sortOrder: 'desc',
      search: '',
      searchFields:'',
      fields: ['id', 'name', '@created', '@timestamp'],
      filter:
        'savedObjectType.attributes.name: "SayMyName" and savedObjectType.updatedAt > 2018-12-22'
    });

via #41136

Add ApplicationService Mounting

Kibana Platform plugins may now register UI applications to display in the global navigation and be mounted inside Kibana as a single-page application. Example:

class MyPlugin {
  public setup(core) {
    core.application.register({
      id: 'myApp',
      async mount(context, params) {
        const { renderApp } = await import('./application');
        return renderApp(context, params);
      }
    });
  }
}

For more details, see the Application Mounting RFC.

via #41007

Removal of visFactory.createAngularVisualization

Angular visualizations are now created using createBaseVisualization and setting the visualization property to AngularVisController. If your plugin uses createAngularVisualization, it will need to be updated as follows:

// old
import { VisFactoryProvider } from 'ui/vis/vis_factory';
export function createVis(Private) {
  const visFactory = Private(VisFactoryProvider);
  return visFactory.createAngularVisualization({
    ...
  });
}
// new
import { visFactory } from 'ui/vis/vis_factory';
import { AngularVisController } from 'ui/vis/vis_types/angular_vis_type';
export function createVis() {
  return visFactory.createBaseVisualization({
    ...,
    visualization: AngularVisController
  });
}

via #45888