eval log body for index
@@ -52,14 +52,17 @@ class RmqEs():
callback triggered on rabiitmq message received and sends it to
an elasticsearch index
"""
- # !! TODO index needs to be reworked for multiple file types
- # !! TODO this will need to account for keeping logs and plugin output seperate
index = method.routing_key.split(".")[1]
- if method.routing_key.split(".")[0] == 'syslog':
+ try:
+ doc = ast.literal_eval(body)
+ except Exception as e:
+ try:
body = body.strip().replace('"', '\"')
body = '{"log":"'+body+'"}'
- try:
doc = ast.literal_eval(body)
+ except Exception as e:
+ pass
+ try:
res = self.es_conn.index(index=index, doc_type=method.routing_key.split(".")[1], id=method.routing_key+"."+str(uuid.uuid4()), body=doc)
print(" [x] "+str(datetime.datetime.utcnow())+" UTC {0!r}:{1!r}".format(method.routing_key, body))
except Exception as e:
