简体   繁体   English

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

[英]How to configure JBoss JsonFormatter for Filebeat (WildFly 14)

I have Filebeat pulling logs from stdout. 我有Filebeat从标准输出中提取日志。 I want to ensure my logs are outputted as JSON, so they can be properly parsed. 我想确保我的日志输出为JSON,以便可以对其进行正确解析。

Thus far, here's what I've found: 到目前为止,这是我发现的内容:

  • org.jboss.logmanager.formatters doesn't have a JSON formatter org.jboss.logmanager.formatters没有JSON格式化程序
  • There's an "extension" module that provides a JsonFormatter class. 有一个“扩展”模块 ,提供了JsonFormatter类。
  • I can use it in my logging.properties by doing something like this: 我可以通过以下操作在我的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

I need to know: 我需要知道:

  • Am I missing anything with this configuration? 此配置是否缺少任何内容?
  • How can I customise the JSON output (ie add or remove fields)? 如何自定义JSON输出(即添加或删除字段)?

There is a json-formatter in WildFly 14. I would not suggest editing the logging.properties . WildFly 14中有一个json-formatter程序。我不建议编辑logging.properties The following CLI commands are an example of configuring a json-formatter . 以下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)

Note the meta-data attribute is just a key/value pair separated by commas. 请注意, meta-data属性只是一个键/值对,以逗号分隔。

How can I customise the JSON output (ie add or remove fields)? 如何自定义JSON输出(即添加或删除字段)?

You can really only add metadata or change field names. 您实际上只能添加元数据或更改字段名称。 You can't remove fields though. 但是您不能删除字段。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM