首页 > 解决方案 > ELK 堆栈数据映射功能

问题描述

所以现在我想知道 ELK 堆栈中是否有一个功能可以对来自不同来源的数据进行查找和映射。

例如:我有日志

'computer.log' -> {computer_id: 123456, internet_connected: 345612}
'phone.log' ->    {phone_id: 234561}
'internet.log' -> {internet_id: 345612, phone_push: 234561}

所以我们有 3 条日志流被发送到 filebeat -> logstash -> elasticsearch -> kibana

当我们需要跟踪哪部手机连接到计算机时,我想搜索“computer_id:123456”,然后弹出所有这3个日志。我知道我们可以在弹性搜索中搜索数据的特定索引,并在 logstash 中解析原始日志。但我想知道如果我们分别收到这 3 个日志(在 5 毫秒内),我该如何跟踪或进行映射。

logstash 是否会具有这种数据跟踪功能,还是我必须编写一个程序来处理映射并将转换 id 插入到特定日志中,然后再流式传输到 logstash?

我不知道这个功能的确切名称,你能告诉我 ELK 堆栈中是否有一个吗?

标签: elasticsearchmappinglogstashtrace

解决方案


如果 internet.log 以至少几秒钟的保证间隙排在最后,我们可以丰富包含 internet.log 的索引。

我建议关注

  1. 在索引 internet.log 时,将document_id 添加为 uuid - https://www.elastic.co/guide/en/logstash/current/plugins-filters-uuid.html 并添加状态 - '未处理'
  2. 添加另一个logstash
    • 输入 - 使用弹性搜索输入插件查询状态为未处理的 internet.log
    • 过滤器 1 - 使用 elasticsearch 过滤器插件查询 computer.log 以获取事件中的 computer_id 和其他字段(如果有)。
    • 过滤器 2 - 使用弹性搜索过滤器插件查询 phone.log 以获取与事件中的电话相关的字段。
    • 如果过滤器 1 和 2 成功返回数据,则将状态更新为已处理。
    • 输出 - 使用相同的 document_id (uuid) 重新索引 internet.log 文档

您可以在这里找到一些示例 - * https://www.elastic.co/guide/en/logstash/current/lookup-enrichment.html * https://www.elastic.co/guide/en/logstash/current/插件-过滤器-elasticsearch.html

现在,您可以在单个索引 (index.log) 中搜索和查询所有数据。


推荐阅读