kibana/x-pack/plugins/notifications
Spencer 1b85815402
[packages] migrate all plugins to packages (#148130)
Fixes https://github.com/elastic/kibana/issues/149344

This PR migrates all plugins to packages automatically. It does this
using `node scripts/lint_packages` to automatically migrate
`kibana.json` files to `kibana.jsonc` files. By doing this automatically
we can simplify many build and testing procedures to only support
packages, and not both "packages" and "synthetic packages" (basically
pointers to plugins).

The majority of changes are in operations related code, so we'll be
having operations review this before marking it ready for review. The
vast majority of the code owners are simply pinged because we deleted
all `kibana.json` files and replaced them with `kibana.jsonc` files, so
we plan on leaving the PR ready-for-review for about 24 hours before
merging (after feature freeze), assuming we don't have any blockers
(especially from @elastic/kibana-core since there are a few core
specific changes, though the majority were handled in #149370).

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
2023-02-08 21:06:50 -06:00
..
common
server
jest.config.js
kibana.jsonc [packages] migrate all plugins to packages (#148130) 2023-02-08 21:06:50 -06:00
README.md
tsconfig.json Transpile packages on demand, validate all TS projects (#146212) 2022-12-22 19:00:29 -06:00

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:

  1. Make sure notifications is in your optionalPlugins in the kibana.json file:
// <plugin>/kibana.json
{
"id": "...",
"requiredPlugins": ["notifications"]
}
  1. 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 uses Connectors 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