【问题标题】:Filebeat multiline filter doesn't work with txt fileFilebeat 多行过滤器不适用于 txt 文件
【发布时间】:2022-01-22 02:07:29
【问题描述】:

我使用 filebeat 从 .txt 文件中收集数据。我正在尝试使用 Filebeat 多行功能通过以下 Filebeat 配置将日志行合并到一个条目中:

filebeat.inputs:

- type: filestream
  enabled: true
  multiline.pattern: '^[0-9]{2}\/[0-9]{2}\/[0-9]{4}'
  multiline.negate: true
  multiline.match: after
  paths:
    - .\My.log

output.logstash:
  hosts: ["localhost:5044"]

这是一个日志示例。我想合并堆栈跟踪日志。

18/11/2021 19:17:25,717 [96] ERROR B2XPPA.Web.UI.Utilities.GlobalExceptionFilter -
System.AggregateException: One or more errors occurred. ---> System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: The request was aborted: Could not create SSL/TLS secure channel.
   at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
   at System.Net.Http.HttpClientHandler.GetResponseCallback(IAsyncResult ar)
   --- End of inner exception stack trace ---
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
   at System.Threading.Tasks.Task`1.get_Result()
   at B2X.AddressRestfulAPIClient.RestfulWebAPIClient.GetDetails(String url)
   at B2X.AddressValidation.AddressValidation.GetEircodeAddress(String Eircodeid)
   at B2XPPA.Web.UI.Services.DropdownsPPAService.GetEircodeAddress(String eirCodeId)
   at B2XPPA.Web.UI.Models.Populators.PPADetailsPopulator.Populate(IViewModel viewModel, Quote quote)
   at B2X.Services.ApplicationService.Application`1.PopulateDetailsView(DetailsViewModel viewModel, String referenceNumberInController, Quote quote)
   at B2XPPA.Web.UI.Controllers.QuoteController.Create(QuoteDetailsViewModel viewModel)
   at lambda_method(Closure , ControllerBase , Object[] )
   at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters)
   at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)

但是,Kibana 中的所有日志继续在每一行分隔,并且根本没有发生多行格式化。谁能帮我解决这个问题?

【问题讨论】:

    标签: elasticsearch logstash kibana elastic-stack filebeat


    【解决方案1】:

    您的多行模式与任何内容都不匹配。

    ^[0-9]{4}-[0-9]{2}-[0-9]{2} 模式希望您的行以 dddd-dd-dd 开头,其中 d 是 0 到 9 之间的数字,这通常在您的日期类似于 2022-01-22 时使用

    但是您的行以以下模式dd/dd/dddd 开头,因此您需要更改多行模式以匹配行的开头。

    此模式^[0-9]{2}\/[0-9]{2}\/[0-9]{4} 将匹配以日期开头的行,例如您所拥有的日期,例如18/11/2021

    【讨论】:

    • 谢谢@leandrojmp,我已经改变了模式,但它仍然不起作用:(
    【解决方案2】:

    我发现了问题所在。我使用 filestream 作为 filebeat 输入。多行不适用于文件流。我已将类型更改为 log,然后一切正常。

    filebeat.inputs:
     multiline.pattern: '^[0-9]{4}-[0-9]{2}-[0-9]{2}'
     multiline.negate: true
     multiline.match: after
    - type: log
      enabled: true
    
      paths:
        - .\My.log
    
    output.logstash:
      hosts: ["localhost:5044"]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-05-18
      • 1970-01-01
      • 1970-01-01
      • 2013-01-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多