我有一个几乎没有微服务的 kubernetes 集群。微服务将日志记录/导出为 JSON 格式。因此,我的 ELK 堆栈正在记录消息并在 kibana 中进行可视化(我使用的是 7.3 版),并且我正在努力进一步反序列化来自我的微服务的消息归档,以便我可以看到在“消息”字段中进一步提取的各个字段。例如,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:
最佳答案
请向我们展示 logstash 配置文件。
我认为这可以通过以下代码来实现:
input {
file {
path => "/var/log/containers/*.log"
codec => "json"
}
}
P.S.:如果您看到标签“_jsonparsefailure”并且仍然像以前一样在消息字段中收到您的文档,那么您需要检查您的输入,很可能是无效的 JSON。
关于json - ELK Stack - 进一步反序列化 Kubernetes 中归档的 "message",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62421657/