feat: mock plugins with real configs
so you no longer need to comment out xpack config in the kibana.dev.yml
This commit is contained in:
41
index.js
41
index.js
@@ -1,17 +1,30 @@
|
||||
export default function (kibana) {
|
||||
import { xpackMain } from "./plugins/xpack_main";
|
||||
import { apm } from "./plugins/apm";
|
||||
import { graph } from "./plugins/graph";
|
||||
import { ml } from "./plugins/ml";
|
||||
import { monitoring } from "./plugins/monitoring";
|
||||
import { reporting } from "./plugins/reporting";
|
||||
import { security } from "./plugins/security";
|
||||
|
||||
const fakeXpack = kibana => {
|
||||
return new kibana.Plugin({
|
||||
require: [],
|
||||
name: 'xpack_main',
|
||||
id: 'xpack_main',
|
||||
configPrefix: 'xpack.xpack_main',
|
||||
config(Joi) {
|
||||
return Joi.object({
|
||||
enabled: Joi.boolean().default(true),
|
||||
xpack_api_polling_frequency_millis: Joi.number().default(30000),
|
||||
}).default();
|
||||
},
|
||||
name: "fake_xpack",
|
||||
id: "fake_xpack",
|
||||
init() {
|
||||
console.log('FAKE X-PACK IN FULL EFFECT! [xpack_main]');
|
||||
},
|
||||
});
|
||||
console.log("FAKE X-PACK IN FULL EFFECT! [xpack_main]");
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export default function(kibana) {
|
||||
return [
|
||||
fakeXpack(kibana),
|
||||
xpackMain(kibana),
|
||||
apm(kibana),
|
||||
graph(kibana),
|
||||
ml(kibana),
|
||||
monitoring(kibana),
|
||||
reporting(kibana),
|
||||
security(kibana)
|
||||
];
|
||||
}
|
||||
|
||||
18
plugins/apm/index.js
Normal file
18
plugins/apm/index.js
Normal file
@@ -0,0 +1,18 @@
|
||||
export function apm(kibana) {
|
||||
return new kibana.Plugin({
|
||||
name: 'apm',
|
||||
id: 'apm',
|
||||
configPrefix: 'xpack.apm',
|
||||
config(Joi) {
|
||||
return Joi.object({
|
||||
ui: Joi.object({
|
||||
enabled: Joi.boolean().default(true),
|
||||
}).default(),
|
||||
enabled: Joi.boolean().default(true),
|
||||
indexPattern: Joi.string().default('apm*'),
|
||||
minimumBucketSize: Joi.number().default(15),
|
||||
bucketTargetCount: Joi.number().default(27),
|
||||
}).default();
|
||||
},
|
||||
});
|
||||
}
|
||||
1
plugins/constants.js
Normal file
1
plugins/constants.js
Normal file
@@ -0,0 +1 @@
|
||||
export const XPACK_INFO_API_DEFAULT_POLL_FREQUENCY_IN_MILLIS = 30000;
|
||||
16
plugins/graph/index.js
Normal file
16
plugins/graph/index.js
Normal file
@@ -0,0 +1,16 @@
|
||||
export function graph(kibana) {
|
||||
return new kibana.Plugin({
|
||||
name: 'graph',
|
||||
id: 'graph',
|
||||
configPrefix: 'xpack.graph',
|
||||
config(Joi) {
|
||||
return Joi.object({
|
||||
enabled: Joi.boolean().default(true),
|
||||
canEditDrillDownUrls: Joi.boolean().default(true),
|
||||
savePolicy: Joi.string()
|
||||
.valid(['config', 'configAndDataWithConsent', 'configAndData', 'none'])
|
||||
.default('configAndData'),
|
||||
}).default();
|
||||
},
|
||||
});
|
||||
}
|
||||
12
plugins/ml/index.js
Normal file
12
plugins/ml/index.js
Normal file
@@ -0,0 +1,12 @@
|
||||
export function ml(kibana) {
|
||||
return new kibana.Plugin({
|
||||
name: 'ml',
|
||||
id: 'ml',
|
||||
configPrefix: 'xpack.ml',
|
||||
config(Joi) {
|
||||
return Joi.object({
|
||||
enabled: Joi.boolean().default(true),
|
||||
}).default();
|
||||
},
|
||||
});
|
||||
}
|
||||
101
plugins/monitoring/index.js
Normal file
101
plugins/monitoring/index.js
Normal file
@@ -0,0 +1,101 @@
|
||||
import {
|
||||
XPACK_INFO_API_DEFAULT_POLL_FREQUENCY_IN_MILLIS,
|
||||
} from "../constants";
|
||||
|
||||
export function monitoring(kibana) {
|
||||
return new kibana.Plugin({
|
||||
name: "monitoring",
|
||||
id: "monitoring",
|
||||
configPrefix: "xpack.monitoring",
|
||||
config(Joi) {
|
||||
const { array, boolean, number, object, string } = Joi;
|
||||
const DEFAULT_REQUEST_HEADERS = ["authorization"];
|
||||
|
||||
return object({
|
||||
ccs: object({
|
||||
enabled: boolean().default(true)
|
||||
}).default(),
|
||||
enabled: boolean().default(true),
|
||||
ui: object({
|
||||
enabled: boolean().default(true),
|
||||
container: object({
|
||||
elasticsearch: object({
|
||||
enabled: boolean().default(false)
|
||||
}).default(),
|
||||
logstash: object({
|
||||
enabled: boolean().default(false)
|
||||
}).default()
|
||||
}).default()
|
||||
}).default(),
|
||||
index_pattern: string().default(".monitoring-*-2-*,.monitoring-*-6-*"),
|
||||
kibana: object({
|
||||
index_pattern: string().default(
|
||||
".monitoring-kibana-2-*,.monitoring-kibana-6-*"
|
||||
),
|
||||
collection: object({
|
||||
enabled: boolean().default(true),
|
||||
interval: number().default(10000) // op status metrics get buffered at `ops.interval` and flushed to the bulk endpoint at this interval
|
||||
}).default()
|
||||
}).default(),
|
||||
logstash: object({
|
||||
index_pattern: string().default(
|
||||
".monitoring-logstash-2-*,.monitoring-logstash-6-*"
|
||||
)
|
||||
}).default(),
|
||||
beats: object({
|
||||
index_pattern: string().default(".monitoring-beats-6-*")
|
||||
}).default(),
|
||||
cluster_alerts: object({
|
||||
enabled: boolean().default(true),
|
||||
index: string().default(".monitoring-alerts-6"),
|
||||
email_notifications: object({
|
||||
enabled: boolean().default(true)
|
||||
}).default()
|
||||
}).default(),
|
||||
xpack_api_polling_frequency_millis: number().default(
|
||||
XPACK_INFO_API_DEFAULT_POLL_FREQUENCY_IN_MILLIS
|
||||
),
|
||||
max_bucket_size: number().default(10000),
|
||||
min_interval_seconds: number().default(10),
|
||||
show_license_expiration: boolean().default(true),
|
||||
report_stats: boolean().default(true),
|
||||
node_resolver: string()
|
||||
.valid("uuid")
|
||||
.default("uuid"), // deprecated in 5.6; we can make them set it properly before we remove it
|
||||
agent: object({
|
||||
interval: string()
|
||||
.regex(/[\d\.]+[yMwdhms]/)
|
||||
.default("10s")
|
||||
}).default(),
|
||||
elasticsearch: object({
|
||||
customHeaders: object().default({}),
|
||||
index_pattern: string().default(
|
||||
".monitoring-es-2-*,.monitoring-es-6-*"
|
||||
),
|
||||
logQueries: boolean().default(false),
|
||||
requestHeadersWhitelist: array()
|
||||
.items()
|
||||
.single()
|
||||
.default(DEFAULT_REQUEST_HEADERS),
|
||||
url: string().uri({ scheme: ["http", "https"] }), // if empty, use Kibana's connection config
|
||||
username: string(),
|
||||
password: string(),
|
||||
requestTimeout: number().default(30000),
|
||||
pingTimeout: number().default(30000),
|
||||
ssl: object({
|
||||
verificationMode: string()
|
||||
.valid("none", "certificate", "full")
|
||||
.default("full"),
|
||||
certificateAuthorities: array()
|
||||
.single()
|
||||
.items(string()),
|
||||
certificate: string(),
|
||||
key: string(),
|
||||
keyPassphrase: string()
|
||||
}).default(),
|
||||
apiVersion: string().default("master")
|
||||
}).default()
|
||||
}).default();
|
||||
}
|
||||
});
|
||||
}
|
||||
134
plugins/reporting/index.js
Normal file
134
plugins/reporting/index.js
Normal file
@@ -0,0 +1,134 @@
|
||||
const appConfig = { concurrency: 4 };
|
||||
const getDefaultBrowser = async () => 'phantom';
|
||||
const getDefaultChromiumSandboxDisabled = async () => true;
|
||||
|
||||
export function reporting(kibana) {
|
||||
return new kibana.Plugin({
|
||||
name: "reporting",
|
||||
id: "reporting",
|
||||
configPrefix: "xpack.reporting",
|
||||
async config(Joi) {
|
||||
return Joi.object({
|
||||
enabled: Joi.boolean().default(true),
|
||||
kibanaServer: Joi.object({
|
||||
protocol: Joi.string().valid(["http", "https"]),
|
||||
hostname: Joi.string(),
|
||||
port: Joi.number().integer()
|
||||
}).default(),
|
||||
queue: Joi.object({
|
||||
indexInterval: Joi.string().default("week"),
|
||||
pollInterval: Joi.number()
|
||||
.integer()
|
||||
.default(3000),
|
||||
pollIntervalErrorMultiplier: Joi.number()
|
||||
.integer()
|
||||
.default(10),
|
||||
timeout: Joi.number()
|
||||
.integer()
|
||||
.default(30000)
|
||||
}).default(),
|
||||
capture: Joi.object({
|
||||
record: Joi.boolean().default(false),
|
||||
zoom: Joi.number()
|
||||
.integer()
|
||||
.default(2),
|
||||
viewport: Joi.object({
|
||||
width: Joi.number()
|
||||
.integer()
|
||||
.default(1950),
|
||||
height: Joi.number()
|
||||
.integer()
|
||||
.default(1200)
|
||||
}).default(),
|
||||
timeout: Joi.number()
|
||||
.integer()
|
||||
.default(20000), //deprecated
|
||||
loadDelay: Joi.number()
|
||||
.integer()
|
||||
.default(3000),
|
||||
settleTime: Joi.number()
|
||||
.integer()
|
||||
.default(1000), //deprecated
|
||||
concurrency: Joi.number()
|
||||
.integer()
|
||||
.default(appConfig.concurrency), //deprecated
|
||||
browser: Joi.object({
|
||||
type: Joi.any()
|
||||
.valid("phantom", "chromium")
|
||||
.default(await getDefaultBrowser()),
|
||||
autoDownload: Joi.boolean().when("$dev", {
|
||||
is: true,
|
||||
then: Joi.default(true),
|
||||
otherwise: Joi.default(false)
|
||||
}),
|
||||
chromium: Joi.object({
|
||||
disableSandbox: Joi.boolean().default(
|
||||
await getDefaultChromiumSandboxDisabled()
|
||||
),
|
||||
proxy: Joi.object({
|
||||
enabled: Joi.boolean().default(false),
|
||||
server: Joi.string()
|
||||
.uri({ scheme: ["http", "https"] })
|
||||
.when("enabled", {
|
||||
is: Joi.valid(false),
|
||||
then: Joi.valid(null),
|
||||
else: Joi.required()
|
||||
}),
|
||||
bypass: Joi.array()
|
||||
.items(Joi.string().regex(/^[^\s]+$/))
|
||||
.when("enabled", {
|
||||
is: Joi.valid(false),
|
||||
then: Joi.valid(null),
|
||||
else: Joi.default([])
|
||||
})
|
||||
}).default(),
|
||||
maxScreenshotDimension: Joi.number()
|
||||
.integer()
|
||||
.default(1950)
|
||||
}).default()
|
||||
}).default()
|
||||
}).default(),
|
||||
csv: Joi.object({
|
||||
maxSizeBytes: Joi.number()
|
||||
.integer()
|
||||
.default(1024 * 1024 * 10), // bytes in a kB * kB in a mB * 10
|
||||
scroll: Joi.object({
|
||||
duration: Joi.string()
|
||||
.regex(/^[0-9]+(d|h|m|s|ms|micros|nanos)$/, {
|
||||
name: "DurationString"
|
||||
})
|
||||
.default("30s"),
|
||||
size: Joi.number()
|
||||
.integer()
|
||||
.default(500)
|
||||
}).default()
|
||||
}).default(),
|
||||
encryptionKey: Joi.string(),
|
||||
roles: Joi.object({
|
||||
allow: Joi.array()
|
||||
.items(Joi.string())
|
||||
.default(["reporting_user"])
|
||||
}).default(),
|
||||
index: Joi.string().default(".reporting"),
|
||||
poll: Joi.object({
|
||||
jobCompletionNotifier: Joi.object({
|
||||
interval: Joi.number()
|
||||
.integer()
|
||||
.default(10000),
|
||||
intervalErrorMultiplier: Joi.number()
|
||||
.integer()
|
||||
.default(5)
|
||||
}).default(),
|
||||
jobsRefresh: Joi.object({
|
||||
interval: Joi.number()
|
||||
.integer()
|
||||
.default(5000),
|
||||
intervalErrorMultiplier: Joi.number()
|
||||
.integer()
|
||||
.default(5)
|
||||
}).default()
|
||||
}).default()
|
||||
}).default();
|
||||
}
|
||||
});
|
||||
}
|
||||
29
plugins/security/index.js
Normal file
29
plugins/security/index.js
Normal file
@@ -0,0 +1,29 @@
|
||||
export function security(kibana) {
|
||||
return new kibana.Plugin({
|
||||
name: 'security',
|
||||
id: 'security',
|
||||
configPrefix: 'xpack.security',
|
||||
config(Joi) {
|
||||
return Joi.object({
|
||||
authProviders: Joi.array()
|
||||
.items(Joi.string())
|
||||
.default(['basic']),
|
||||
enabled: Joi.boolean().default(true),
|
||||
cookieName: Joi.string().default('sid'),
|
||||
encryptionKey: Joi.string(),
|
||||
sessionTimeout: Joi.number()
|
||||
.allow(null)
|
||||
.default(null),
|
||||
secureCookies: Joi.boolean().default(false),
|
||||
public: Joi.object({
|
||||
protocol: Joi.string().valid(['http', 'https']),
|
||||
hostname: Joi.string().hostname(),
|
||||
port: Joi.number()
|
||||
.integer()
|
||||
.min(0)
|
||||
.max(65535),
|
||||
}).default(),
|
||||
}).default();
|
||||
},
|
||||
});
|
||||
}
|
||||
30
plugins/xpack_main/index.js
Normal file
30
plugins/xpack_main/index.js
Normal file
@@ -0,0 +1,30 @@
|
||||
import { XPACK_INFO_API_DEFAULT_POLL_FREQUENCY_IN_MILLIS } from "../constants";
|
||||
|
||||
export function xpackMain(kibana) {
|
||||
return new kibana.Plugin({
|
||||
require: [],
|
||||
name: "xpack_main",
|
||||
id: "xpack_main",
|
||||
configPrefix: "xpack.xpack_main",
|
||||
config(Joi) {
|
||||
return Joi.object({
|
||||
enabled: Joi.boolean().default(true),
|
||||
telemetry: Joi.object({
|
||||
enabled: Joi.boolean().default(true),
|
||||
url: Joi.when("$dev", {
|
||||
is: true,
|
||||
then: Joi.string().default(
|
||||
"https://telemetry-staging.elastic.co/xpack/v1/send"
|
||||
),
|
||||
otherwise: Joi.string().default(
|
||||
"https://telemetry.elastic.co/xpack/v1/send"
|
||||
)
|
||||
})
|
||||
}).default(),
|
||||
xpack_api_polling_frequency_millis: Joi.number().default(
|
||||
XPACK_INFO_API_DEFAULT_POLL_FREQUENCY_IN_MILLIS
|
||||
)
|
||||
}).default();
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user