【发布时间】:2023-04-04 23:54:01
【问题描述】:
我正在尝试使用 ELK 管道来阅读电子邮件 (IMAP),提取通用附件(主要是 PDF,最后是 doc 或 ppt)并将它们放在 ElasticSearch 上。
这是我能够做到的:
- 使用 Logstash 从文件中直接加载一些 base64 数据到 ElasticSearch,使用 ElasticSearch 上的
Ingest Attachment Processor读取 base64 内容。 - 从 IMAP 加载数据(交换电子邮件)我可以在 ElasticSearch 上正确加载除附件(我需要的)之外的所有电子邮件信息。
第一个解决方案工作正常,可以满足我的要求,只是它不直接从电子邮件中提取附件,而且我在文件中硬编码了 base64 数据。
使用第二种解决方案,我在 Kibana 上有一个字段 x-ms-has-attach: yes,但附件本身没有任何地方。 imap 插件是为了只加载不带附件的邮件内容?
我错过了什么?你能建议我一条管道来实现我正在寻找的东西吗?
这是我为第一个示例配置的logstash:
input {
file {
path => "/my/path/to/data/*"
start_position => "beginning"
# sincedb_path => "/my/path/to/sincedb"
sincedb_path => "/dev/null"
close_older => 0
tags => ["attachment"]
}
}
output {
elasticsearch {
index => "email-attachment"
hosts => [ "localhost:9200" ]
}
}
这是管道:
PUT _ingest/pipeline/email-attachment
{
"description": "Pipeline to parse an email and its attachments",
"processors": [
{
"attachment" : {
"field" : "message"
}
},
{
"remove" : {
"field" : "message"
}
},
{
"date_index_name" : {
"field" : "@timestamp",
"index_name_prefix" : "email-attachment-",
"index_name_format": "yyyy-MM",
"date_rounding" : "M"
}
}
]
}
这是我的 第二个示例的logstash配置:
input {
imap {
host => "my.domain.it"
password => "mypassword"
user => "myuser"
port => 12345
type => "imap"
secure => true
strip_attachment => true
}
}
output {
elasticsearch {
index => "email-attachment"
hosts => [ "localhost:9200" ]
}
}
更新
我正在使用版本5.2.2
【问题讨论】:
标签: email elasticsearch logstash