-
Notifications
You must be signed in to change notification settings - Fork 64
Configuration and making it work in Python
The purpose of this page is to share how to make it work in python and posterior analysis in kibana. I wanted to share what worked for me, I made it work with dict config, this way I got every formatter in only one config file and so I can change it behaviour easily.
In your config file (say logging.cfg) add the logstash formatter like this:
"formatters": { "logstash":{ "()": "logstash_formatter.LogstashFormatter" } }
Then in python (for example in an init method of your logManager):
import json, logging
from dictconfig import dictConfig
from logstash_formatter import LogstashFormatter
config = json.load(open('path_to_your_config/logging.cfg', 'r'))
dictConfig(config)
That's all you need to formatt output in json format, but if you want every field to be load and indexed into elasticsearch for better quering you must add a logstash filter in your logstash config file:
filter {
json {
source => "message"
}
}
Hope this help someone else when configuring things.