06b1820df7
* First draft, not quite working but a good start * More working * Support configuring throttle * Get the other alerts working too * More * Separate into individual files * Menu support as well as better integration in existing UIs * Red borders! * New overview style, and renamed alert * more visual updates * Update cpu usage and improve settings configuration in UI * Convert cluster health and license expiration alert to use legacy data model * Remove most of the custom UI and use the flyout * Add the actual alerts * Remove more code * Fix formatting * Fix up some errors * Remove unnecessary code * Updates * add more links here * Fix up linkage * Added nodes changed alert * Most of the version mismatch working * Add kibana mismatch * UI tweaks * Add timestamp * Support actions in the enable api * Move this around * Better support for changing legacy alerts * Add missing files * Update alerts * Enable alerts whenever any page is visited in SM * Tweaks * Use more practical default * Remove the buggy renderer and ensure setup mode can show all alerts * Updates * Remove unnecessary code * Remove some dead code * Cleanup * Fix snapshot * Fixes * Fixes * Fix test * Add alerts to kibana and logstash listing pages * Fix test * Add disable/mute options * Tweaks * Fix linting * Fix i18n * Adding a couple tests * Fix localization * Use http * Ensure we properly handle when an alert is resolved * Fix tests * Hide legacy alerts if not the right license * Design tweaks * Fix tests * PR feedback * Moar tests * Fix i18n * Ensure we have a control over the messaging * Fix translations * Tweaks * More localization * Copy changes * Type
60 lines
2 KiB
TypeScript
60 lines
2 KiB
TypeScript
/*
|
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
* or more contributor license agreements. Licensed under the Elastic License;
|
|
* you may not use this file except in compliance with the Elastic License.
|
|
*/
|
|
import { Subscription } from 'rxjs';
|
|
import { ILegacyCustomClusterClient } from 'kibana/server';
|
|
import { ILicense, LicenseFeature } from '../../licensing/common/types';
|
|
import { LicensingPluginSetup } from '../../licensing/server';
|
|
import { MonitoringConfig } from './config';
|
|
import { Logger } from '../../../../src/core/server';
|
|
import { MonitoringLicenseService } from './types';
|
|
|
|
interface SetupDeps {
|
|
licensing: LicensingPluginSetup;
|
|
monitoringClient: ILegacyCustomClusterClient;
|
|
config: MonitoringConfig;
|
|
log: Logger;
|
|
}
|
|
|
|
const defaultLicenseFeature: LicenseFeature = {
|
|
isAvailable: false,
|
|
isEnabled: false,
|
|
};
|
|
|
|
export class LicenseService {
|
|
public setup({ licensing, monitoringClient, config, log }: SetupDeps): MonitoringLicenseService {
|
|
const { refresh, license$ } = licensing.createLicensePoller(
|
|
monitoringClient,
|
|
config.licensing.api_polling_frequency.asMilliseconds()
|
|
);
|
|
|
|
let rawLicense: Readonly<ILicense> | undefined;
|
|
let licenseSubscription: Subscription | undefined = license$.subscribe((nextRawLicense) => {
|
|
rawLicense = nextRawLicense;
|
|
});
|
|
|
|
if (!rawLicense?.isAvailable) {
|
|
log.warn(
|
|
`X-Pack Monitoring Cluster Alerts will not be available: ${rawLicense?.getUnavailableReason()}`
|
|
);
|
|
}
|
|
|
|
return {
|
|
refresh,
|
|
license$,
|
|
getMessage: () => rawLicense?.getUnavailableReason() || 'N/A',
|
|
getMonitoringFeature: () => rawLicense?.getFeature('monitoring') || defaultLicenseFeature,
|
|
getWatcherFeature: () => rawLicense?.getFeature('watcher') || defaultLicenseFeature,
|
|
getSecurityFeature: () => rawLicense?.getFeature('security') || defaultLicenseFeature,
|
|
stop: () => {
|
|
if (licenseSubscription) {
|
|
licenseSubscription.unsubscribe();
|
|
licenseSubscription = undefined;
|
|
}
|
|
},
|
|
};
|
|
}
|
|
}
|