/
Configuration.java
320 lines (239 loc) · 10.8 KB
/
Configuration.java
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
/**
* This file is part of Graylog.
*
* Graylog is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Graylog is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Graylog. If not, see <http://www.gnu.org/licenses/>.
*/
package org.graylog2;
import com.github.joschi.jadconfig.Parameter;
import com.github.joschi.jadconfig.converters.TrimmedStringSetConverter;
import com.github.joschi.jadconfig.util.Duration;
import com.github.joschi.jadconfig.validators.DirectoryPathReadableValidator;
import com.github.joschi.jadconfig.validators.PositiveDurationValidator;
import com.github.joschi.jadconfig.validators.PositiveIntegerValidator;
import com.github.joschi.jadconfig.validators.PositiveLongValidator;
import com.github.joschi.jadconfig.validators.StringNotBlankValidator;
import org.graylog2.configuration.WebListenUriValidator;
import org.graylog2.plugin.BaseConfiguration;
import org.graylog2.utilities.IPSubnetConverter;
import org.jboss.netty.handler.ipfilter.IpSubnet;
import org.joda.time.DateTimeZone;
import java.net.URI;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Collections;
import java.util.Set;
import static org.graylog2.plugin.Tools.getUriWithDefaultPath;
import static org.graylog2.plugin.Tools.getUriWithPort;
import static org.graylog2.plugin.Tools.getUriWithScheme;
/**
* Helper class to hold configuration of Graylog
*/
@SuppressWarnings("FieldMayBeFinal")
public class Configuration extends BaseConfiguration {
@Parameter(value = "is_master", required = true)
private boolean isMaster = true;
@Parameter(value = "password_secret", required = true, validator = StringNotBlankValidator.class)
private String passwordSecret;
@Parameter(value = "rest_listen_uri", required = true)
private URI restListenUri = URI.create("http://127.0.0.1:" + GRAYLOG_DEFAULT_PORT + "/");
@Parameter(value = "web_listen_uri", required = true, validator = WebListenUriValidator.class)
private URI webListenUri = URI.create("http://127.0.0.1:" + GRAYLOG_DEFAULT_WEB_PORT + "/");
@Parameter(value = "output_batch_size", required = true, validator = PositiveIntegerValidator.class)
private int outputBatchSize = 500;
@Parameter(value = "output_flush_interval", required = true, validator = PositiveIntegerValidator.class)
private int outputFlushInterval = 1;
@Parameter(value = "outputbuffer_processors", required = true, validator = PositiveIntegerValidator.class)
private int outputBufferProcessors = 3;
@Parameter(value = "outputbuffer_processor_threads_max_pool_size", required = true, validator = PositiveIntegerValidator.class)
private int outputBufferProcessorThreadsMaxPoolSize = 30;
@Parameter(value = "outputbuffer_processor_threads_core_pool_size", required = true, validator = PositiveIntegerValidator.class)
private int outputBufferProcessorThreadsCorePoolSize = 3;
@Parameter(value = "outputbuffer_processor_keep_alive_time", validator = PositiveIntegerValidator.class)
private int outputBufferProcessorKeepAliveTime = 5000;
@Parameter("rules_file")
private String droolsRulesFile;
@Parameter(value = "node_id_file")
private String nodeIdFile = "/etc/graylog/server/node-id";
@Parameter(value = "root_username")
private String rootUsername = "admin";
@Parameter(value = "root_password_sha2", required = true)
private String rootPasswordSha2;
@Parameter(value = "root_timezone")
private DateTimeZone rootTimeZone = DateTimeZone.UTC;
@Parameter(value = "root_email")
private String rootEmail = "";
@Parameter(value = "allow_leading_wildcard_searches")
private boolean allowLeadingWildcardSearches = false;
@Parameter(value = "allow_highlighting")
private boolean allowHighlighting = false;
@Parameter(value = "enable_metrics_collection")
private boolean metricsCollectionEnabled = false;
@Parameter(value = "lb_recognition_period_seconds", validator = PositiveIntegerValidator.class)
private int loadBalancerRecognitionPeriodSeconds = 3;
@Parameter(value = "stream_processing_timeout", validator = PositiveLongValidator.class)
private long streamProcessingTimeout = 2000;
@Parameter(value = "stream_processing_max_faults", validator = PositiveIntegerValidator.class)
private int streamProcessingMaxFaults = 3;
@Parameter(value = "output_module_timeout", validator = PositiveLongValidator.class)
private long outputModuleTimeout = 10000;
@Parameter(value = "output_fault_count_threshold", validator = PositiveLongValidator.class)
private long outputFaultCountThreshold = 5;
@Parameter(value = "output_fault_penalty_seconds", validator = PositiveLongValidator.class)
private long outputFaultPenaltySeconds = 30;
@Parameter(value = "stale_master_timeout", validator = PositiveIntegerValidator.class)
private int staleMasterTimeout = 2000;
@Parameter(value = "ldap_connection_timeout", validator = PositiveIntegerValidator.class)
private int ldapConnectionTimeout = 2000;
@Parameter(value = "alert_check_interval", validator = PositiveIntegerValidator.class)
private int alertCheckInterval = 60;
@Parameter(value = "gc_warning_threshold")
private Duration gcWarningThreshold = Duration.seconds(1L);
@Parameter(value = "default_message_output_class")
private String defaultMessageOutputClass = "";
@Parameter(value = "dashboard_widget_default_cache_time", validator = PositiveDurationValidator.class)
private Duration dashboardWidgetDefaultCacheTime = Duration.seconds(10L);
@Parameter(value = "user_password_default_algorithm")
private String userPasswordDefaultAlgorithm = "bcrypt";
@Parameter(value = "user_password_bcrypt_salt_size", validator = PositiveIntegerValidator.class)
private int userPasswordBCryptSaltSize = 10;
@Parameter(value = "content_packs_loader_enabled")
private boolean contentPacksLoaderEnabled = true;
@Parameter(value = "content_packs_dir", validators = DirectoryPathReadableValidator.class)
private Path contentPacksDir = Paths.get("data", "contentpacks");
@Parameter(value = "content_packs_auto_load", converter = TrimmedStringSetConverter.class)
private Set<String> contentPacksAutoLoad = Collections.emptySet();
@Parameter(value = "index_ranges_cleanup_interval", validator = PositiveDurationValidator.class)
private Duration indexRangesCleanupInterval = Duration.hours(1L);
@Parameter(value = "deflector_index_read_only_timeout", validator = PositiveDurationValidator.class)
private Duration deflectorIndexReadOnlyTimeout = Duration.hours(1L);
@Parameter(value = "trusted_proxies", converter = IPSubnetConverter.class)
private Set<IpSubnet> trustedProxies = Collections.emptySet();
public boolean isMaster() {
return isMaster;
}
public void setIsMaster(boolean is) {
isMaster = is;
}
public String getPasswordSecret() {
return passwordSecret.trim();
}
public int getOutputBatchSize() {
return outputBatchSize;
}
public int getOutputFlushInterval() {
return outputFlushInterval;
}
public int getOutputBufferProcessors() {
return outputBufferProcessors;
}
public int getOutputBufferProcessorThreadsCorePoolSize() {
return outputBufferProcessorThreadsCorePoolSize;
}
public int getOutputBufferProcessorThreadsMaxPoolSize() {
return outputBufferProcessorThreadsMaxPoolSize;
}
public int getOutputBufferProcessorKeepAliveTime() {
return outputBufferProcessorKeepAliveTime;
}
public String getDroolsRulesFile() {
return droolsRulesFile;
}
public String getNodeIdFile() {
return nodeIdFile;
}
@Override
public URI getRestListenUri() {
return getUriWithDefaultPath(getUriWithPort(getUriWithScheme(restListenUri, getRestUriScheme()), GRAYLOG_DEFAULT_PORT), "/");
}
@Override
public URI getWebListenUri() {
return getUriWithDefaultPath(getUriWithPort(getUriWithScheme(webListenUri, getWebUriScheme()), GRAYLOG_DEFAULT_WEB_PORT), "/");
}
public String getRootUsername() {
return rootUsername;
}
public String getRootPasswordSha2() {
return rootPasswordSha2;
}
public DateTimeZone getRootTimeZone() {
return rootTimeZone;
}
public String getRootEmail() {
return rootEmail;
}
public boolean isAllowLeadingWildcardSearches() {
return allowLeadingWildcardSearches;
}
public boolean isAllowHighlighting() {
return allowHighlighting;
}
public boolean isMetricsCollectionEnabled() {
return metricsCollectionEnabled;
}
public int getLoadBalancerRecognitionPeriodSeconds() {
return loadBalancerRecognitionPeriodSeconds;
}
public long getStreamProcessingTimeout() {
return streamProcessingTimeout;
}
public int getStreamProcessingMaxFaults() {
return streamProcessingMaxFaults;
}
public long getOutputModuleTimeout() {
return outputModuleTimeout;
}
public long getOutputFaultCountThreshold() {
return outputFaultCountThreshold;
}
public long getOutputFaultPenaltySeconds() {
return outputFaultPenaltySeconds;
}
public int getStaleMasterTimeout() {
return staleMasterTimeout;
}
public int getLdapConnectionTimeout() {
return ldapConnectionTimeout;
}
public int getAlertCheckInterval() {
return alertCheckInterval;
}
public Duration getGcWarningThreshold() {
return gcWarningThreshold;
}
public String getDefaultMessageOutputClass() {
return defaultMessageOutputClass;
}
public Duration getDashboardWidgetDefaultCacheTime() {
return dashboardWidgetDefaultCacheTime;
}
public String getUserPasswordDefaultAlgorithm() {
return userPasswordDefaultAlgorithm;
}
public int getUserPasswordBCryptSaltSize() {
return userPasswordBCryptSaltSize;
}
public boolean isContentPacksLoaderEnabled() {
return contentPacksLoaderEnabled;
}
public Path getContentPacksDir() {
return contentPacksDir;
}
public Set<String> getContentPacksAutoLoad() {
return contentPacksAutoLoad;
}
public Duration getIndexRangesCleanupInterval() {
return indexRangesCleanupInterval;
}
public Set<IpSubnet> getTrustedProxies() { return trustedProxies; }
}