I am currently using the ELK stack as provided by Docker here:
https://github.com/deviantony/docker-elk
To log in my python program, I am utilising the python-logstash
library:
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:
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:
http://127.0.0.1:9200/_search?pretty=true
There are also no error or debug messages returned by the python-logstash
library.
Can anybody point out what I am doing incorrectly?
My logstash.conf
contains the following:
input {
tcp {
port => 5000
codec => json
}
}
output {
elasticsearch {
hosts => "elasticsearch:9200"
codec => rubydebug
}
}
Use
LOGGER.addHandler(logstash.TCPLogstashHandler(127.0.0.1, 5000, version=1))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With