You need to enable JavaScript to run this app. 如何在Elastic Agent日志入库Elasticsearch前添加威胁情报扩展字段
优惠活动
大模型
产品
解决方案
定价
更多

如何在Elastic Agent日志入库Elasticsearch前添加威胁情报扩展字段

Elastic Agent采集日志入集群前追加VirusTotal威胁情报字段的实现方案

实现这类字段扩展的核心逻辑是在日志写入Elasticsearch之前的流转环节加入 enrichment 处理,目前常用的三种实现方案如下:

方案1:Elasticsearch Ingest Pipeline 实现(生产环境最推荐)

无需额外部署组件,性能损耗最低,适合高流量采集场景:

  • 第一步:预构建威胁情报映射索引
    定期同步VirusTotal的进程特征数据到独立的Elasticsearch索引(可命名为threat_intel_virustotal_process),每条数据至少包含process.name、vt.malicious_score、vt.total_scan三个核心字段。
  • 第二步:创建Enrich策略与自定义Ingest Pipeline
    先基于上面的威胁情报索引创建Enrich策略,再新建日志处理管道,调用Enrich处理器关联进程名与VT评分,管道配置示例如下:
{
  "processors": [
    {
      "enrich": {
        "policy_name": "vt-process-score-policy",
        "field": "process.name",
        "target_field": "virustotal",
        "ignore_missing": true,
        "ignore_failure": true
      }
    }
  ]
}
  • 第三步:绑定管道到Elastic Agent集成
    打开Kibana Fleet界面,找到对应日志采集的集成配置,在「高级选项」的「自定义Ingest Pipeline」项中填入上述管道ID,后续Agent上报的所有日志都会先经过管道处理再写入集群。

方案2:Fleet自定义处理器实现(轻量场景适用)

如果日志流量低,可直接在Agent侧配置处理器实时查询VirusTotal接口,无需提前同步情报数据:

  • 在对应采集集成的「自定义处理器」配置项中添加如下规则,注意替换为你自己的VT API密钥:
- http:
    url: "https://www.virustotal.com/api/v3/search?query={{process.name}}"
    method: GET
    headers:
      "x-apikey": "YOUR_VT_API_KEY"
    target_field: "virustotal.raw_response"
    ignore_failure: true
- script:
    lang: painless
    source: >
      if (ctx.virustotal?.raw_response?.data != null && ctx.virustotal.raw_response.data.length > 0) {
        ctx.virustotal.malicious_score = ctx.virustotal.raw_response.data[0].attributes.last_analysis_stats.malicious;
        ctx.virustotal.total_scan = ctx.virustotal.raw_response.data[0].attributes.last_analysis_stats.total;
        ctx.remove('virustotal.raw_response');
      }
    ignore_failure: true

注意:该方案受VirusTotal API调用频率限制,仅测试或低流量采集场景使用,高并发场景会出现接口限流导致字段追加失败。

方案3:Logstash中转处理

如果你的架构中已经用Logstash作为Elastic Agent的输出中转,可直接在Logstash的filter阶段完成字段扩展:

  • 用elasticsearch filter查询预构建的VT威胁情报索引完成关联,或者用http filter调用VirusTotal接口查询,最终将结果写入自定义字段即可。

内容的提问来源于stack exchange,提问作者Pradeep M Nayak

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.14 21:06:04