elasticsearch - 将 PCAP 导入 Elasticsearch

标签 elasticsearch kibana filebeat tshark

我第一次尝试 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/

相关文章:

c# - 如何编写用于 Elasticsearch 匹配和模糊查询的 LINQ 表达式(NEST)

elasticsearch - 如何将每个文档的计数乘以其中的值?

elasticsearch - Elastic Sink Connector 无法正常工作新版本

elasticsearch - 无法将Filebeat连接到Logstash以使用ELK进行日志记录

elasticsearch - 我如何正确排序ElasticSearch结果

java - 基于_source字段搜索查询elasticsearch

elasticsearch - Elasticsearch无法解析主机

elasticsearch - 如何增加数据节点进行 Elasticsearch

elasticsearch - ELK Logstash无法在ES中创建索引

logstash - Filebeat 无法连接到 logstash