[Uptime] [Synthetics Service] adds Kibana version to service call for synthetics (#123434)

* uptime - adds kibana version to service call for synthetics

* add kibana version to uptime server context
This commit is contained in:
Dominique Clarke 2022-01-28 15:56:50 -05:00 committed by GitHub
parent 52e613a48e
commit 624a50abd7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 3 deletions

View file

@ -50,6 +50,7 @@ export interface UptimeServerSetup {
authSavedObjectsClient?: SavedObjectsClientContract;
encryptedSavedObjects: EncryptedSavedObjectsPluginStart;
syntheticsService: SyntheticsService;
kibanaVersion: string;
}
export interface UptimeCorePluginsSetup {

View file

@ -34,12 +34,14 @@ export class ServiceAPIClient {
private locations: ServiceLocations;
private logger: Logger;
private readonly config: ServiceConfig;
private readonly kibanaVersion: string;
constructor(logger: Logger, config: ServiceConfig) {
constructor(logger: Logger, config: ServiceConfig, kibanaVersion: string) {
this.config = config;
const { username, password, manifestUrl, devUrl } = config;
this.username = username;
this.devUrl = devUrl;
this.kibanaVersion = kibanaVersion;
if (username && password) {
this.authorization = 'Basic ' + Buffer.from(`${username}:${password}`).toString('base64');
@ -102,7 +104,7 @@ export class ServiceAPIClient {
return axios({
method,
url: (this.devUrl ?? url) + (runOnce ? '/run' : '/monitors'),
data: { monitors: monitorsStreams, output },
data: { monitors: monitorsStreams, output, stack_version: this.kibanaVersion },
headers: this.authorization
? {
Authorization: this.authorization,

View file

@ -50,7 +50,7 @@ export class SyntheticsService {
this.server = server;
this.config = config;
this.apiClient = new ServiceAPIClient(logger, this.config);
this.apiClient = new ServiceAPIClient(logger, this.config, this.server.kibanaVersion);
this.esHosts = getEsHosts({ config: this.config, cloud: server.cloud });
}

View file

@ -71,6 +71,7 @@ export class Plugin implements PluginType {
config,
router: core.http.createRouter(),
cloud: plugins.cloud,
kibanaVersion: this.initContext.env.packageInfo.version,
} as UptimeServerSetup;
if (this.server?.config?.service?.enabled) {