Skip to content
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

[6.x] Backport Beats Management (#23819) #24185

Merged
merged 1 commit into from
Oct 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@
"type": "git",
"url": "https://github.com/elastic/kibana.git"
},
"resolutions": {
"**/@types/node": "8.10.21"
},
"dependencies": {
"@elastic/eui": "4.4.1",
"@elastic/filesaver": "1.1.2",
Expand Down Expand Up @@ -234,9 +237,9 @@
"@kbn/eslint-plugin-license-header": "link:packages/kbn-eslint-plugin-license-header",
"@kbn/plugin-generator": "link:packages/kbn-plugin-generator",
"@kbn/test": "link:packages/kbn-test",
"@octokit/rest": "^15.10.0",
"@types/angular": "^1.6.50",
"@types/angular-mocks": "^1.7.0",
"@octokit/rest": "^15.10.0",
"@types/babel-core": "^6.25.5",
"@types/bluebird": "^3.1.1",
"@types/boom": "^7.2.0",
Expand Down
2 changes: 2 additions & 0 deletions x-pack/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { watcher } from './plugins/watcher';
import { grokdebugger } from './plugins/grokdebugger';
import { dashboardMode } from './plugins/dashboard_mode';
import { logstash } from './plugins/logstash';
import { beats } from './plugins/beats_management';
import { apm } from './plugins/apm';
import { licenseManagement } from './plugins/license_management';
import { cloud } from './plugins/cloud';
Expand All @@ -42,6 +43,7 @@ module.exports = function (kibana) {
grokdebugger(kibana),
dashboardMode(kibana),
logstash(kibana),
beats(kibana),
apm(kibana),
canvas(kibana),
licenseManagement(kibana),
Expand Down
8 changes: 7 additions & 1 deletion x-pack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
"intermediateBuildDirectory": "build/plugin/kibana/x-pack"
}
},
"resolutions": {
"**/@types/node": "8.10.21"
},
"devDependencies": {
"@kbn/dev-utils": "link:../packages/kbn-dev-utils",
"@kbn/es": "link:../packages/kbn-es",
Expand All @@ -38,6 +41,7 @@
"@types/history": "^4.6.2",
"@types/jest": "^23.3.1",
"@types/joi": "^10.4.4",
"@types/jsonwebtoken": "^7.2.7",
"@types/lodash": "^3.10.1",
"@types/mocha": "^5.2.5",
"@types/pngjs": "^3.3.1",
Expand All @@ -46,7 +50,7 @@
"@types/react-datepicker": "^1.1.5",
"@types/react-dom": "^16.0.5",
"@types/react-redux": "^6.0.6",
"@types/react-router-dom": "^4.2.6",
"@types/react-router-dom": "4.2.6",
"@types/reduce-reducers": "^0.1.3",
"@types/sinon": "^5.0.1",
"@types/supertest": "^2.0.5",
Expand Down Expand Up @@ -157,6 +161,7 @@
"extract-zip": "1.5.0",
"file-saver": "^1.3.8",
"font-awesome": "4.4.0",
"formsy-react": "^1.1.5",
"get-port": "2.1.0",
"getos": "^3.1.0",
"glob": "6.0.4",
Expand All @@ -173,6 +178,7 @@
"isomorphic-fetch": "2.2.1",
"joi": "6.10.1",
"jquery": "^3.3.1",
"jsonwebtoken": "^8.3.0",
"jstimezonedetect": "1.0.5",
"lodash": "npm:@elastic/[email protected]",
"lodash.clone": "^4.5.0",
Expand Down
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];
11 changes: 11 additions & 0 deletions x-pack/plugins/beats_management/common/constants/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
* 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 { PLUGIN } from './plugin';
export { INDEX_NAMES } from './index_names';
export { UNIQUENESS_ENFORCING_TYPES, ConfigurationBlockTypes } from './configuration_blocks';
export const BASE_PATH = '/management/beats_management/';
export { TABLE_CONFIG } from './table';
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
* 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 const INDEX_NAMES = {
BEATS: '.management-beats',
};
9 changes: 9 additions & 0 deletions x-pack/plugins/beats_management/common/constants/plugin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
* 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 const PLUGIN = {
ID: 'beats_management',
};
12 changes: 12 additions & 0 deletions x-pack/plugins/beats_management/common/constants/table.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* 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 const TABLE_CONFIG = {
INITIAL_ROW_SIZE: 5,
PAGE_SIZE_OPTIONS: [3, 5, 10, 20],
TRUNCATE_TAG_LENGTH: 33,
TRUNCATE_TAG_LENGTH_SMALL: 20,
};
87 changes: 87 additions & 0 deletions x-pack/plugins/beats_management/common/domain_types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/*
* 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 { ConfigurationBlockTypes } from './constants';

export enum FilebeatModuleName {
system = 'system',
apache2 = 'apache2',
nginx = 'nginx',
mongodb = 'mongodb',
elasticsearch = 'elasticsearch',
}

export enum MetricbeatModuleName {
system = 'system',
apache2 = 'apache2',
nginx = 'nginx',
mongodb = 'mongodb',
elasticsearch = 'elasticsearch',
}

export enum OutputType {
elasticsearch = 'elasticsearch',
logstash = 'logstash',
kafka = 'kafka',
console = 'console',
}

export interface FilebeatInputsConfig {
paths: string[];
other: string;
}
export interface FilebeatModuleConfig {
module: FilebeatModuleName;
other: string;
}
export interface MetricbeatModuleConfig {
module: MetricbeatModuleName;
hosts?: string[];
period: string;
other: string;
}

export type ConfigContent = FilebeatInputsConfig | FilebeatModuleConfig | MetricbeatModuleConfig;
export interface ConfigurationBlock {
type: ConfigurationBlockTypes;
description: string;
configs: ConfigContent[];
}

export interface ReturnedConfigurationBlock
extends Pick<ConfigurationBlock, Exclude<keyof ConfigurationBlock, 'configs'>> {
config: ConfigContent;
}

export interface CMBeat {
id: string;
enrollment_token: string;
active: boolean;
access_token: string;
verified_on?: string;
type: string;
version?: string;
host_ip: string;
host_name: string;
ephemeral_id?: string;
last_updated?: string;
event_rate?: string;
local_configuration_yml?: string;
tags?: string[];
central_configuration_yml?: string;
metadata?: {};
name?: string;
}

export interface CMPopulatedBeat extends CMBeat {
full_tags: BeatTag[];
}

export interface BeatTag {
id: string;
configuration_blocks: ConfigurationBlock[];
color?: string;
last_updated: Date;
}
38 changes: 38 additions & 0 deletions x-pack/plugins/beats_management/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* 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 Joi from 'joi';
import { resolve } from 'path';
import { PLUGIN } from './common/constants';
import { initServerWithKibana } from './server/kibana.index';

const DEFAULT_ENROLLMENT_TOKENS_TTL_S = 10 * 60; // 10 minutes

export const config = Joi.object({
enabled: Joi.boolean().default(true),
encryptionKey: Joi.string(),
enrollmentTokensTtlInSeconds: Joi.number()
.integer()
.min(1)
.max(10 * 60 * 14) // No more then 2 weeks for security reasons
.default(DEFAULT_ENROLLMENT_TOKENS_TTL_S),
}).default();
export const configPrefix = 'xpack.beats';

export function beats(kibana: any) {
return new kibana.Plugin({
id: PLUGIN.ID,
require: ['kibana', 'elasticsearch', 'xpack_main'],
publicDir: resolve(__dirname, 'public'),
uiExports: {
managementSections: ['plugins/beats_management'],
},
config: () => config,
configPrefix,
init(server: any) {
initServerWithKibana(server);
},
});
}
14 changes: 14 additions & 0 deletions x-pack/plugins/beats_management/public/app.d.ts
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.
*/

export type FlatObject<T> = { [Key in keyof T]: string };

export interface AppURLState {
beatsKBar?: string;
tagsKBar?: string;
enrollmentToken?: string;
createdTag?: string;
}
Loading