[英]Writing python log files to logstash
I am currently using the ELK stack as provided by Docker here: 我目前正在使用Docker提供的ELK堆栈:
https://github.com/deviantony/docker-elk
To log in my python program, I am utilising the python-logstash
library: 要登录我的python程序,我正在使用
python-logstash
库:
https://github.com/vklochan/python-logstash
I am trying to write log to logstash (and view the subsequent data in Kibana) using the example at the python-logstash
github page: 我正在尝试使用
python-logstash
github页面上的示例将日志写入logstash(并在Kibana中查看后续数据):
LOGGER = logging.getLogger('python-logstash-logger')
LOGGER.setLevel(logging.INFO)
LOGGER.addHandler(logstash.LogstashHandler(127.0.0.1, 5000, version=1))
LOGGER.error('python-logstash: test logstash error message.')
However, this is not writing any data to ElasticSearch, as verified via: 但是,这不会向ElasticSearch写入任何数据,如通过以下方式验证:
http://127.0.0.1:9200/_search?pretty=true
There are also no error or debug messages returned by the python-logstash
library. python-logstash
库也没有返回错误或调试消息。
Can anybody point out what I am doing incorrectly? 任何人都可以指出我做错了什么吗?
My logstash.conf
contains the following: 我的
logstash.conf
包含以下内容:
input {
tcp {
port => 5000
codec => json
}
}
output {
elasticsearch {
hosts => "elasticsearch:9200"
codec => rubydebug
}
}
使用
LOGGER.addHandler(logstash.TCPLogstashHandler(127.0.0.1, 5000, version=1))
这对我有用:
LOGGER.addHandler(logstash.TCPLogstashHandler('127.0.0.1', 5000, version=1))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.