regex - 基于Logstash中的模式匹配创建索引

标签 regex elasticsearch logstash logstash-grok

我正在尝试使用elasticsearch logstash和kibana为一组Windows和Linux服务器构建集中式日志记录系统。我的输入将是来自两个系统的系统日志(单个输入流)。我试图了解是否有使用grok并匹配模式的方法,然后基于此将日志放入不同的索引(一个用于Windows日志,另一个用于linux日志)

任何方向的帮助将不胜感激。

谢谢,

最佳答案

您可以根据日志来自哪个系统来分配“类型”,然后在输出中使用该类型。

下面是配置:

input{
   file{
     path =>"path/to/system1_log_file"
     type =>"sys1logs"
   }

  file{
    path =>"path/to/system2_log_files"
    type =>"sys2logs"
  }
}

output{
  if[type]=="sys1logs"{
  #output to sys1 index
   elasticsearch{host => localhost
               index => "sys1"
               }
   }

 if[type]=="sys2logs"{
 #output to sys2 index
  elasticsearch{host => localhost
               index =>"sys2"
              }
  }
}

关于regex - 基于Logstash中的模式匹配创建索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31277641/

相关文章:

curl - 如何在elasticsearch中获取单词三元组

elasticsearch - 如何使用Logstash将数据上传到现有索引?

elasticsearch - 为什么 Logstash 不会基于 grok'd 字段合并行?

regex - 从一个文件中查找另一个文件中的电子邮件

ruby 正则表达式 : Get Index of Capture

JavaScript 正则表达式 : Positive lookbehind alternative (for Safari and other browsers that do not support lookbehinds)

nginx - 在 logstash 或 elasticsearch 中更改 nginx 访问日志数据

Python正则表达式模式定义不包括字符

sql-server - 在 Azure 上创建弹性作业代理后,导出失败

elasticsearch - 如何使用java api在elasticsearch中搜索特定日期和时间范围内的日志