elastalert 不发送电子邮件

elastalert not sending out email

我在 Docker 图片上设置了弹性警报,并尝试通过 gmail smtp 服务器发送电子邮件,但不断收到错误

我的 config.yaml 文件是:

...
smtp_auth_file: /usr/local/bin/elastalert/rules/email_auth.yaml

我的电子邮件验证文件是:

smtp_host: smtp.gmail.com
from_addr: some_random_addr@gmail.com
user: "username"
password: "password"

但我得到的错误是:

util.EAException: Error loading file /usr/local/bin/elastalert/rules/email_auth.yaml: Invalid Rule: None
{'from_addr': 'some_rand_addr@gmail.com', 'smtp_ssl': True, 'smtp_host': 'smtp.gmail.com', 'user': 'username', 'rule_file': '/usr/local/bin/elastalert/rules/email_auth.yaml', 'password': 'password'} is valid under each of {'properties': {'type': {'pattern': '[.]'}}, 'title': 'Custom Rule from Module'}, {'properties': {'type': {'enum': ['any']}}, 'title': 'Any'}

Failed validating 'oneOf' in schema:
    {'$schema': 'http://json-schema.org/draft-04/schema#',
     'definitions': {'arrayOfStrings': {'items': {'type': 'string'},
                                        'type': ['string', 'array']},
                     'arrayOfStringsOrOtherArrays': {'items': {'type': ['string',
                                                                        'array']},
                                                     'type': ['string',
                                                              'array']},
                     'filter': {},
                     'timeFrame': {'additionalProperties': False,
                                   'properties': {'days': {'type': 'number'},
                                                  'hours': {'type': 'number'},
                                                  'milliseconds': {'type': 'number'},
                                                  'minutes': {'type': 'number'},
                                                  'schedule': {'type': 'string'},
                                                  'seconds': {'type': 'number'},
                                                  'weeks': {'type': 'number'}},
                                   'type': 'object'}},
     'oneOf': [{'properties': {'type': {'enum': ['any']}},
                'title': 'Any'},
               {'properties': {'blacklist': {'items': {'type': 'string'},
                                             'type': 'array'},
                               'compare_key': {'type': 'string'},
                               'type': {'enum': ['blacklist']}},
                'required': ['blacklist', 'compare_key'],
                'title': 'Blacklist'},
               {'properties': {'compare_key': {'type': 'string'},
                               'ignore_null': {'type': 'boolean'},
                               'type': {'enum': ['whitelist']},
                               'whitelist': {'items': {'type': 'string'},
                                             'type': 'array'}},
                'required': ['whitelist', 'compare_key', 'ignore_null'],
                'title': 'Whitelist'},
               {'properties': {'compare_key': {'type': 'string'},
                               'ignore_null': {'type': 'boolean'},
                               'timeframe': {'additionalProperties': False,
                                             'properties': {'days': {'type': 'number'},
                                                            'hours': {'type': 'number'},
                                                            'milliseconds': {'type': 'number'},
                                                            'minutes': {'type': 'number'},
                                                            'schedule': {'type': 'string'},
                                                            'seconds': {'type': 'number'},
                                                            'weeks': {'type': 'number'}},
                                             'type': 'object'},
                               'type': {'enum': ['change']}},
                'required': ['query_key', 'compare_key', 'ignore_null'],
                'title': 'Change'},

我检查了 elastalert/config.py 和 schma.yaml,发现 smtp_auth_file,用户和密码 属性 甚至没有在 schma.yaml 中定义。那是导致验证错误的原因吗?任何人都知道我的设置哪里出错了?谢谢

我发现了问题。我将 email_authentication.yaml 放在 rule_folder 的同一文件夹中。一旦我把它移出,这个错误就解决了。