gpt4 book ai didi

elasticsearch - 将 PCAP 导入 Elasticsearch

转载 作者:行者123 更新时间:2023-12-02 22:28:15 25 4
gpt4 key购买 nike

我第一次尝试 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 地址。

最佳答案

您的 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

关于elasticsearch - 将 PCAP 导入 Elasticsearch,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54744030/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com