Как создать собственный фильтр grok для logstash, если в файле журнала более одного шаблона - PullRequest
0 голосов
/ 26 сентября 2019

У меня есть настройка ELK вместе с filebeat.Filebeat отправляет журнал в logstash, а logtstash предполагает его фильтрацию.Я новичок в этом и не знаю, как создать фильтр Грока, я знаю регулярные выражения, но это, вероятно, что-то другое.В настоящее время ниже мой фильтр, может кто-нибудь помочь мне написать фильтр grok для моего журнала (прилагается ниже)

filter {
  #If log line contains tab character followed by 'at' then we will tag that entry as stacktrace
  if [message] =~ "\tat" {
    grok {
      match => ["message", "^(\tat)"]
      add_tag => ["stacktrace"]
    }
  }
}

вышеупомянутый фильтр не работает, т.е. каждый "at" создает новую запись журнала в Elastic Search.

Ниже приведен пример из файла журнала

ERROR org.quartz.core.ErrorLogger 18:51:17,201 - Job (GroupDummy.JobA threw an exception.
org.quartz.SchedulerException: Job threw an unhandled exception. [See nested exception: null]
        at org.quartz.core.JobRunShell.run(JobRunShell.java:234)
        at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:549)
Caused by: null
        at com.test.databasesync.DataBaseSynchronizationDLJob.execute(DataBaseSynchronizationDLJob.java:56)
        at org.quartz.core.JobRunShell.run(JobRunShell.java:223)
        ... 1 more
WARN com.arjuna.ats.jta 18:52:08,470 - ARJUNA016027: Local XARecoveryModule.xaRecovery got XA exception XAException.XAER_RMERR
javax.transaction.xa.XAException
        at oracle.jdbc.xa.OracleXAResource.recover(OracleXAResource.java:701)
        at org.jboss.jca.adapters.jdbc.xa.XAManagedConnection.recover(XAManagedConnection.java:362)
        at com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule.xaRecoveryFirstPass(XARecoveryModule.java:546)
        at com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule.periodicWorkFirstPass(XARecoveryModule.java:186)
        at com.arjuna.ats.internal.arjuna.recovery.PeriodicRecovery.doWorkInternal(PeriodicRecovery.java:747)
        at com.arjuna.ats.internal.arjuna.recovery.PeriodicRecovery.run(PeriodicRecovery.java:375)
ERROR org.quartz.core.ErrorLogger - Job (GroupDummy.JobA threw an exception.
org.quartz.SchedulerException: Job threw an unhandled exception. [See nested exception: null]
        at org.quartz.core.JobRunShell.run(JobRunShell.java:234)
        at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:549)
Caused by: null
        at com.test.databasesync.DataBaseSynchronizationDLJob.execute(DataBaseSynchronizationDLJob.java:56)
        at org.quartz.core.JobRunShell.run(JobRunShell.java:223)
        ... 1 more
ERROR com.test -  Date: 24-09-2019  14:24:12-Exception in: Classname=com.test.status.modeldeployment.dao.impl.ModelDeploymentStatusDLDaoImpl Method= getModelDeploymentStatusElementList
ERROR com.test - context
PreparedStatementCallback; bad SQL grammar [SELECT * FROM (SELECT ROWNUM RN,R.* FROM ( SELECT A.MODEL_ID, A.MODEL_NAME, B.PROJECT_NAME, A.IS_TRANSFERRED, A.DATE_OF_TRANSFER FROM MODEL_DETAIL A, PROJECT_DETAIL B WHERE A.PROJECT_ID = B.PROJECT_ID ORDER BY MODEL_ID desc ) R )  where    RN>=1 and RN<=10]; nested exception is java.sql.SQLSyntaxErrorException: ORA-00904: "A"."DATE_OF_TRANSFER": invalid identifier

        at com.test.databasesync.dao.impl.ModelDeploymentStatusDaoImpl.getModelDeploymentStatusElementList(ModelDeploymentStatusDaoImpl.java:223)
        at com.test.databasesync.dao.impl.ModelDeploymentStatusDaoImpl$$FastClassBySpringCGLIB$$ed0d043f.invoke(<generated>)
        at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
        at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:720)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
        at org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:52)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
        at org.springframework.aop.aspectj.AspectJAfterAdvice.invoke(AspectJAfterAdvice.java:44)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
        at org.springframework.aop.aspectj.AspectJAfterThrowingAdvice.invoke(AspectJAfterThrowingAdvice.java:59)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
        at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
        at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:655)
        at com.test.status.modeldeployment.dao.impl.ModelDeploymentStatusDLDaoImpl$$EnhancerBySpringCGLIB$$7c67212c.getModelDeploymentStatusElementList(<generated>)
        at com.test.status.model.business.impl.ModelDeploymentStatusBusinessImpl.getModelDeploymentStatusElementList(ModelDeploymentStatusBusinessImpl.java:37)
        at com.test.status.model.business.impl.ModelDeploymentStatusBusinessImpl$$FastClassBySpringCGLIB$$16c7f9f2.invoke(<generated>)
        at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
        at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:720)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
        at org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:52)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
        at org.springframework.aop.aspectj.AspectJAfterAdvice.invoke(AspectJAfterAdvice.java:44)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
        at org.springframework.aop.aspectj.AspectJAfterThrowingAdvice.invoke(AspectJAfterThrowingAdvice.java:59)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
        at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
        at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:655)
        at com.test.status.modeldeployment.business.impl.ModelDeploymentStatusDLBusinessImpl$$EnhancerBySpringCGLIB$$1fd64b58.getModelDeploymentStatusElementList(<generated>)
        at com.test.common.business.impl.DeepLearningPaginationBusinessImpl.getModelDeploymentStatusDetail(DeepLearningPaginationBusinessImpl.java:1096)
        at com.test.common.business.impl.DeepLearningPaginationBusinessImpl.processServletRequest(DeepLearningPaginationBusinessImpl.java:184)
        at com.test.common.business.impl.DeepLearningPaginationBusinessImpl$$FastClassBySpringCGLIB$$4683014.invoke(<generated>)
        at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
        at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:720)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
        at org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:52)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
        at org.springframework.aop.aspectj.AspectJAfterAdvice.invoke(AspectJAfterAdvice.java:44)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
        at org.springframework.aop.aspectj.AspectJAfterThrowingAdvice.invoke(AspectJAfterThrowingAdvice.java:59)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
        at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
        at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:655)
        at com.test.common.business.impl.DeepLearningPaginationBusinessImpl$$EnhancerBySpringCGLIB$$b88fb44d.processServletRequest(<generated>)
        at com.test.common.servlet.LendingAnalyticsPaginationServlet.doGet(LendingAnalyticsPaginationServlet.java:69)
        at com.test.action.servlet.DeepLearningPaginationServlet.doGet(DeepLearningPaginationServlet.java:35)
        at com.test.common.servlet.LendingAnalyticsPaginationServlet.doPost(LendingAnalyticsPaginationServlet.java:101)
        at com.test.action.servlet.DeepLearningPaginationServlet.doPost(DeepLearningPaginationServlet.java:61)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
        at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:286)
        at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:260)
        at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:137)
ERROR com.test -  Date: 24-09-2019  14:24:12-Exception in: Classname=com.test.status.modeldeployment.business.impl.ModelDeploymentStatusDLBusinessImpl Method= getModelDeploymentStatusElementList
...