如何为Filebeat配置JBoss JsonFormatter(WildFly 14) [英] How to configure JBoss JsonFormatter for Filebeat (WildFly 14)
问题描述
我有Filebeat从stdout中提取日志.我想确保我的日志以JSON格式输出,以便可以对其进行正确的解析.
I have Filebeat pulling logs from stdout. I want to ensure my logs are outputted as JSON, so they can be properly parsed.
到目前为止,这是我所发现的:
Thus far, here's what I've found:
- org.jboss.logmanager.formatters没有JSON格式化程序
- 有一个扩展"模块,它提供了一个JsonFormatter类.
- 我可以通过以下操作在我的logging.properties中使用它:
- org.jboss.logmanager.formatters doesn't have a JSON formatter
- There's an "extension" module that provides a JsonFormatter class.
- I can use it in my logging.properties by doing something like this:
handler.CONSOLE=org.jboss.logmanager.handlers.ConsoleHandler
handler.CONSOLE.properties=autoFlush,target
handler.CONSOLE.autoFlush=true
handler.CONSOLE.formatter=JSON-FORMATTER
handler.CONSOLE.target=SYSTEM_OUT
formatter.JSON-FORMATTER=org.jboss.logmanager.ext.formatters.JSONFormatter
我需要知道:
- 此配置是否缺少任何内容?
- 如何自定义JSON输出(即添加或删除字段)?
推荐答案
有一个 json-formatter
.我不建议编辑logging.properties
.以下CLI命令是配置json-formatter
的示例.
There is a json-formatter
in WildFly 14. I would not suggest editing the logging.properties
. The following CLI commands are an example of configuring a json-formatter
.
/subsystem=logging/json-formatter=json:add(exception-output-type=formatted, pretty-print=false, meta-data={label=value})
/subsystem=logging/console-handler=CONSOLE:write-attribute(name=named-formatter, value=json)
请注意meta-data
属性只是一个键/值对,以逗号分隔.
Note the meta-data
attribute is just a key/value pair separated by commas.
如何自定义JSON输出(即添加或删除字段)?
How can I customise the JSON output (i.e. add or remove fields)?
您实际上只能添加元数据或更改字段名称.但是您不能删除字段.
You can really only add metadata or change field names. You can't remove fields though.
这篇关于如何为Filebeat配置JBoss JsonFormatter(WildFly 14)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!