diff --git a/src/core/public/pulse/index.ts b/src/core/public/pulse/index.ts index e527da120b184..cd407a999128d 100644 --- a/src/core/public/pulse/index.ts +++ b/src/core/public/pulse/index.ts @@ -45,13 +45,13 @@ const logger = { export class PulseService { private retriableErrors = 0; private readonly channels: Map; - private readonly instructions: Map> = new Map(); + private readonly instructions$: Map> = new Map(); constructor() { this.channels = new Map( channelNames.map((id): [string, PulseChannel] => { const instructions$ = new Subject(); - this.instructions.set(id, instructions$); + this.instructions$.set(id, instructions$); const channel = new PulseChannel({ id, instructions$, logger }); return [channel.id, channel]; }) @@ -127,8 +127,8 @@ export class PulseService { const responseBody: InstructionsResponse = await response.json(); - responseBody.channels.forEach((channel: PulseChannel) => { - const instructions$ = this.instructions.get(channel.id); + responseBody.channels.forEach(channel => { + const instructions$ = this.instructions$.get(channel.id); if (!instructions$) { throw new Error( `Channel (${channel.id}) from service has no corresponding channel handler in client` diff --git a/src/core/server/pulse/channel.ts b/src/core/server/pulse/channel.ts index 4f93bee5e8284..613c8f51fd5d9 100644 --- a/src/core/server/pulse/channel.ts +++ b/src/core/server/pulse/channel.ts @@ -43,12 +43,12 @@ export class PulseChannel { private readonly collector: any; constructor(private readonly config: ChannelConfig) { - const Collector: PulseCollectorContructor = require(`${__dirname}/collectors/${this.id}`) + const Collector: PulseCollectorConstructor = require(`${__dirname}/collectors/${this.id}`) .Collector; this.collector = new Collector(this.config.logger); } - public async setup(setupContext: ChannelSetupContexxt) { + public async setup(setupContext: ChannelSetupContext) { return this.collector.setup(setupContext); } diff --git a/src/core/server/pulse/index.ts b/src/core/server/pulse/index.ts index 9f1cf4e911ab9..2c1d046eeb48b 100644 --- a/src/core/server/pulse/index.ts +++ b/src/core/server/pulse/index.ts @@ -46,7 +46,7 @@ interface ChannelResponse { instructions: PulseInstruction[]; } -interface InstructionsResponse { +export interface InstructionsResponse { channels: ChannelResponse[]; } diff --git a/x-pack/plugins/pulse_poc/server/channels/default/check_receiving_telemetry.ts b/x-pack/plugins/pulse_poc/server/channels/default/check_receiving_telemetry.ts index def0cd025fb61..c1dc1c8642300 100644 --- a/x-pack/plugins/pulse_poc/server/channels/default/check_receiving_telemetry.ts +++ b/x-pack/plugins/pulse_poc/server/channels/default/check_receiving_telemetry.ts @@ -9,29 +9,29 @@ import { CheckContext } from '../../types'; export async function check(es: IScopedClusterClient, context: CheckContext) { const { deploymentId } = context; - // const response = await es.callAsInternalUser('search', { - // index: 'pulse-poc-raw*', - // size: 0, - // allow_no_indices: true, - // ignore_unavailable: true, - // body: { - // query: { - // term: { - // deployment_id: { - // value: deploymentId, - // }, - // }, - // }, - // }, - // }); + const response = await es.callAsInternalUser('search', { + index: 'pulse-poc-raw*', + size: 0, + allow_no_indices: true, + ignore_unavailable: true, + body: { + query: { + term: { + deployment_id: { + value: deploymentId, + }, + }, + }, + }, + }); - // if (response.hits.total.value > 0) { - // return undefined; - // } else { - return { - owner: 'core', - id: 'pulse_telemetry', - value: 'try_again', - }; - // } + if (response.hits.total.value > 0) { + return undefined; + } else { + return { + owner: 'core', + id: 'pulse_telemetry', + value: 'try_again', + }; + } } diff --git a/x-pack/plugins/pulse_poc/server/channels/errors/check_receiving_errors.ts b/x-pack/plugins/pulse_poc/server/channels/errors/check_receiving_errors.ts index f7d98e949ceb7..a2bc742c99703 100644 --- a/x-pack/plugins/pulse_poc/server/channels/errors/check_receiving_errors.ts +++ b/x-pack/plugins/pulse_poc/server/channels/errors/check_receiving_errors.ts @@ -5,11 +5,12 @@ */ import { IScopedClusterClient } from 'src/core/server'; +import { CheckContext } from '../../types'; -export async function check(es: IScopedClusterClient, deploymentId: string) { +export async function check(es: IScopedClusterClient, { deploymentId, indexName }: CheckContext) { // TODO: modify the search query for full text search const response = await es.callAsInternalUser('search', { - index: 'pulse-poc-raw-errors', + index: indexName, size: 100, allow_no_indices: true, ignore_unavailable: true, diff --git a/x-pack/plugins/pulse_poc/server/plugin.ts b/x-pack/plugins/pulse_poc/server/plugin.ts index e5fb2a991e544..9a4120c623e71 100644 --- a/x-pack/plugins/pulse_poc/server/plugin.ts +++ b/x-pack/plugins/pulse_poc/server/plugin.ts @@ -134,8 +134,10 @@ export class PulsePocPlugin { const { deploymentId } = request.params; const es = context.core.elasticsearch.adminClient; const allChannelCheckResults = this.channels.map(async channel => { - // const indexName = `pulse-poc-raw-${channel.id}`; - const channelChecks = channel.checks.map(check => check.check(es, deploymentId)); + const indexName = `pulse-poc-raw-${channel.id}`; + const channelChecks = channel.checks.map(check => + check.check(es, { deploymentId, indexName }) + ); const checkResults = await Promise.all(channelChecks); const instructions = checkResults.filter((value: any) => Boolean(value)); return {