python-2.7 - 如何在elastalert中配置Config.yaml?

标签 python-2.7 elasticsearch elastalert

我对Elastcalert完全陌生。当没有日志从我的客户端服务器发送到Elasticalert时,我正在尝试使用logstash来发送电子邮件。我已经在主服务器上成功安装了Elastcalert。但是,当我运行elastalert-create-index时,出现以下错误:

Traceback (most recent call last):
File "/usr/bin/elastalert-create-index", line 11, in <module>
load_entry_point('elastalert==0.1.21', 'console_scripts', 'elastalert-
create-index')()
File "/usr/lib/python2.7/site-packages/elastalert-0.1.21-
py2.7.egg/elastalert/create_index.py", line 77, in main
username = args.username if args.username else data.get('es_username')
UnboundLocalError: local variable 'data' referenced before assignment

我的config.yaml如下:
# This is the folder that contains the rule yaml files
# Any .yaml file will be loaded as a rule
rules_folder: example_rules

# How often ElastAlert will query Elasticsearch
# The unit can be anything from weeks to seconds
run_every:
  minutes: 1

# ElastAlert will buffer results from the most recent
# period of time, in case some log sources are not in real time
buffer_time:
  minutes: 15

# The Elasticsearch hostname for metadata writeback
# Note that every rule can have its own Elasticsearch host
es_host: localhost

# The Elasticsearch port
es_port: 9200

# The AWS region to use. Set this when using AWS-managed elasticsearch
#aws_region: us-east-1

# The AWS profile to use. Use this if you are using an aws-cli profile.
# See http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-
started.html
# for details
#profile: test

# Optional URL prefix for Elasticsearch
#es_url_prefix: elasticsearch

# Connect with TLS to Elasticsearch
#use_ssl: True

# Verify TLS certificates
#verify_certs: True

# GET request with body is the default option for Elasticsearch.
# If it fails for some reason, you can pass 'GET', 'POST' or 'source'.
# See http://elasticsearch-py.readthedocs.io/en/master/connection.html?
highlight=send_get_body_as#transport
# for details
#es_send_get_body_as: GET

# Option basic-auth username and password for Elasticsearch
#es_username:
#es_password:

# Use SSL authentication with client certificates client_cert must be
# a pem file containing both cert and key for client
#verify_certs: True
#ca_certs: /path/to/cacert.pem
#client_cert: /path/to/client_cert.pem
#client_key: /path/to/client_key.key

# The index on es_host which is used for metadata storage
# This can be a unmapped index, but it is recommended that you run
# elastalert-create-index to set a mapping
writeback_index: elastalert_status

# If an alert fails for some reason, ElastAlert will retry
# sending the alert until this time period has elapsed
alert_time_limit:
  days: 2

最佳答案

您是否尝试不带任何参数运行elastalert-create-index?它会指导您完成以下设置过程:

$>elastalert-create-index
Enter Elasticsearch host: localhost
Enter Elasticsearch port: 9200
Use SSL? t/f: f
Enter optional basic-auth username (or leave blank):
Enter optional basic-auth password (or leave blank):
Enter optional Elasticsearch URL prefix (prepends a string to the URL of every request):
New index name? (Default elastalert_status)
Name of existing index to copy? (Default None)
Elastic Version:6
Mapping used for string:{'type': 'keyword'}
New index elastalert_status created
Done!

关于python-2.7 - 如何在elastalert中配置Config.yaml?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46645253/

相关文章:

python - 如何从文件或列表中读取?

python-2.7 - python中numpy数组的简单绘图?

python - 比较两个 csv 文件并添加两个文件中不常见的列

elasticsearch - Logstash正在将旧数据放入Elasticsearch。无法清除Elasticsearch数据

java - Spring Data elasticsearch @Query 注解嵌套对象

elasticsearch - elastalert-create-index未知的模仿类型错误

elasticsearch - 无法启动ElastAlert:仅支持pytz库中的时区

python - 将 python 操作转换为 numpy

elasticsearch - elastalert 中的电子邮件发送错误。 SMTPSenderRefused : (530, '5.5.1 需要身份验证)

java - 使 ElasticSearch 在配置错误时失败