elasticsearch 将PCAP导入Elasticsearch
我第一次尝试了Elasticsearch 我已经下载了elasticsearch 将PCAP导入Elasticsearch,elasticsearch,kibana,filebeat,tshark,elasticsearch,Kibana,Filebeat,Tshark,我第一次尝试了Elasticsearch 我已经下载了Elasticsearch和Kibana,一切看起来都很好。我可以访问http://localhost:5601和查看Kibana无错误 我使用wireshark/tshark进行了一些跟踪,并使用以下工具将其转换为Elasticsearch格式: tshark -r test_trace.pcap -T ek > test_trace.pcap.json 现在我正试图将.json导入Elasticsearch,但似乎失败了: cur
Elasticsearch
和Kibana
,一切看起来都很好。我可以访问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\u not\u found\u 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
}
如何正确导入数据并在Elasticsearch
和Kibana
中查看
JSON文件是195MB,由10MBPCAP
文件转换而来。
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
my.json
中的文件类型为:
"frame_frame_protocols": "sll:ethertype:ip:sctp"
而且确实有多个
ip\u ip\u addr
字段,因为我在跟踪中有源和目标ip地址。您的JSON文件已经包含了数据应该被索引到的索引,即packets-2019-02-15
,因此您的查询应该是:
curl 'http://127.0.0.1:9200/packets-2019-02-15/_search/?size=10&pretty=true'
但是,我怀疑您能否一次性发送195MB的文件,我建议您您是否也可以显示
test_trace.pcap.json
的前几行?这个文件有多大?当然,完成:)好的,运行curl'http://127.0.0.1:9200/packets-2019-02-15/_search/?size=10&pretty=true'
没有给我任何信息。如果文件太大,不会报告错误吗?文件可能太大,如果等待足够长的时间,可能会出现5xx错误。你的curl bulk命令是执行完毕还是终止了它?curl
在几秒钟内完成,没有错误,也不需要终止它。嗯,195MB的几秒钟听起来很奇怪。。。你能拆下-s开关吗?这里还有反馈吗?