将PCAP导入Elasticsearch

问题描述 投票:0回答:1

我第一次尝试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":...

UPDATE

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

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...

UPDATE

我在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地址。

elasticsearch kibana filebeat tshark
1个回答
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

© www.soinside.com 2019 - 2024. All rights reserved.