Hi!
I am trying to configure opensearch to log exceptions as a single line, so it’s easier to filter them with logstash.
I tried this log4j2.properties configuration file:
status = error
appender.console.type = Console
appender.console.name = console
appender.console.layout.type = PatternLayout
appender.console.layout.pattern = [%d{ISO8601}][%-5p][%-25c{1.}] [%node_name]%marker %replace{%m}{%n}{\u2028} %throwable{separator(\u2028)}%n
rootLogger.level = info
rootLogger.appenderRef.console.ref = console
The pattern seems to be working. Most stack traces get logged in a single line, for example:
[2023-08-10T11:53:12,701][ERROR][o.o.j.s.u.LockService ] [node1] Exception occurred finding lock NoShardAvailableActionException[No shard available for [get [.opendistro-job-scheduler-lock][.opendistro-ism-config-mJx3FvlbQl61lQ03_3SO2g]: routing [null]]] at org.opensearch.action.support.single.shard.TransportSingleShardAction$AsyncSingleAction.perform(TransportSingleShardAction.java:256) at org.opensearch.action.support.single.shard.TransportSingleShardAction$AsyncSingleAction.start(TransportSingleShardAction.java:231) at org.opensearch.action.support.single.shard.TransportSingleShardAction.doExecute(TransportSingleShardAction.java:125) at org.opensearch.action.support.single.shard.TransportSingleShardAction.doExecute(TransportSingleShardAction.java:78) at org.opensearch.action.support.TransportAction$RequestFilterChain.proceed(TransportAction.java:218) at org.opensearch.indexmanagement.rollup.actionfilter.FieldCapsFilter.apply(FieldCapsFilter.kt:118) at org.opensearch.action.support.TransportAction$RequestFilterChain.proceed(TransportAction.java:216) at org.opensearch.indexmanagement.controlcenter.notification.filter.IndexOperationActionFilter.apply(IndexOperationActionFilter.kt:39) at org.opensearch.action.support.TransportAction$RequestFilterChain.proceed(TransportAction.java:216) at org.opensearch.performanceanalyzer.action.PerformanceAnalyzerActionFilter.apply(PerformanceAnalyzerActionFilter.java:78) at org.opensearch.action.support.TransportAction$RequestFilterChain.proceed(TransportAction.java:216) at org.opensearch.security.filter.SecurityFilter.apply0(SecurityFilter.java:320) at org.opensearch.security.filter.SecurityFilter.apply(SecurityFilter.java:165) at org.opensearch.action.support.TransportAction$RequestFilterChain.proceed(TransportAction.java:216) at org.opensearch.action.support.TransportAction.execute(TransportAction.java:188) at org.opensearch.action.support.TransportAction.execute(TransportAction.java:107) at org.opensearch.client.node.NodeClient.executeLocally(NodeClient.java:110) at org.opensearch.client.node.NodeClient.doExecute(NodeClient.java:97) at org.opensearch.client.support.AbstractClient.execute(AbstractClient.java:476) at org.opensearch.client.support.AbstractClient.get(AbstractClient.java:572) at org.opensearch.jobscheduler.spi.utils.LockService.findLock(LockService.java:255) at org.opensearch.jobscheduler.spi.utils.LockService.lambda$acquireLockWithId$3(LockService.java:154) at org.opensearch.action.ActionListener$1.onResponse(ActionListener.java:80) at org.opensearch.jobscheduler.spi.utils.LockService.createLockIndex(LockService.java:85) at org.opensearch.jobscheduler.spi.utils.LockService.acquireLockWithId(LockService.java:151) at org.opensearch.jobscheduler.spi.utils.LockService.acquireLock(LockService.java:122) at org.opensearch.indexmanagement.indexstatemanagement.ManagedIndexRunner$runJob$1$lock$1.invoke(ManagedIndexRunner.kt:235) at org.opensearch.indexmanagement.indexstatemanagement.ManagedIndexRunner$runJob$1$lock$1.invoke(ManagedIndexRunner.kt:235) at org.opensearch.indexmanagement.opensearchapi.OpenSearchExtensionsKt.suspendUntil(OpenSearchExtensions.kt:231) at org.opensearch.indexmanagement.indexstatemanagement.ManagedIndexRunner$runJob$1.invokeSuspend(ManagedIndexRunner.kt:235) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:56) at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:738) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)
but I still see some exceptions spanning multiple lines:
uncaught exception in thread [DefaultDispatcher-worker-5]
NoShardAvailableActionException[No shard available for [get [.opendistro-job-scheduler-lock][.opendistro-ism-config-mJx3FvlbQl61lQ03_3SO2g]: routing [null]]]
at org.opensearch.action.support.single.shard.TransportSingleShardAction$AsyncSingleAction.perform(TransportSingleShardAction.java:256)
at org.opensearch.action.support.single.shard.TransportSingleShardAction$AsyncSingleAction.start(TransportSingleShardAction.java:231)
at org.opensearch.action.support.single.shard.TransportSingleShardAction.doExecute(TransportSingleShardAction.java:125)
at org.opensearch.action.support.single.shard.TransportSingleShardAction.doExecute(TransportSingleShardAction.java:78)
at org.opensearch.action.support.TransportAction$RequestFilterChain.proceed(TransportAction.java:218)
at org.opensearch.indexmanagement.rollup.actionfilter.FieldCapsFilter.apply(FieldCapsFilter.kt:118)
at org.opensearch.action.support.TransportAction$RequestFilterChain.proceed(TransportAction.java:216)
at org.opensearch.indexmanagement.controlcenter.notification.filter.IndexOperationActionFilter.apply(IndexOperationActionFilter.kt:39)
at org.opensearch.action.support.TransportAction$RequestFilterChain.proceed(TransportAction.java:216)
at org.opensearch.performanceanalyzer.action.PerformanceAnalyzerActionFilter.apply(PerformanceAnalyzerActionFilter.java:78)
at org.opensearch.action.support.TransportAction$RequestFilterChain.proceed(TransportAction.java:216)
at org.opensearch.security.filter.SecurityFilter.apply0(SecurityFilter.java:320)
at org.opensearch.security.filter.SecurityFilter.apply(SecurityFilter.java:165)
at org.opensearch.action.support.TransportAction$RequestFilterChain.proceed(TransportAction.java:216)
at org.opensearch.action.support.TransportAction.execute(TransportAction.java:188)
at org.opensearch.action.support.TransportAction.execute(TransportAction.java:107)
at org.opensearch.client.node.NodeClient.executeLocally(NodeClient.java:110)
at org.opensearch.client.node.NodeClient.doExecute(NodeClient.java:97)
at org.opensearch.client.support.AbstractClient.execute(AbstractClient.java:476)
at org.opensearch.client.support.AbstractClient.get(AbstractClient.java:572)
at org.opensearch.jobscheduler.spi.utils.LockService.findLock(LockService.java:255)
at org.opensearch.jobscheduler.spi.utils.LockService.lambda$acquireLockWithId$3(LockService.java:154)
at org.opensearch.action.ActionListener$1.onResponse(ActionListener.java:80)
at org.opensearch.jobscheduler.spi.utils.LockService.createLockIndex(LockService.java:85)
at org.opensearch.jobscheduler.spi.utils.LockService.acquireLockWithId(LockService.java:151)
at org.opensearch.jobscheduler.spi.utils.LockService.acquireLock(LockService.java:122)
at org.opensearch.indexmanagement.indexstatemanagement.ManagedIndexRunner$runJob$1$lock$1.invoke(ManagedIndexRunner.kt:235)
at org.opensearch.indexmanagement.indexstatemanagement.ManagedIndexRunner$runJob$1$lock$1.invoke(ManagedIndexRunner.kt:235)
at org.opensearch.indexmanagement.opensearchapi.OpenSearchExtensionsKt.suspendUntil(OpenSearchExtensions.kt:231)
at org.opensearch.indexmanagement.indexstatemanagement.ManagedIndexRunner$runJob$1.invokeSuspend(ManagedIndexRunner.kt:235)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:56)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:738)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)
What am I missing?