mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
Customers upgrading to 8.6 should not have warning messages for a new feature that they have not enabled. This PR changes the default behaviour, logging an `info` message (instead of a `warn`) when the default connector configuration is missing for the `'notifications'` plugin. |
||
---|---|---|
.. | ||
common | ||
server | ||
jest.config.js | ||
kibana.json | ||
README.md | ||
tsconfig.json |
Kibana Notifications Plugin
The Notifications plugin provides a set of services to help Solutions and plugins send notifications to users.
Notifications Plugin public API
Start
The start
function exposes the following interface:
isEmailServiceAvailable(): boolean
: A function to check whether the deployment is properly configured and the EmailService can be correctly retrieved.getEmailService(): EmailService
:- A function to get the basic EmailService, which can be used to send plain text emails. If the EmailService is not available, trying to retrieve it will result in an Exception.
Usage
To use the exposed plugin start contract:
- Make sure
notifications
is in youroptionalPlugins
in thekibana.json
file:
// <plugin>/kibana.json
{
"id": "...",
"requiredPlugins": ["notifications"]
}
- Use the exposed contract:
// <plugin>/server/plugin.ts
import { NotificationsPluginStart } from '../notifications/server`;
interface MyPluginStartDeps {
notifications?: NotificationsPluginStart;
}
class MyPlugin {
public start(
core: CoreStart,
{ notifications }: MyPluginStartDeps
) {
if (notifications.isEmailServiceAvailable()) {
const emailService = notifications.getEmailService();
emailService.sendPlainTextEmail({
to: 'foo@bar.com',
subject: 'Some subject',
message: 'Hello world!',
});
}
...
}
}
Requirements
-
This plugin currently depends on the
'actions'
plugin, as it usesConnectors
under the hood. -
Note also that for each notification channel the corresponding connector must be preconfigured. E.g. to enable email notifications, an
Email
connector must exist in the system. -
Once the appropriate connectors are preconfigured in
kibana.yaml
, you can configure the'notifications'
plugin by adding:notifications: connectors: default: email: elastic-cloud-email # The identifier of the configured connector