Merge pull request #69 from UnrealAkama/es_support

elasticsearch output support - early release
This commit is contained in:
Michel Oosterhof
2015-11-17 08:51:47 +04:00
2 changed files with 42 additions and 0 deletions

View File

@@ -234,6 +234,14 @@ interact_port = 5123
[output_jsonlog]
logfile = log/cowrie.json
# Supports logging to elasticsearch
# This is a simple early release
#
#[output-elasticsearch]
#host = localhost
#port = 9200
#index = cowrie
#type = cowrie
# Local Syslog output module
#

View File

@@ -0,0 +1,34 @@
# Simple elasticsearch logger
import os
import json
import pyes
import cowrie.core.output
class Output(cowrie.core.output.Output):
def __init__(self, cfg):
self.host = cfg.get('output_elasticsearch', 'host')
self.port = cfg.get('output_elasticsearch', 'port')
self.index = cfg.get('output_elasticsearch', 'index')
self.type = cfg.get('output_elasticsearch', 'type')
cowrie.core.output.Output.__init__(self, cfg)
def start(self):
self.es = pyes.ES('{0}:{1}'.format(self.host, self.port))
def stop(self):
pass
def write(self, logentry):
for i in logentry.keys():
# remove twisted 15 legacy keys
if i.startswith('log_'):
del logentry[i]
self.es.index(logentry, self.index, self.type)