add logs
This commit is contained in:
parent
70618f66ac
commit
4a61b646e6
|
@ -7,7 +7,15 @@
|
|||
*/
|
||||
|
||||
import { Observable, combineLatest, Subscription } from 'rxjs';
|
||||
import { map, distinctUntilChanged, shareReplay, take, debounceTime } from 'rxjs/operators';
|
||||
import {
|
||||
map,
|
||||
distinctUntilChanged,
|
||||
shareReplay,
|
||||
take,
|
||||
debounceTime,
|
||||
pairwise,
|
||||
startWith,
|
||||
} from 'rxjs/operators';
|
||||
import { isDeepStrictEqual } from 'util';
|
||||
|
||||
import { CoreService } from '../../types';
|
||||
|
@ -39,6 +47,7 @@ export class StatusService implements CoreService<InternalStatusServiceSetup> {
|
|||
private readonly logger: Logger;
|
||||
private readonly config$: Observable<StatusConfigType>;
|
||||
|
||||
private overall$?: Observable<ServiceStatus>;
|
||||
private pluginsStatus?: PluginsStatusService;
|
||||
private overallSubscription?: Subscription;
|
||||
|
||||
|
@ -59,10 +68,7 @@ export class StatusService implements CoreService<InternalStatusServiceSetup> {
|
|||
const core$ = this.setupCoreStatus({ elasticsearch, savedObjects });
|
||||
this.pluginsStatus = new PluginsStatusService({ core$, pluginDependencies });
|
||||
|
||||
const overall$: Observable<ServiceStatus> = combineLatest([
|
||||
core$,
|
||||
this.pluginsStatus.getAll$(),
|
||||
]).pipe(
|
||||
this.overall$ = combineLatest([core$, this.pluginsStatus.getAll$()]).pipe(
|
||||
// Prevent many emissions at once from dependency status resolution from making this too noisy
|
||||
debounceTime(500),
|
||||
map(([coreStatus, pluginsStatus]) => {
|
||||
|
@ -78,7 +84,7 @@ export class StatusService implements CoreService<InternalStatusServiceSetup> {
|
|||
);
|
||||
|
||||
// Create an unused subscription to ensure all underlying lazy observables are started.
|
||||
this.overallSubscription = overall$.subscribe();
|
||||
this.overallSubscription = this.overall$.subscribe();
|
||||
|
||||
const router = http.createRouter('');
|
||||
registerStatusRoute({
|
||||
|
@ -91,7 +97,7 @@ export class StatusService implements CoreService<InternalStatusServiceSetup> {
|
|||
},
|
||||
metrics,
|
||||
status: {
|
||||
overall$,
|
||||
overall$: this.overall$,
|
||||
plugins$: this.pluginsStatus.getAll$(),
|
||||
core$,
|
||||
},
|
||||
|
@ -99,7 +105,7 @@ export class StatusService implements CoreService<InternalStatusServiceSetup> {
|
|||
|
||||
return {
|
||||
core$,
|
||||
overall$,
|
||||
overall$: this.overall$,
|
||||
plugins: {
|
||||
set: this.pluginsStatus.set.bind(this.pluginsStatus),
|
||||
getDependenciesStatus$: this.pluginsStatus.getDependenciesStatus$.bind(this.pluginsStatus),
|
||||
|
@ -109,7 +115,11 @@ export class StatusService implements CoreService<InternalStatusServiceSetup> {
|
|||
};
|
||||
}
|
||||
|
||||
public start() {}
|
||||
public start() {
|
||||
this.overall$!.pipe(startWith(undefined), pairwise()).subscribe(([oldStatus, newStatus]) => {
|
||||
this.logger.info(`Kibana overall status is now ${newStatus!.level.toString()}`);
|
||||
});
|
||||
}
|
||||
|
||||
public stop() {
|
||||
if (this.overallSubscription) {
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
|
||||
import { Observable, Subject, Subscription, timer } from 'rxjs';
|
||||
import { take, startWith, map } from 'rxjs/operators';
|
||||
import moment from 'moment';
|
||||
import { createHash } from 'crypto';
|
||||
import stringify from 'json-stable-stringify';
|
||||
|
@ -18,7 +19,8 @@ import {
|
|||
Plugin,
|
||||
PluginInitializerContext,
|
||||
IClusterClient,
|
||||
} from 'src/core/server';
|
||||
ServiceStatusLevels,
|
||||
} from '../../../../src/core/server';
|
||||
|
||||
import { ILicense, PublicLicense, PublicFeatures } from '../common/types';
|
||||
import { LicensingPluginSetup, LicensingPluginStart } from './types';
|
||||
|
@ -107,6 +109,26 @@ export class LicensingPlugin implements Plugin<LicensingPluginSetup, LicensingPl
|
|||
pollingFrequency.asMilliseconds()
|
||||
);
|
||||
|
||||
core.status.set(
|
||||
license$.pipe(
|
||||
startWith(undefined),
|
||||
take(2),
|
||||
map((license) => {
|
||||
if (license) {
|
||||
return {
|
||||
level: ServiceStatusLevels.available,
|
||||
summary: 'License fetched',
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
level: ServiceStatusLevels.degraded,
|
||||
summary: 'license not fetched yet',
|
||||
};
|
||||
}
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
core.http.registerRouteHandlerContext(
|
||||
'licensing',
|
||||
createRouteHandlerContext(license$, core.getStartServices)
|
||||
|
|
Loading…
Reference in a new issue