我在linux上搭建了一个SMTP邮件服务器,主要是ELK用来发送预警邮件;
邮件内容都是一些JAVA异常的堆栈信息;
然后有部分邮件内容会出现乱码,看着好像是编码之后没有解码的内容。
如图:
不知道是什么原因造成的,我之前用的是163邮件服务器发送的,然后接收邮件的是QQ邮箱;开始以为是两个邮箱不一样导致的,后面把163邮件服务器改成了QQ邮件服务;但是问题依然存在......
以下是我搭建SMTP邮件服务器的步骤:
以下是ELK发送预警邮件的配置:
{
"actions": {
"email_html_alarm_7d6323ca-2835-4ffe-a78b-65acb93c2f55": {
"name": "email html alarm",
"throttle_period": "1m",
"email_html": {
"to": "to@qq.com",
"from": "from@163.com",
"stateless": false,
"subject": "xxx异常预警检测到[开发环境]xxx日志中有{{payload.hits.total}}个异常信息",
"priority": "high",
"html": "<p>Hi {{watcher.username}},</p><br/><p>xxx异常预警发现{{payload.hits.total}}个异常信息,<a href=\"http://192.168.2.16:5601/app/kibana\" target=\"_blank\">点击</a>查看详情。</p><p>异常信息如下:</p>{{#payload.hits.hits}}<p>MessageInfo:<i style=\"color: grey\">{{_source.message}}</i><br/>Hosts:<i style=\"color: grey\">{{_source.fields.logsource}}</i><br/>SourceFile:<i style=\"color: grey\">{{_source.source}}</i><br/>LogType:<i style=\"color: grey\">{{_source.fields.logtype}}</i><br/>Time:<i style=\"color: grey\">{{_source.@timestamp}}</i></p>{{/payload.hits.hits}}<br/><div style=\"color: grey\"><br/><hr><br/><p>此监视程序根据以下标准发送警报:</p><br/><ul><li>{{watcher.condition.script.script}}</li></ul><br/></div>"
}
}
},
"input": {
"search": {
"request": {
"index": [
"filebeat-*"
],
"body": {
"query": {
"bool": {
"must": [
{
"term": {
"fields.logtype": "xxx"
}
},
{
"term": {
"tags": "exception"
}
},
{
"range": {
"@timestamp": {
"gte": "now-1h",
"lte": "now",
"format": "epoch_millis"
}
}
}
],
"must_not": [],
"should": []
}
},
"sort": [
{
"@timestamp": {
"order": "desc"
}
}
]
}
}
}
},
"condition": {
"script": {
"script": "payload.hits.total >= 1"
}
},
"trigger": {
"schedule": {
"later": "every 1 hours"
}
},
"disable": false,
"report": false,
"title": "xxx异常预警",
"save_payload": false,
"spy": false,
"impersonate": false,
"username": "xxx"
}