【问题标题】:Importing PCAP into Elasticsearch将 PCAP 导入 Elasticsearch
【发布时间】:2019-07-11 15:29:21
【问题描述】:

我是第一次尝试Elasticsearch

我已经下载了ElasticsearchKibana,一切似乎都运行良好。我可以访问http://localhost:5601 并查看Kibana 而不会出错。

我已经使用wireshark/tshark 进行了一些跟踪,并将其转换为Elasticsearch 格式:

tshark -r test_trace.pcap -T ek > test_trace.pcap.json

现在我正在尝试将 .json 导入到 Elasticsearch,但它似乎失败了:

curl -s -H "Content-Type: application/x-ndjson" -XPOST "localhost:9200/foo/_bulk" --data-binary "@/Users/test-elastic/test_trace.pcap.json"

我没有收到任何错误或任何输出,但访问 Kibana 显示 index_not_found_exception 并运行:

curl 'http://127.0.0.1:9200/foo/_search/?size=10&pretty=true'

输出

{
  "error" : {
    "root_cause" : [
      {
        "type" : "index_not_found_exception",
        "reason" : "no such index",
        "resource.type" : "index_or_alias",
        "resource.id" : "foo",
        "index_uuid" : "_na_",
        "index" : "foo"
      }
    ],
    "type" : "index_not_found_exception",
    "reason" : "no such index",
    "resource.type" : "index_or_alias",
    "resource.id" : "foo",
    "index_uuid" : "_na_",
    "index" : "foo"
  },
  "status" : 404
}

如何正确导入我的数据并在ElasticsearchKibana 中查看?

JSON 文件为 195MB,由 10MB PCAP 文件转换而来。 json 文件中第一行的输出是:

{"index" : {"_index": "packets-2019-02-15", "_type": "pcap_file", "_score": null}}
{"timestamp" : "1549540104875", "layers" : {"frame": {"frame_frame_interface_id":...

更新

curl 中删除-s 后,我得到了输出:

HTTP/1.1 413 Request Entity Too Large

现在我尝试使用split 将文件拆分为多个较小的文件。

现在再次测试导入会给我多个错误:

..."reason":"failed to parse","caused_by":{"type":"json_parse_exception","reason":"Duplicate field 'ip_ip_addr'\n at [Source: org.elasticsearch.common.bytes.BytesReference$MarkSupportingStreamInputWrapper@5d2f82db; line: 1, column: 1300...

更新

我在test_trace.pcap.json 上使用了以下命令来获取更小的文件:

split -l 10000 -a 10 test_trace.pcap.json.pcap.json ./tmp/test_trace.pcap

然后我得到了很多文件并用第一个文件测试了导入:

./tmp/test_trace.pcapaaaaaaaaaa

.json中的文件类型是:

"frame_frame_protocols": "sll:ethertype:ip:sctp"

确实有多个 ip_ip_addr 字段,因为我在跟踪中具有源 IP 地址和目标 IP 地址。

【问题讨论】:

  • 你能把test_trace.pcap.json的前几行也显示一下吗?这个文件有多大?
  • 当然,完成:)

标签: elasticsearch kibana filebeat tshark


【解决方案1】:

您的 JSON 文件已经包含数据应该被索引到的索引,即packets-2019-02-15,因此您的查询应该是:

curl 'http://127.0.0.1:9200/packets-2019-02-15/_search/?size=10&pretty=true'

但是,我怀疑你是否可以一次发送一个195MB的文件,我建议你split it and load it in chunks

【讨论】:

  • 好的,运行curl 'http://127.0.0.1:9200/packets-2019-02-15/_search/?size=10&pretty=true' 什么也没给我。文件太大不会报错吗?
  • 文件可能太大了,如果等待的时间足够长,您可能会收到 5xx 错误。您的 curl 批量命令执行完毕还是您杀死了它?
  • curl 在几秒钟内完成,没有错误也不需要杀死它。
  • 嗯,195MB 的几秒钟听起来很奇怪......你能去掉 -s 开关吗?
  • 这里还有其他反馈吗?
猜你喜欢
  • 1970-01-01
  • 2014-01-12
  • 2017-09-27
  • 2021-12-27
  • 1970-01-01
  • 1970-01-01
  • 2020-02-18
  • 2018-04-16
相关资源
最近更新 更多