elasticsearch - jboss-eap 的 Fluentd 正则表达式
问题描述
我正在尝试从 Jboss-eap 服务器收集日志然后发送到 Elasticsearch,我在服务器上使用 td-agent,它在读取我的输入和正则表达式时总是说 unmatched_lines
我的输入配置
<source>
@type tail
read_from_head true
tag file-jboss.log
path C:\T24\JBOSS\jboss-eap-6.4\standalone\log\server.log
#C:\T24\TAFJ\log\database.log
pos_file c:\opt\td-agent\file-jboss.pos
<parse>
@type regexp
expression /(?<time>\d{2}\:\d{2}\:\d{2}\,\d{3})\s+\s*(?<level>\w{1,6})\s+(?<service>\[[a-zA-Z.]*\])\s*(?<thread>\(.*\))\s+(?<message>[A-Za-z0-9]*\:.*)/
</parse>
</source>
<filter file-jboss.log>
@type record_transformer
<record>
host_param "#{Socket.gethostname}"
</record>
</filter>
我使用了这个正则表达式,它并不匹配所有内容,但我需要的是匹配的
(?<time>\d{2}\:\d{2}\:\d{2}\,\d{3})\s+\s*(?<level>\w{1,6})\s+(?<service>\[[a-zA-Z.]*\])\s*(?<thread>\(.*\))\s+(?<message>[A-Za-z0-9]*\:.*)
匹配样本的日志
11:12:09,587 INFO [org.jboss.as.controller] (Controller Boot Thread) JBAS014774: Service status report
JBAS014775: New missing/unsatisfied dependencies:
service jboss.naming.context.java.ConnectionFactory (missing) dependents: [service jboss.naming.context.java.comp.TAFJJEE_EAR.TAFJJEE_EJB.ARCMOBProcessingBean.env.jms.TopicConnectionFactory, service jboss.naming.context.java.comp.TAFJJEE_EAR.TAFJJEE_MDB.TAFJPhantomListenerMDB.env.jms.TAFJQueueConnectionFactory, service jboss.naming.context.java.comp.TAFJJEE_EAR.TAFJJEE_EJB.AMLProcessingBean.env.jms.TopicConnectionFactory, service jboss.naming.context.java.module.BrowserWeb.BrowserWeb.env.jms.jmsConnectionFactory, JBAS014799: ... and 6 more ]
11:12:13,447 INFO [org.jboss.as.server.deployment] (MSC service thread 1-39) JBAS015974: Stopped subdeployment (runtime-name: TAFJJEE_EJB.jar) in 135ms
11:12:13,447 INFO [org.jboss.as.server.deployment] (MSC service thread 1-37) JBAS015974: Stopped subdeployment (runtime-name: TAFJJEE_MDB.jar) in 135ms
Fluentd 日志输出
2021-10-13 11:55:21 +0100 [info]: using configuration file: <ROOT>
<source>
@type tail
read_from_head true
tag "file-jboss.log"
path "C:\\T24\\JBOSS\\jboss-eap-6.4\\standalone\\log\\server.log"
pos_file "c:\\opt\\td-agent\\file-jboss.pos"
<parse>
@type "regexp"
expression /(?<time>\d{2}\:\d{2}\:\d{2}\,\d{3})\s+\s*(?<level>\w{1,6})\s+(?<service>\[[a-zA-Z.]*\])\s*(?<thread>\(.*\))\s+(?<mes
sage>[A-Za-z0-9]*\:.*)/
unmatched_lines
</parse>
</source>
<filter file-jboss.log>
@type record_transformer
<record>
host_param T24-MERCURY
</record>
</filter>
<match file-jboss.log>
@type file
path "c:\\opt\\td-agent\\output\\tafj.log"
<buffer time>
path "c:\\opt\\td-agent\\output\\tafj.log"
</buffer>
</match>
</ROOT>
2021-10-13 11:55:21 +0100 [info]: starting fluentd-1.13.3 pid=3192 ruby="2.7.4"
2021-10-13 11:55:21 +0100 [info]: spawn command to main: cmdline=["C:/opt/td-agent/bin/ruby.exe", "-Eascii-8bit:ascii-8bit", "C:/opt/
td-agent/bin/fluentd", "--under-supervisor"]
2021-10-13 11:55:24 +0100 [info]: adding filter pattern="file-jboss.log" type="record_transformer"
2021-10-13 11:55:24 +0100 [info]: adding match pattern="file-jboss.log" type="file"
2021-10-13 11:55:24 +0100 [info]: adding source type="tail"
2021-10-13 11:55:24 +0100 [info]: #0 starting fluentd worker pid=8120 ppid=3192 worker=0
2021-10-13 11:55:24 +0100 [info]: #0 following tail of C:\T24\JBOSS\jboss-eap-6.4\standalone\log\server.log
2021-10-13 11:55:24 +0100 [info]: #0 fluentd worker is now running worker=0
知道为什么 fluentd 不喜欢 regex 吗?
解决方案
推荐阅读
- javascript - 在 JavaScript 中将字符串转换为十进制数
- xpath - 如何使用 importxml 将网页内容下载到 Google 表格
- python - 如何单击网页中所有选定的链接,然后返回登录页面并单击下一个链接
- php - PHP 刀片 | 仅当等于某个值时才打印特定数据
- javascript - 如何删除窗口对象以进行测试?
- javascript - 将地图作为组的一部分附加(多个地图)
- google-chrome - Chrome 开发工具:内存堆快照显示特殊图标而不是 unicode 字符(以前是红色/黄色突出显示)
- php - 如果我要从数据库查询,我如何将数组中的数据 foreach 到 xmls 标签,以便将消息发送到多个号码
- swift - 重新加载数据后我的 TableView 没有改变
- android - 询问建议 - 上移或下移时编辑文本失去焦点时的回收视图回调函数