diff --git a/x-pack/plugins/task_manager/server/lib/log_health_metrics.test.ts b/x-pack/plugins/task_manager/server/lib/log_health_metrics.test.ts index 0dcb12a4e5511..61a5dfcf96233 100644 --- a/x-pack/plugins/task_manager/server/lib/log_health_metrics.test.ts +++ b/x-pack/plugins/task_manager/server/lib/log_health_metrics.test.ts @@ -117,6 +117,24 @@ describe('logHealthMetrics', () => { expect(firstDebug).toMatchObject(health); }); + it('should log as debug if status is OK even if not enabled', () => { + const logger = loggingSystemMock.create().get(); + const config = getTaskManagerConfig({ + monitored_stats_health_verbose_log: { + enabled: false, + warn_delayed_task_start_in_seconds: 60, + }, + }); + const health = getMockMonitoredHealth(); + + logHealthMetrics(health, logger, config); + + const firstDebug = JSON.parse( + (logger as jest.Mocked).debug.mock.calls[0][0].replace('Latest Monitored Stats: ', '') + ); + expect(firstDebug).toMatchObject(health); + }); + it('should log as warn if status is Warn', () => { const logger = loggingSystemMock.create().get(); const config = getTaskManagerConfig({ diff --git a/x-pack/plugins/task_manager/server/lib/log_health_metrics.ts b/x-pack/plugins/task_manager/server/lib/log_health_metrics.ts index 0543895dba9e2..8904d7abd58db 100644 --- a/x-pack/plugins/task_manager/server/lib/log_health_metrics.ts +++ b/x-pack/plugins/task_manager/server/lib/log_health_metrics.ts @@ -43,6 +43,7 @@ export function logHealthMetrics( logLevel = LogLevel.Error; } + const message = `Latest Monitored Stats: ${JSON.stringify(monitoredHealth)}`; if (enabled) { const driftInSeconds = (monitoredHealth.stats.runtime?.value.drift.p99 ?? 0) / 1000; if ( @@ -53,8 +54,6 @@ export function logHealthMetrics( ); logLevel = LogLevel.Warn; } - - const message = `Latest Monitored Stats: ${JSON.stringify(monitoredHealth)}`; switch (logLevel) { case LogLevel.Warn: logger.warn(message); @@ -66,6 +65,8 @@ export function logHealthMetrics( logger.debug(message); } } else { + // This is legacy support - we used to always show this + logger.debug(message); if (logLevel !== LogLevel.Debug && lastLogLevel === LogLevel.Debug) { logger.warn( `Detected potential performance issue with Task Manager. Set 'xpack.task_manager.monitored_stats_health_verbose_log.enabled: true' in your Kibana.yml to enable debug logging`