-
Notifications
You must be signed in to change notification settings - Fork 8.3k
/
config.ts
105 lines (97 loc) · 3.61 KB
/
config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import { schema, TypeOf } from '@kbn/config-schema';
import {
config as ElasticsearchBaseConfig,
ElasticsearchConfig,
} from '../../../../src/core/server/';
const hostURISchema = schema.uri({ scheme: ['http', 'https'] });
const elasticsearchConfigSchema = ElasticsearchBaseConfig.elasticsearch.schema;
type ElasticsearchConfigType = TypeOf<typeof elasticsearchConfigSchema>;
export const monitoringElasticsearchConfigSchema = elasticsearchConfigSchema.extends({
logFetchCount: schema.number({ defaultValue: 10 }),
hosts: schema.maybe(schema.oneOf([hostURISchema, schema.arrayOf(hostURISchema, { minSize: 1 })])),
});
export const configSchema = schema.object({
enabled: schema.boolean({ defaultValue: true }),
ui: schema.object({
enabled: schema.boolean({ defaultValue: true }),
debug_mode: schema.boolean({ defaultValue: false }),
debug_log_path: schema.string({ defaultValue: '' }),
ccs: schema.object({
enabled: schema.boolean({ defaultValue: true }),
}),
logs: schema.object({
index: schema.string({ defaultValue: 'filebeat-*' }),
}),
metricbeat: schema.object({
index: schema.string({ defaultValue: 'metricbeat-*' }),
}),
max_bucket_size: schema.number({ defaultValue: 10000 }),
elasticsearch: monitoringElasticsearchConfigSchema,
container: schema.object({
elasticsearch: schema.object({
enabled: schema.boolean({ defaultValue: false }),
}),
apm: schema.object({
enabled: schema.boolean({ defaultValue: false }),
}),
logstash: schema.object({
enabled: schema.boolean({ defaultValue: false }),
}),
}),
min_interval_seconds: schema.number({ defaultValue: 10 }),
show_license_expiration: schema.boolean({ defaultValue: true }),
render_react_app: schema.boolean({ defaultValue: false }),
}),
kibana: schema.object({
collection: schema.object({
enabled: schema.boolean({ defaultValue: true }),
interval: schema.number({ defaultValue: 10000 }), // op status metrics get buffered at `ops.interval` and flushed to the bulk endpoint at this interval
}),
}),
cluster_alerts: schema.object({
allowedSpaces: schema.arrayOf(schema.string(), { defaultValue: ['default'] }),
enabled: schema.boolean({ defaultValue: true }),
email_notifications: schema.object({
enabled: schema.boolean({ defaultValue: true }),
email_address: schema.string({ defaultValue: '' }),
}),
}),
licensing: schema.object({
api_polling_frequency: schema.duration({
defaultValue: '30s',
}),
}),
agent: schema.object({
interval: schema.string({ defaultValue: '10s' }),
// TOOD: NP
// .regex(/[\d\.]+[yMwdhms]/)
}),
tests: schema.object({
cloud_detector: schema.object({
enabled: schema.boolean({ defaultValue: true }),
}),
}),
});
export class MonitoringElasticsearchConfig extends ElasticsearchConfig {
public readonly logFetchCount?: number;
constructor(rawConfig: TypeOf<typeof monitoringElasticsearchConfigSchema>) {
super(rawConfig as ElasticsearchConfigType);
this.logFetchCount = rawConfig.logFetchCount;
}
}
export type MonitoringConfig = ReturnType<typeof createConfig>;
export function createConfig(config: TypeOf<typeof configSchema>) {
return {
...config,
ui: {
...config.ui,
elasticsearch: new MonitoringElasticsearchConfig(config.ui.elasticsearch),
},
};
}