* fix(NA): log rotation watchers usage * docs(NA): add old value to the example * chore(NA): change warning messages
This commit is contained in:
parent
2eecaf4a8d
commit
192d348632
4 changed files with 23 additions and 11 deletions
|
@ -200,7 +200,7 @@ that feature would not take any effect.
|
|||
|
||||
`logging.rotate.everyBytes:`:: [experimental] *Default: 10485760* The maximum size of a log file (that is `not an exact` limit). After the
|
||||
limit is reached, a new log file is generated. The default size limit is 10485760 (10 MB) and
|
||||
this option should be in the range of 102400 (100KB) to 1073741824 (1GB).
|
||||
this option should be in the range of 1048576 (1 MB) to 1073741824 (1 GB).
|
||||
|
||||
`logging.rotate.keepFiles:`:: [experimental] *Default: 7* The number of most recent rotated log files to keep
|
||||
on disk. Older files are deleted during log rotation. The default value is 7. The `logging.rotate.keepFiles`
|
||||
|
@ -210,7 +210,7 @@ option has to be in the range of 2 to 1024 files.
|
|||
the `logging.rotate.usePolling` is enabled. That option has to be in the range of 5000 to 3600000 milliseconds.
|
||||
|
||||
`logging.rotate.usePolling:`:: [experimental] *Default: false* By default we try to understand the best way to monitoring
|
||||
the log file. However, there is some systems where it could not be always accurate. In those cases, if needed,
|
||||
the log file and warning about it. Please be aware there are some systems where watch api is not accurate. In those cases, in order to get the feature working,
|
||||
the `polling` method could be used enabling that option.
|
||||
|
||||
`logging.silent:`:: *Default: false* Set the value of this setting to `true` to
|
||||
|
|
|
@ -136,8 +136,8 @@ export default () =>
|
|||
.keys({
|
||||
enabled: Joi.boolean().default(false),
|
||||
everyBytes: Joi.number()
|
||||
// > 100KB
|
||||
.greater(102399)
|
||||
// > 1MB
|
||||
.greater(1048576)
|
||||
// < 1GB
|
||||
.less(1073741825)
|
||||
// 10MB
|
||||
|
|
|
@ -204,8 +204,8 @@ describe('LogRotator', () => {
|
|||
expect(logRotator.running).toBe(true);
|
||||
expect(logRotator.usePolling).toBe(false);
|
||||
|
||||
const usePolling = await logRotator._shouldUsePolling();
|
||||
expect(usePolling).toBe(false);
|
||||
const shouldUsePolling = await logRotator._shouldUsePolling();
|
||||
expect(shouldUsePolling).toBe(false);
|
||||
|
||||
await logRotator.stop();
|
||||
});
|
||||
|
@ -231,7 +231,8 @@ describe('LogRotator', () => {
|
|||
await logRotator.start();
|
||||
|
||||
expect(logRotator.running).toBe(true);
|
||||
expect(logRotator.usePolling).toBe(true);
|
||||
expect(logRotator.usePolling).toBe(false);
|
||||
expect(logRotator.shouldUsePolling).toBe(true);
|
||||
|
||||
await logRotator.stop();
|
||||
});
|
||||
|
@ -257,7 +258,8 @@ describe('LogRotator', () => {
|
|||
await logRotator.start();
|
||||
|
||||
expect(logRotator.running).toBe(true);
|
||||
expect(logRotator.usePolling).toBe(true);
|
||||
expect(logRotator.usePolling).toBe(false);
|
||||
expect(logRotator.shouldUsePolling).toBe(true);
|
||||
|
||||
await logRotator.stop();
|
||||
jest.useRealTimers();
|
||||
|
|
|
@ -50,6 +50,7 @@ export class LogRotator {
|
|||
public usePolling: boolean;
|
||||
public pollingInterval: number;
|
||||
private stalkerUsePollingPolicyTestTimeout: NodeJS.Timeout | null;
|
||||
public shouldUsePolling: boolean;
|
||||
|
||||
constructor(config: KibanaConfig, server: Server) {
|
||||
this.config = config;
|
||||
|
@ -64,6 +65,7 @@ export class LogRotator {
|
|||
this.stalker = null;
|
||||
this.usePolling = config.get('logging.rotate.usePolling');
|
||||
this.pollingInterval = config.get('logging.rotate.pollingInterval');
|
||||
this.shouldUsePolling = false;
|
||||
this.stalkerUsePollingPolicyTestTimeout = null;
|
||||
}
|
||||
|
||||
|
@ -150,12 +152,20 @@ export class LogRotator {
|
|||
}
|
||||
|
||||
async _startLogFileSizeMonitor() {
|
||||
this.usePolling = await this._shouldUsePolling();
|
||||
this.usePolling = this.config.get('logging.rotate.usePolling');
|
||||
this.shouldUsePolling = await this._shouldUsePolling();
|
||||
|
||||
if (this.usePolling && this.usePolling !== this.config.get('logging.rotate.usePolling')) {
|
||||
if (this.usePolling && !this.shouldUsePolling) {
|
||||
this.log(
|
||||
['warning', 'logging:rotate'],
|
||||
'The current environment does not support `fs.watch`. Falling back to polling using `fs.watchFile`'
|
||||
'Looks like your current environment support a faster algorithm then polling. You can try to disable `usePolling`'
|
||||
);
|
||||
}
|
||||
|
||||
if (!this.usePolling && this.shouldUsePolling) {
|
||||
this.log(
|
||||
['error', 'logging:rotate'],
|
||||
'Looks like within your current environment you need to use polling in order to enable log rotator. Please enable `usePolling`'
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue