The Kibana Core APIs for server-side plugins.
A plugin's server/index
file must contain a named import, plugin
, that implements PluginInitializer which returns an object that implements Plugin.
The plugin integrates with the core system via lifecycle events: setup
, start
, and stop
. In each lifecycle method, the plugin will receive the corresponding core services available (either CoreSetup or CoreStart) and any interfaces returned by dependency plugins' lifecycle method. Anything returned by the plugin's lifecycle method will be exposed to downstream dependencies when their corresponding lifecycle methods are invoked.
Class | Description |
---|---|
ClusterClient | Represents an Elasticsearch cluster API client and allows to call API on behalf of the internal Kibana user and the actual user that is derived from the request headers (via asScoped(...) ). |
ElasticsearchErrorHelpers | Helpers for working with errors returned from the Elasticsearch service.Since the internal data of errors are subject to change, consumers of the Elasticsearch service should always use these helpers to classify errors instead of checking error internals such as body.error.header[WWW-Authenticate] |
KibanaRequest | Kibana specific abstraction for an incoming request. |
Router | |
SavedObjectsErrorHelpers | |
SavedObjectsSchema | |
SavedObjectsSerializer | |
ScopedClusterClient | Serves the same purpose as "normal" ClusterClient but exposes additional callAsCurrentUser method that doesn't use credentials of the Kibana internal user (as callAsInternalUser does) to request Elasticsearch API, but rather passes HTTP headers extracted from the current user request to the API |
Interface | Description |
---|---|
AuthResultParams | Result of an incoming request authentication. |
AuthToolkit | A tool set defining an outcome of Auth interceptor for incoming request. |
CallAPIOptions | The set of options that defines how API call should be made and result be processed. |
CoreSetup | Context passed to the plugins setup method. |
CoreStart | Context passed to the plugins start method. |
DiscoveredPlugin | Small container object used to expose information about discovered plugins that may or may not have been started. |
ElasticsearchError | |
ElasticsearchServiceSetup | |
FakeRequest | Fake request object created manually by Kibana plugins. |
HttpServiceSetup | |
HttpServiceStart | |
InternalCoreStart | |
KibanaRequestRoute | Request specific route information exposed to a handler. |
Logger | Logger exposes all the necessary methods to log any type of information and this is the interface used by the logging consumers including plugins. |
LoggerFactory | The single purpose of LoggerFactory interface is to define a way to retrieve a context-based logger instance. |
LogMeta | Contextual metadata |
OnPostAuthToolkit | A tool set defining an outcome of OnPostAuth interceptor for incoming request. |
OnPreAuthToolkit | A tool set defining an outcome of OnPreAuth interceptor for incoming request. |
Plugin | The interface that should be returned by a PluginInitializer . |
PluginInitializerContext | Context that's available to plugins during initialization stage. |
PluginsServiceSetup | |
PluginsServiceStart | |
ResponseErrorMeta | Additional metadata to enhance error output or provide error details. |
RouteConfigOptions | Route specific configuration. |
SavedObject | |
SavedObjectAttributes | |
SavedObjectReference | A reference to another saved object. |
SavedObjectsBaseOptions | |
SavedObjectsBulkCreateObject | |
SavedObjectsBulkGetObject | |
SavedObjectsBulkResponse | |
SavedObjectsClientWrapperOptions | |
SavedObjectsCreateOptions | |
SavedObjectsFindOptions | |
SavedObjectsFindResponse | |
SavedObjectsMigrationVersion | A dictionary of saved object type -> version used to determine what migrations need to be applied to a saved object. |
SavedObjectsRawDoc | A raw document as represented directly in the saved object index. |
SavedObjectsService | |
SavedObjectsUpdateOptions | |
SavedObjectsUpdateResponse | |
SessionStorage | Provides an interface to store and retrieve data across requests. |
SessionStorageFactory | SessionStorage factory to bind one to an incoming request |
Type Alias | Description |
---|---|
APICaller | |
AuthenticationHandler | |
AuthHeaders | Auth Headers map |
ElasticsearchClientConfig | |
GetAuthHeaders | Get headers to authenticate a user against Elasticsearch. |
Headers | |
LegacyRequest | Support Legacy platform request for the period of migration. |
LifecycleResponseFactory | Creates an object containing redirection or error response with error details, HTTP headers, and other data transmitted to the client. |
OnPostAuthHandler | |
OnPreAuthHandler | |
PluginInitializer | The plugin export at the root of a plugin's server directory should conform to this interface. |
PluginName | Dedicated type for plugin name/id that is supposed to make Map/Set/Arrays that use it as a key or value more obvious. |
RecursiveReadonly | |
ResponseError | Error message and optional data send to the client in case of error. |
ResponseFactory | Creates an object containing request response payload, HTTP headers, error details, and other data transmitted to the client. |
RouteMethod | The set of common HTTP methods supported by Kibana routing. |
SavedObjectsClientContract | ## SavedObjectsClient errorsSince the SavedObjectsClient has its hands in everything we are a little paranoid about the way we present errors back to to application code. Ideally, all errors will be either:1. Caused by bad implementation (ie. undefined is not a function) and as such unpredictable 2. An error that has been classified and decorated appropriately by the decorators in SavedObjectsErrorHelpersType 1 errors are inevitable, but since all expected/handle-able errors should be Type 2 the isXYZError() helpers exposed at SavedObjectsErrorHelpers should be used to understand and manage error responses from the SavedObjectsClient .Type 2 errors are decorated versions of the source error, so if the elasticsearch client threw an error it will be decorated based on its type. That means that rather than looking for error.body.error.type or doing substring checks on error.body.error.reason , just use the helpers to understand the meaning of the error:```js if (SavedObjectsErrorHelpers.isNotFoundError(error)) { // handle 404 }if (SavedObjectsErrorHelpers.isNotAuthorizedError(error)) { // 401 handling should be automatic, but in case you wanted to know }// always rethrow the error unless you handle it throw error; ```### 404s from missing indexFrom the perspective of application code and APIs the SavedObjectsClient is a black box that persists objects. One of the internal details that users have no control over is that we use an elasticsearch index for persistance and that index might be missing.At the time of writing we are in the process of transitioning away from the operating assumption that the SavedObjects index is always available. Part of this transition is handling errors resulting from an index missing. These used to trigger a 500 error in most cases, and in others cause 404s with different error messages.From my (Spencer) perspective, a 404 from the SavedObjectsApi is a 404; The object the request/call was targeting could not be found. This is why #14141 takes special care to ensure that 404 errors are generic and don't distinguish between index missing or document missing.### 503s from missing indexUnlike all other methods, create requests are supposed to succeed even when the Kibana index does not exist because it will be automatically created by elasticsearch. When that is not the case it is because Elasticsearch's action.auto_create_index setting prevents it from being created automatically so we throw a special 503 with the intention of informing the user that their Elasticsearch settings need to be updated.See SavedObjectsErrorHelpers |
SavedObjectsClientWrapperFactory |