Plugin API changes in 7.13

edit

Plugin API changes in 7.13

edit

This page discusses the plugin API changes that you need to be aware of when migrating your application to Kibana 7.13.

Other versions: 7.12 | 7.11 | 7.10 | 7.9 | 7.8

Ensure LogMeta is ECS-compliant

Core’s logging system has been updated to ensure that logs using a JSON layout are compliant with ECS. If you are using the optional LogMeta param in your plugin, check the ECS spec and ensure your meta conforms to ECS wherever possible.

We’ve updated the LogMeta TypeScript interface to require ECS-friendly data. Should you need to log fields that do not fit within the ECS spec, you can provide a generic type parameter that accepts an interface that extends from the base LogMeta:

// plugins/my-plugin/server/plugin.ts

import type { CoreSetup, LogMeta, Plugin, PluginInitializerContext } from 'src/core/server';

interface MyPluginLogMeta extends LogMeta {
  kibana: { myCustomField: string };
}

export class MyPlugin implements Plugin  {
  constructor(private readonly initContext: PluginInitializerContext) {
    this.logger = initContext.logger.get();
  }

  setup(core: CoreSetup) {
    this.logger.warn<MyPluginLogMeta>('my log with custom meta', {
      kibana: {
        myCustomField: 'heya',
      }
    });
  }
}

Refer to #96350

ES client uses new type definitions

In the previous releases, the Kibana Platform provided an Elasticsearch client that didn’t have any response typings out of the box. Going forward, the Elasticsearch client is provided with enhanced response type definitions.

If your code already leverages the new Elasticsearch client, remove all type definitions imported from the legacy elasticseach client library and all manually maintained type definitions. Instead, use typings provided from the @elastic/elasticsearch client:

- import { SearchResponse } from 'elasticsearch';
+ import type { estypes } from '@elastic/elasticsearch';

Also, review all the @elastic/elasticsearch library type generics used in your code. Most of them are either unnecessary or should be refactored:

- const { body } = await client.search<MySearchResponse>(...)
+ const { body } = await client.search(...)

Refer to #83808