我是第一次尝试Elasticsearch
。
我已经下载了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_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
}
如何正确导入数据并在Elasticsearch
和Kibana
中查看数据?
JSON文件为195MB,是从10MB PCAP
文件转换而来的。
json-file中第一行的输出是:
{"index" : {"_index": "packets-2019-02-15", "_type": "pcap_file", "_score": null}}
{"timestamp" : "1549540104875", "layers" : {"frame": {"frame_frame_interface_id":...
更新
在-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...
更新
我在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地址。
答案 0 :(得分: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