我有一个kubernetes集群,只有很少的微服务。微服务以JSON格式记录/导出日志。因此,我的ELK堆栈在kibana中记录消息和可视化(我使用的是7.3版),并且我正在努力进一步反序列化来自我的微服务的消息字段,以便我可以看到在" message“字段中进一步提取的单个字段。例如,JSON有"app“和"logger”字段--这些字段应该与当前显示kubernetes字段的方式类似。我已经按如下方式配置了filebeat,但是我看不到进一步的反序列化消息字段。你能帮我解决这个问题吗?请参考我的文件节拍配置。
=======================
kind: ConfigMap
metadata:
name: filebeat-config
labels:
app: filebeat
data:
filebeat.yml: |-
# Enable filebeat config reloading
filebeat.config:
modules:
enabled: true
#path: ${path.config}/modules.d/*.yml
reload.enabled: true
reload.period: 10s
# Available log levels are: error, warning, info, debug
logging.level: warning
# To enable hints based autodiscover, remove `filebeat.inputs` configuration and uncomment this:
filebeat.autodiscover:
providers:
- type: kubernetes
node: ${NODE_NAME}
hints.enabled: true
json.message_key: message
hints.default_config:
type: container
paths:
- /var/log/containers/*${data.kubernetes.container.id}.log
templates:
config:
json.keys_under_root: true
json.add_error_key: false
processors:
- drop_event:
when:
or:
- equals:
kubernetes.namespace: "monitoring"
- contains:
message: "NETWORK"
- contains:
message: "INFO"
- add_cloud_metadata:
- add_kubernetes_metadata:
- add_host_metadata:发布于 2020-06-17 14:41:50
请向我们显示logstash配置文件。
我假设这可以通过下面的代码来实现:
input {
file {
path => "/var/log/containers/*.log"
codec => "json"
}
}附注:如果您看到一个标记"_jsonparsefailure“,但仍然像以前一样在消息字段中收到您的文档,那么您需要检查您的输入,很可能是无效的JSON。
发布于 2020-06-17 22:33:42
我知道您想使用filebeat.yml来获得JSON解码。这可能是您想要使用的方法。我将此作为单独的答案发送,因为这是一种完全不同的方法。
filebeat.inputs:
- type: log
# Change to true to enable this prospector configuration.
enabled: true
# Paths that should be crawled and fetched. Glob based paths.
paths:
- \PATH\TO\LOG\FILES\*
json.keys_under_root: true
json.add_error_key: true
json.message_key: messagejson PS:请注意json参数的适当缩进。
https://stackoverflow.com/questions/62421657
复制相似问题