Home > kibana-plugin-core-server
The Kibana Core APIs for server-side plugins.
A plugin requires a kibana.json
file at it's root directory that follows the manfiest schema to define static plugin information required to load the plugin.
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 |
---|---|
BasePath | Access or manipulate the Kibana base path |
ClusterClient | Represents an Elasticsearch cluster API client created by the platform. It allows to call API on behalf of the internal Kibana user and the actual user that is derived from the request headers (via asScoped(...) ).See ClusterClient. |
CspConfig | CSP configuration for use in Kibana. |
ElasticsearchConfig | Wrapper of config schema. |
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. |
RouteValidationError | Error to return when the validation is not successful. |
SavedObjectsClient | |
SavedObjectsErrorHelpers | |
SavedObjectsRepository | |
SavedObjectsSerializer | A serializer that can be used to manually convert raw or sanitized documents to the other kind. |
SavedObjectTypeRegistry | Registry holding information about all the registered saved object types. |
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.See ScopedClusterClient. |
Enumeration | Description |
---|---|
AuthResultType | |
AuthStatus | Status indicating an outcome of the authentication. |
Function | Description |
---|---|
exportSavedObjectsToStream({ types, objects, search, savedObjectsClient, exportSizeLimit, includeReferencesDeep, excludeExportDetails, namespace, }) | Generates sorted saved object stream to be used for export. See the options for more detailed information. |
importSavedObjectsFromStream({ readStream, objectLimit, overwrite, savedObjectsClient, supportedTypes, namespace, }) | Import saved objects from given stream. See the options for more detailed information. |
resolveSavedObjectsImportErrors({ readStream, objectLimit, retries, savedObjectsClient, supportedTypes, namespace, }) | Resolve and return saved object import errors. See the options for more detailed informations. |
Interface | Description |
---|---|
APICaller | |
AssistanceAPIResponse | |
AssistantAPIClientParams | |
Authenticated | |
AuthNotHandled | |
AuthRedirected | |
AuthRedirectedParams | Result of auth redirection. |
AuthResultParams | Result of successful 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. |
Capabilities | The read-only set of capabilities available for the current UI session. Capabilities are simple key-value pairs of (string, boolean), where the string denotes the capability ID, and the boolean is a flag indicating if the capability is enabled or disabled. |
CapabilitiesSetup | APIs to manage the Capabilities that will be used by the application.Plugins relying on capabilities to toggle some of their features should register them during the setup phase using the registerProvider method.Plugins having the responsibility to restrict capabilities depending on a given context should register their capabilities switcher using the registerSwitcher method.Refers to the methods documentation for complete description and examples. |
CapabilitiesStart | APIs to access the application Capabilities. |
ConfigDeprecationFactory | Provides helpers to generates the most commonly used ConfigDeprecation when invoking a ConfigDeprecationProvider.See methods documentation for more detailed examples. |
ContextSetup | An object that handles registration of context providers and configuring handlers with context. |
CoreSetup | Context passed to the plugins setup method. |
CoreStart | Context passed to the plugins start method. |
CustomHttpResponseOptions | HTTP response parameters for a response with adjustable status code. |
DeprecationAPIClientParams | |
DeprecationAPIResponse | |
DeprecationInfo | |
DeprecationSettings | UiSettings deprecation field options. |
DiscoveredPlugin | Small container object used to expose information about discovered plugins that may or may not have been started. |
ElasticsearchError | |
ElasticsearchServiceSetup | |
EnvironmentMode | |
ErrorHttpResponseOptions | HTTP response parameters |
FakeRequest | Fake request object created manually by Kibana plugins. |
HttpResponseOptions | HTTP response parameters |
HttpServerInfo | |
HttpServiceSetup | Kibana HTTP Service provides own abstraction for work with HTTP stack. Plugins don't have direct access to hapi server and its primitives anymore. Moreover, plugins shouldn't rely on the fact that HTTP Service uses one or another library under the hood. This gives the platform flexibility to upgrade or changing our internal HTTP stack without breaking plugins. If the HTTP Service lacks functionality you need, we are happy to discuss and support your needs. |
HttpServiceStart | |
IContextContainer | An object that handles registration of context providers and configuring handlers with context. |
ICspConfig | CSP configuration for use in Kibana. |
IKibanaResponse | A response data object, expected to returned as a result of RequestHandler execution |
IKibanaSocket | A tiny abstraction for TCP socket. |
ImageValidation | |
IndexSettingsDeprecationInfo | |
IRenderOptions | |
IRouter | Registers route handlers for specified resource path and method. See RouteConfig and RequestHandler for more information about arguments to route registrations. |
IScopedRenderingClient | |
IUiSettingsClient | Server-side client that provides access to the advanced settings stored in elasticsearch. The settings provide control over the behavior of the Kibana application. For example, a user can specify how to display numeric or date fields. Users can adjust the settings via Management UI. |
KibanaRequestEvents | Request events. |
KibanaRequestRoute | Request specific route information exposed to a handler. |
LegacyRequest | |
LegacyServiceSetupDeps | |
LegacyServiceStartDeps | |
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 |
MetricsServiceSetup | APIs to retrieves metrics gathered and exposed by the core platform. |
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. |
OnPreResponseExtensions | Additional data to extend a response. |
OnPreResponseInfo | Response status code. |
OnPreResponseToolkit | A tool set defining an outcome of OnPreAuth interceptor for incoming request. |
OpsMetrics | Regroups metrics gathered by all the collectors. This contains metrics about the os/runtime, the kibana process and the http server. |
OpsOsMetrics | OS related metrics |
OpsProcessMetrics | Process related metrics |
OpsServerMetrics | server related metrics |
PackageInfo | |
Plugin | The interface that should be returned by a PluginInitializer . |
PluginConfigDescriptor | Describes a plugin configuration properties. |
PluginInitializerContext | Context that's available to plugins during initialization stage. |
PluginManifest | Describes the set of required and optional properties plugin can define in its mandatory JSON manifest file. |
PluginsServiceSetup | |
PluginsServiceStart | |
RequestHandlerContext | Plugin specific context passed to a route handler.Provides the following clients and services: - rendering - Rendering client which uses the data of the incoming request - savedObjects.client - Saved Objects client which uses the credentials of the incoming request - savedObjects.typeRegistry - Type registry containing all the registered types. - elasticsearch.dataClient - Elasticsearch data client which uses the credentials of the incoming request - elasticsearch.adminClient - Elasticsearch admin client which uses the credentials of the incoming request - uiSettings.client - uiSettings client which uses the credentials of the incoming request |
RouteConfig | Route specific configuration. |
RouteConfigOptions | Additional route options. |
RouteConfigOptionsBody | Additional body options for a route |
RouteValidationResultFactory | Validation result factory to be used in the custom validation function to return the valid data or validation errorsSee RouteValidationFunction. |
RouteValidatorConfig | The configuration object to the RouteValidator class. Set params , query and/or body to specify the validation logic to follow for that property. |
RouteValidatorOptions | Additional options for the RouteValidator class to modify its default behaviour. |
SavedObject | |
SavedObjectAttributes | The data for a Saved Object is stored as an object in the attributes property. |
SavedObjectMigrationContext | Migration context provided when invoking a migration handler |
SavedObjectMigrationMap | A map of migration functions to be used for a given type. The map's keys must be valid semver versions.For a given document, only migrations with a higher version number than that of the document will be applied. Migrations are executed in order, starting from the lowest version and ending with the highest one. |
SavedObjectReference | A reference to another saved object. |
SavedObjectsBaseOptions | |
SavedObjectsBulkCreateObject | |
SavedObjectsBulkGetObject | |
SavedObjectsBulkResponse | |
SavedObjectsBulkUpdateObject | |
SavedObjectsBulkUpdateOptions | |
SavedObjectsBulkUpdateResponse | |
SavedObjectsClientProviderOptions | Options to control the creation of the Saved Objects Client. |
SavedObjectsClientWrapperOptions | Options passed to each SavedObjectsClientWrapperFactory to aid in creating the wrapper instance. |
SavedObjectsComplexFieldMapping | See SavedObjectsFieldMapping for documentation. |
SavedObjectsCoreFieldMapping | See SavedObjectsFieldMapping for documentation. |
SavedObjectsCreateOptions | |
SavedObjectsDeleteByNamespaceOptions | |
SavedObjectsDeleteOptions | |
SavedObjectsExportOptions | Options controlling the export operation. |
SavedObjectsExportResultDetails | Structure of the export result details entry |
SavedObjectsFindOptions | |
SavedObjectsFindResponse | Return type of the Saved Objects find() method.*Note*: this type is different between the Public and Server Saved Objects clients. |
SavedObjectsImportConflictError | Represents a failure to import due to a conflict. |
SavedObjectsImportError | Represents a failure to import. |
SavedObjectsImportMissingReferencesError | Represents a failure to import due to missing references. |
SavedObjectsImportOptions | Options to control the import operation. |
SavedObjectsImportResponse | The response describing the result of an import. |
SavedObjectsImportRetry | Describes a retry operation for importing a saved object. |
SavedObjectsImportUnknownError | Represents a failure to import due to an unknown reason. |
SavedObjectsImportUnsupportedTypeError | Represents a failure to import due to having an unsupported saved object type. |
SavedObjectsIncrementCounterOptions | |
SavedObjectsMappingProperties | Describe the fields of a saved object type. |
SavedObjectsMigrationLogger | |
SavedObjectsMigrationVersion | Information about the migrations that have been applied to this SavedObject. When Kibana starts up, KibanaMigrator detects outdated documents and migrates them based on this value. For each migration that has been applied, the plugin's name is used as a key and the latest migration version as the value. |
SavedObjectsRawDoc | A raw document as represented directly in the saved object index. |
SavedObjectsRepositoryFactory | Factory provided when invoking a client factory provider See SavedObjectsServiceSetup.setClientFactoryProvider |
SavedObjectsResolveImportErrorsOptions | Options to control the "resolve import" operation. |
SavedObjectsServiceSetup | Saved Objects is Kibana's data persistence mechanism allowing plugins to use Elasticsearch for storing and querying state. The SavedObjectsServiceSetup API exposes methods for registering Saved Object types, creating and registering Saved Object client wrappers and factories. |
SavedObjectsServiceStart | Saved Objects is Kibana's data persisentence mechanism allowing plugins to use Elasticsearch for storing and querying state. The SavedObjectsServiceStart API provides a scoped Saved Objects client for interacting with Saved Objects. |
SavedObjectsType | |
SavedObjectsTypeManagementDefinition | Configuration options for the type's management section. |
SavedObjectsTypeMappingDefinition | Describe a saved object type mapping. |
SavedObjectsUpdateOptions | |
SavedObjectsUpdateResponse | |
SessionCookieValidationResult | Return type from a function to validate cookie contents. |
SessionStorage | Provides an interface to store and retrieve data across requests. |
SessionStorageCookieOptions | Configuration used to create HTTP session storage based on top of cookie mechanism. |
SessionStorageFactory | SessionStorage factory to bind one to an incoming request |
StringValidationRegex | StringValidation with regex object |
StringValidationRegexString | StringValidation as regex string |
UiSettingsParams | UiSettings parameters defined by the plugins. |
UiSettingsServiceSetup | |
UiSettingsServiceStart | |
UserProvidedValues | Describes the values explicitly set by user. |
UuidServiceSetup | APIs to access the application's instance uuid. |
Variable | Description |
---|---|
kibanaResponseFactory | Set of helpers used to create KibanaResponse to form HTTP response on an incoming request. Should be returned as a result of RequestHandler execution. |
validBodyOutput | The set of valid body.output |
Type Alias | Description |
---|---|
AuthenticationHandler | See AuthToolkit. |
AuthHeaders | Auth Headers map |
AuthResult | |
CapabilitiesProvider | See CapabilitiesSetup |
CapabilitiesSwitcher | See CapabilitiesSetup |
ConfigDeprecation | Configuration deprecation returned from ConfigDeprecationProvider that handles a single deprecation from the configuration. |
ConfigDeprecationLogger | Logger interface used when invoking a ConfigDeprecation |
ConfigDeprecationProvider | A provider that should returns a list of ConfigDeprecation.See ConfigDeprecationFactory for more usage examples. |
ConfigPath | |
DestructiveRouteMethod | Set of HTTP methods changing the state of the server. |
ElasticsearchClientConfig | |
GetAuthHeaders | Get headers to authenticate a user against Elasticsearch. |
GetAuthState | Gets authentication state for a request. Returned by auth interceptor. |
HandlerContextType | Extracts the type of the first argument of a HandlerFunction to represent the type of the context. |
HandlerFunction | A function that accepts a context object and an optional number of additional arguments. Used for the generic types in IContextContainer |
HandlerParameters | Extracts the types of the additional arguments of a HandlerFunction, excluding the HandlerContextType. |
Headers | Http request headers to read. |
HttpResponsePayload | Data send to the client as a response payload. |
IBasePath | Access or manipulate the Kibana base pathBasePath |
IClusterClient | Represents an Elasticsearch cluster API client created by the platform. It allows to call API on behalf of the internal Kibana user and the actual user that is derived from the request headers (via asScoped(...) ).See ClusterClient. |
IContextProvider | A function that returns a context value for a specific key of given context type. |
ICustomClusterClient | Represents an Elasticsearch cluster API client created by a plugin. It allows to call API on behalf of the internal Kibana user and the actual user that is derived from the request headers (via asScoped(...) ).See ClusterClient. |
IsAuthenticated | Returns authentication status for a request. |
ISavedObjectsRepository | See SavedObjectsRepository |
ISavedObjectTypeRegistry | See SavedObjectTypeRegistry for documentation. |
IScopedClusterClient | 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.See ScopedClusterClient. |
KibanaRequestRouteOptions | Route options: If 'GET' or 'OPTIONS' method, body options won't be returned. |
KibanaResponseFactory | Creates an object containing request response payload, HTTP headers, error details, and other data transmitted to the client. |
KnownHeaders | Set of well-known HTTP headers. |
LifecycleResponseFactory | Creates an object containing redirection or error response with error details, HTTP headers, and other data transmitted to the client. |
MIGRATION_ASSISTANCE_INDEX_ACTION | |
MIGRATION_DEPRECATION_LEVEL | |
MutatingOperationRefreshSetting | Elasticsearch Refresh setting for mutating operation |
OnPostAuthHandler | See OnPostAuthToolkit. |
OnPreAuthHandler | See OnPreAuthToolkit. |
OnPreResponseHandler | See OnPreAuthToolkit. |
PluginConfigSchema | Dedicated type for plugin configuration schema. |
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. |
PluginOpaqueId | |
RecursiveReadonly | |
RedirectResponseOptions | HTTP response parameters for redirection response |
RequestHandler | A function executed when route path matched requested resource path. Request handler is expected to return a result of one of KibanaResponseFactory functions. |
RequestHandlerContextContainer | An object that handles registration of http request context providers. |
RequestHandlerContextProvider | Context provider for request handler. Extends request context object with provided functionality or data. |
ResponseError | Error message and optional data send to the client in case of error. |
ResponseErrorAttributes | Additional data to provide error details. |
ResponseHeaders | Http response headers to set. |
RouteContentType | The set of supported parseable Content-Types |
RouteMethod | The set of common HTTP methods supported by Kibana routing. |
RouteRegistrar | Route handler common definition |
RouteValidationFunction | The custom validation function if @kbn/config-schema is not a valid solution for your specific plugin requirements. |
RouteValidationSpec | Allowed property validation options: either @kbn/config-schema validations or custom validation functionsSee RouteValidationFunction for custom validation. |
RouteValidatorFullConfig | Route validations config and options merged into one object |
SafeRouteMethod | Set of HTTP methods not changing the state of the server. |
SavedObjectAttribute | Type definition for a Saved Object attribute value |
SavedObjectAttributeSingle | Don't use this type, it's simply a helper type for SavedObjectAttribute |
SavedObjectMigrationFn | A migration function for a saved object type used to migrate it to a given version |
SavedObjectSanitizedDoc | |
SavedObjectsClientContract | Saved Objects is Kibana's data persisentence mechanism allowing plugins to use Elasticsearch for storing plugin state.## 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 SavedObjectsClient See SavedObjectsErrorHelpers |
SavedObjectsClientFactory | Describes the factory used to create instances of the Saved Objects Client. |
SavedObjectsClientFactoryProvider | Provider to invoke to retrieve a SavedObjectsClientFactory. |
SavedObjectsClientWrapperFactory | Describes the factory used to create instances of Saved Objects Client Wrappers. |
SavedObjectsFieldMapping | Describe a saved object type mapping field.Please refer to elasticsearch documentation For the mapping documentation |
ScopeableRequest | A user credentials container. It accommodates the necessary auth credentials to impersonate the current user.See KibanaRequest. |
SharedGlobalConfig | |
StringValidation | Allows regex objects or a regex string |
UiSettingsType | UI element type to represent the settings. |