-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[Beats Management] Move to Ingest UI arch and initial TS effort #20039
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 35 commits
e96973f
f48ba09
934ce9d
625d2cc
705bd00
725daa2
06f2506
2bb3fbf
f28c61d
d8ac2a9
2c86794
aa636aa
5886ebd
4cee944
0305f9f
f4ab093
fb3baea
e1e6fdd
e91867d
b6480bd
1edda86
56ec992
f4c28ea
cb34d4c
70dc670
0202118
7eacf7a
f925c06
d91e414
8738ad0
730353c
3f6df69
8d70b50
0b2d0a0
2ab2dff
21838ed
980e678
37adfdc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,7 +27,11 @@ | |
| "@kbn/es": "link:../packages/kbn-es", | ||
| "@kbn/plugin-helpers": "link:../packages/kbn-plugin-helpers", | ||
| "@kbn/test": "link:../packages/kbn-test", | ||
| "@types/boom": "^4.3.8", | ||
| "@types/hapi": "15.0.1", | ||
| "@types/jest": "^22.2.3", | ||
| "@types/joi": "^10.4.4", | ||
| "@types/lodash": "^4.14.107", | ||
|
||
| "@types/pngjs": "^3.3.1", | ||
| "abab": "^1.0.4", | ||
| "ansicolors": "0.3.2", | ||
|
|
@@ -85,6 +89,7 @@ | |
| "@kbn/ui-framework": "link:../packages/kbn-ui-framework", | ||
| "@samverschueren/stream-to-observable": "^0.3.0", | ||
| "@slack/client": "^4.2.2", | ||
| "@types/uuid": "^3.4.3", | ||
| "angular-paging": "2.2.1", | ||
| "angular-resource": "1.4.9", | ||
| "angular-sanitize": "1.4.9", | ||
|
|
||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| /* | ||
| * 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. | ||
| */ | ||
|
|
||
| export enum ConfigurationBlockTypes { | ||
| FilebeatInputs = 'filebeat.inputs', | ||
| FilebeatModules = 'filebeat.modules', | ||
| MetricbeatModules = 'metricbeat.modules', | ||
| Output = 'output', | ||
| Processors = 'processors', | ||
| } | ||
|
|
||
| export const UNIQUENESS_ENFORCING_TYPES = [ConfigurationBlockTypes.Output]; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,5 +5,5 @@ | |
| */ | ||
|
|
||
| export const INDEX_NAMES = { | ||
| BEATS: '.management-beats' | ||
| BEATS: '.management-beats', | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,5 +5,5 @@ | |
| */ | ||
|
|
||
| export const PLUGIN = { | ||
| ID: 'beats' | ||
| ID: 'beats', | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| /* | ||
| * 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 { Server } from 'hapi'; | ||
| import { compose } from './lib/compose/kibana'; | ||
| import { initManagementServer } from './management_server'; | ||
|
|
||
| export const initServerWithKibana = (hapiServer: Server) => { | ||
| const libs = compose(hapiServer); | ||
| initManagementServer(libs); | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,217 @@ | ||
| /* | ||
| * 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 { flatten, get, omit } from 'lodash'; | ||
| import moment from 'moment'; | ||
| import { INDEX_NAMES } from '../../../../common/constants'; | ||
| import { | ||
| BackendFrameworkAdapter, | ||
| CMBeat, | ||
| CMBeatsAdapter, | ||
| CMTagAssignment, | ||
| FrameworkRequest, | ||
| } from '../../lib'; | ||
|
|
||
| export class ElasticsearchBeatsAdapter implements CMBeatsAdapter { | ||
| private framework: BackendFrameworkAdapter; | ||
|
|
||
| constructor(framework: BackendFrameworkAdapter) { | ||
| this.framework = framework; | ||
| } | ||
|
|
||
| public async get(id: string) { | ||
| const params = { | ||
| id: `beat:${id}`, | ||
| ignore: [404], | ||
| index: INDEX_NAMES.BEATS, | ||
| type: '_doc', | ||
| }; | ||
|
|
||
| const response = await this.framework.callWithInternalUser('get', params); | ||
| if (!response.found) { | ||
| return null; | ||
| } | ||
|
|
||
| return get(response, '_source.beat'); | ||
| } | ||
|
|
||
| public async insert(beat: CMBeat) { | ||
| const body = { | ||
| beat, | ||
| type: 'beat', | ||
| }; | ||
|
|
||
| const params = { | ||
| body, | ||
| id: `beat:${beat.id}`, | ||
| index: INDEX_NAMES.BEATS, | ||
| refresh: 'wait_for', | ||
| type: '_doc', | ||
| }; | ||
| await this.framework.callWithInternalUser('create', params); | ||
| } | ||
|
|
||
| public async update(beat: CMBeat) { | ||
| const body = { | ||
| beat, | ||
| type: 'beat', | ||
| }; | ||
|
|
||
| const params = { | ||
| body, | ||
| id: `beat:${beat.id}`, | ||
| index: INDEX_NAMES.BEATS, | ||
| refresh: 'wait_for', | ||
| type: '_doc', | ||
| }; | ||
| return await this.framework.callWithInternalUser('index', params); | ||
| } | ||
|
|
||
| public async getWithIds(req: FrameworkRequest, beatIds: string[]) { | ||
| const ids = beatIds.map(beatId => `beat:${beatId}`); | ||
|
|
||
| const params = { | ||
| _source: false, | ||
| body: { | ||
| ids, | ||
| }, | ||
| index: INDEX_NAMES.BEATS, | ||
| type: '_doc', | ||
| }; | ||
| const response = await this.framework.callWithRequest(req, 'mget', params); | ||
| return get(response, 'docs', []); | ||
| } | ||
|
|
||
| // TODO merge with getBeatsWithIds | ||
| public async getVerifiedWithIds(req: FrameworkRequest, beatIds: string[]) { | ||
| const ids = beatIds.map(beatId => `beat:${beatId}`); | ||
|
|
||
| const params = { | ||
| _sourceInclude: ['beat.id', 'beat.verified_on'], | ||
| body: { | ||
| ids, | ||
| }, | ||
| index: INDEX_NAMES.BEATS, | ||
| type: '_doc', | ||
| }; | ||
| const response = await this.framework.callWithRequest(req, 'mget', params); | ||
| return get(response, 'docs', []); | ||
| } | ||
|
|
||
| public async verifyBeats(req: FrameworkRequest, beatIds: string[]) { | ||
| if (!Array.isArray(beatIds) || beatIds.length === 0) { | ||
| return []; | ||
| } | ||
|
|
||
| const verifiedOn = moment().toJSON(); | ||
| const body = flatten( | ||
| beatIds.map(beatId => [ | ||
| { update: { _id: `beat:${beatId}` } }, | ||
| { doc: { beat: { verified_on: verifiedOn } } }, | ||
| ]) | ||
| ); | ||
|
|
||
| const params = { | ||
| body, | ||
| index: INDEX_NAMES.BEATS, | ||
| refresh: 'wait_for', | ||
| type: '_doc', | ||
| }; | ||
|
|
||
| const response = await this.framework.callWithRequest(req, 'bulk', params); | ||
| return get(response, 'items', []); | ||
| } | ||
|
|
||
| public async getAll(req: FrameworkRequest) { | ||
| const params = { | ||
| index: INDEX_NAMES.BEATS, | ||
| q: 'type:beat', | ||
| type: '_doc', | ||
| }; | ||
| const response = await this.framework.callWithRequest( | ||
| req, | ||
| 'search', | ||
| params | ||
| ); | ||
|
|
||
| const beats = get(response, 'hits.hits', []); | ||
| return beats.map(beat => omit(beat._source.beat, ['access_token'])); | ||
| } | ||
|
|
||
| public async removeTagsFromBeats( | ||
| req: FrameworkRequest, | ||
| removals: CMTagAssignment[] | ||
| ): Promise<CMTagAssignment[]> { | ||
| const body = flatten( | ||
| removals.map(({ beatId, tag }) => { | ||
| const script = | ||
| '' + | ||
| 'def beat = ctx._source.beat; ' + | ||
| 'if (beat.tags != null) { ' + | ||
| ' beat.tags.removeAll([params.tag]); ' + | ||
| '}'; | ||
|
|
||
| return [ | ||
| { update: { _id: `beat:${beatId}` } }, | ||
| { script: { source: script, params: { tag } } }, | ||
| ]; | ||
| }) | ||
| ); | ||
|
|
||
| const params = { | ||
| body, | ||
| index: INDEX_NAMES.BEATS, | ||
| refresh: 'wait_for', | ||
| type: '_doc', | ||
| }; | ||
|
|
||
| const response = await this.framework.callWithRequest(req, 'bulk', params); | ||
| return get(response, 'items', []).map((item, resultIdx) => ({ | ||
| idxInRequest: removals[resultIdx].idxInRequest, | ||
| result: item.update.result, | ||
| status: item.update.status, | ||
| })); | ||
| } | ||
|
|
||
| // formerly persistAssignments | ||
|
||
| public async assignTagsToBeats( | ||
| req: FrameworkRequest, | ||
| assignments: CMTagAssignment[] | ||
| ): Promise<CMTagAssignment[]> { | ||
| const body = flatten( | ||
| assignments.map(({ beatId, tag }) => { | ||
| const script = | ||
| '' + | ||
| 'def beat = ctx._source.beat; ' + | ||
| 'if (beat.tags == null) { ' + | ||
| ' beat.tags = []; ' + | ||
| '} ' + | ||
| 'if (!beat.tags.contains(params.tag)) { ' + | ||
| ' beat.tags.add(params.tag); ' + | ||
| '}'; | ||
|
|
||
| return [ | ||
| { update: { _id: `beat:${beatId}` } }, | ||
| { script: { source: script, params: { tag } } }, | ||
| ]; | ||
| }) | ||
| ); | ||
|
|
||
| const params = { | ||
| body, | ||
| index: INDEX_NAMES.BEATS, | ||
| refresh: 'wait_for', | ||
| type: '_doc', | ||
| }; | ||
|
|
||
| const response = await this.framework.callWithRequest(req, 'bulk', params); | ||
| return get(response, 'items', []).map((item, resultIdx) => ({ | ||
| idxInRequest: assignments[resultIdx].idxInRequest, | ||
| result: item.update.result, | ||
| status: item.update.status, | ||
| })); | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
ts-loaderwebpack config already sets this depending on thesourceMapskibana config:kibana/src/optimize/base_optimizer.js
Line 303 in d8c7970
Setting it here might lead to undesired artifacts in the build output. Maybe we want to ask the kibana platform team for their perspective?