如何为 Filebeat 配置 JBoss JsonFormatter (WildFly 14)

2024-02-24

我有 Filebeat 从标准输出中提取日志。我想确保我的日志以 JSON 格式输出,以便可以正确解析它们。

到目前为止,这是我发现的:

  • org.jboss.logmanager.formatters 没有 JSON 格式化程序
  • 有一个“扩展”模块 https://mvnrepository.com/artifact/org.jboss.logmanager/jboss-logmanager-ext它提供了一个 JsonFormatter 类。
  • 我可以通过执行以下操作在我的logging.properties中使用它:
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 https://wildscribe.github.io/WildFly/14.0/subsystem/logging/json-formatter/index.html在 WildFly 14 中。我不建议编辑logging.properties。以下 CLI 命令是配置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属性只是一个用逗号分隔的键/值对。

如何自定义 JSON 输出(即添加或删除字段)?

您实际上只能添加元数据或更改字段名称。但您无法删除字段。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何为 Filebeat 配置 JBoss JsonFormatter (WildFly 14) 的相关文章

随机推荐