#NEWLINE# def start( host , port = 5959 , tag = 'salt/engine/logstash' ) : #NEWLINE# #INDENT# '\n    Listen to salt events and forward them to logstash\n    ' #NEWLINE# logstash_logger = logging . getLogger ( 'python-logstash-logger' ) #NEWLINE# logstash_logger . setLevel ( logging . INFO ) #NEWLINE# logstash_logger . addHandler ( logstash . LogstashHandler ( host , logstash_logger , version = 1 ) ) #NEWLINE# if __opts__ . get ( 'id' ) . endswith ( '_master' ) : #NEWLINE# #INDENT# event_bus = salt . utils . event . get_master_event ( __opts__ , __opts__ [ 'sock_dir' ] , listen = True ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# event_bus = salt . utils . event . get_event ( 'minion' , transport = __opts__ [ 'transport' ] , opts = __opts__ , sock_dir = __opts__ [ 'sock_dir' ] , listen = True ) #NEWLINE# log . debug ( 'Logstash engine started' ) #NEWLINE# #UNINDENT# while True : #NEWLINE# #INDENT# event = event_bus . get_event ( ) #NEWLINE# if event : #NEWLINE# #INDENT# logstash_logger . info ( tag , extra = json . dumps ( event ) )