mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
This commit is contained in:
parent
7a2b07cde5
commit
f6b4d051d1
5 changed files with 116 additions and 3 deletions
|
@ -6,10 +6,11 @@
|
|||
"id": "uptime",
|
||||
"kibanaVersion": "kibana",
|
||||
"optionalPlugins": [
|
||||
"cloud",
|
||||
"data",
|
||||
"fleet",
|
||||
"home",
|
||||
"ml",
|
||||
"fleet"
|
||||
"ml"
|
||||
],
|
||||
"requiredPlugins": [
|
||||
"alerting",
|
||||
|
|
|
@ -23,6 +23,7 @@ import { RuleRegistryPluginSetupContract } from '../../../../../rule_registry/se
|
|||
import { UptimeESClient } from '../../lib';
|
||||
import type { UptimeRouter } from '../../../types';
|
||||
import { SecurityPluginStart } from '../../../../../security/server';
|
||||
import { CloudSetup } from '../../../../../cloud/server';
|
||||
import { UptimeConfig } from '../../../../common/config';
|
||||
|
||||
export type UMElasticsearchQueryFn<P, R = any> = (
|
||||
|
@ -40,6 +41,7 @@ export type UMSavedObjectsQueryFn<T = any, P = undefined> = (
|
|||
export interface UptimeCoreSetup {
|
||||
router: UptimeRouter;
|
||||
config: UptimeConfig;
|
||||
cloud: CloudSetup;
|
||||
security: SecurityPluginStart;
|
||||
encryptedSavedObjects: EncryptedSavedObjectsPluginStart;
|
||||
}
|
||||
|
@ -50,6 +52,7 @@ export interface UptimeCorePluginsSetup {
|
|||
observability: ObservabilityPluginSetup;
|
||||
usageCollection: UsageCollectionSetup;
|
||||
ml: MlSetup;
|
||||
cloud?: CloudSetup;
|
||||
ruleRegistry: RuleRegistryPluginSetupContract;
|
||||
encryptedSavedObjects: EncryptedSavedObjectsPluginSetup;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,65 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
|
||||
import { getEsHosts } from './get_es_hosts';
|
||||
import { CloudSetup } from '../../../../cloud/server';
|
||||
|
||||
describe('getEsHostsTest', () => {
|
||||
const cloudSetup = {
|
||||
cloudId:
|
||||
'TLS_Test:dXMtY2VudHJhbDEuZ2NwLmNsb3VkLmVzLmlvJDI0ZDYwY2NjYmZjODRhZmZhNGRjYTQ3M2M2YjFlZDgwJGUxMjkyY2YzMTczZTRkNTViZDViM2NlNzYyZDg1NzY3',
|
||||
isCloudEnabled: true,
|
||||
} as CloudSetup;
|
||||
|
||||
it('should return expected host in cloud', function () {
|
||||
const esHosts = getEsHosts({
|
||||
cloud: cloudSetup,
|
||||
config: {},
|
||||
});
|
||||
|
||||
expect(esHosts).toEqual([
|
||||
'https://24d60cccbfc84affa4dca473c6b1ed80.us-central1.gcp.cloud.es.io:443',
|
||||
]);
|
||||
});
|
||||
|
||||
it('should return expected host from config', function () {
|
||||
const esHosts = getEsHosts({
|
||||
config: {
|
||||
unsafe: {
|
||||
service: {
|
||||
hosts: ['http://localhost:9200'],
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
expect(esHosts).toEqual(['http://localhost:9200']);
|
||||
});
|
||||
it('should return cloud hosts when both config and cloud are present', function () {
|
||||
const esHosts = getEsHosts({
|
||||
cloud: cloudSetup,
|
||||
config: {
|
||||
unsafe: {
|
||||
service: {
|
||||
hosts: ['http://localhost:9200'],
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
expect(esHosts).toEqual([
|
||||
'https://24d60cccbfc84affa4dca473c6b1ed80.us-central1.gcp.cloud.es.io:443',
|
||||
]);
|
||||
});
|
||||
});
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
|
||||
import { CloudSetup } from '../../../../cloud/server';
|
||||
import { decodeCloudId } from '../../../../fleet/common';
|
||||
import { UptimeConfig } from '../../../common/config';
|
||||
|
||||
export function getEsHosts({
|
||||
cloud,
|
||||
config,
|
||||
}: {
|
||||
cloud?: CloudSetup;
|
||||
config: UptimeConfig;
|
||||
}): string[] {
|
||||
const cloudId = cloud?.isCloudEnabled && cloud.cloudId;
|
||||
const cloudUrl = cloudId && decodeCloudId(cloudId)?.elasticsearchUrl;
|
||||
const cloudHosts = cloudUrl ? [cloudUrl] : undefined;
|
||||
if (cloudHosts && cloudHosts.length > 0) {
|
||||
return cloudHosts;
|
||||
}
|
||||
|
||||
const flagHosts = config?.unsafe?.service?.hosts;
|
||||
|
||||
if (flagHosts && flagHosts.length > 0) {
|
||||
return flagHosts;
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
|
@ -59,7 +59,11 @@ export class Plugin implements PluginType {
|
|||
],
|
||||
});
|
||||
|
||||
this.server = { router: core.http.createRouter(), config } as UptimeCoreSetup;
|
||||
this.server = {
|
||||
router: core.http.createRouter(),
|
||||
config,
|
||||
cloud: plugins.cloud,
|
||||
} as UptimeCoreSetup;
|
||||
|
||||
initServerWithKibana(this.server, plugins, ruleDataClient, this.logger);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue