Attach multiple tags to logstash events.

* modules/openstack_project/files/logstash/log-pusher.py: If a list of
tags is provided under a source file configured in the yaml config
attach those tags to the log events generated from that source file.

Example yaml:
  source-files:
    - name: console.html
      retry-get: True
      tags:
        - foo
        - bar

Change-Id: Ib74abad2d06d3e52e5b21b0fb38033f9474ab4e4
Reviewed-on: https://review.openstack.org/29808
Reviewed-by: James E. Blair <corvus@inaugust.com>
Approved: Clark Boylan <clark.boylan@gmail.com>
Reviewed-by: Clark Boylan <clark.boylan@gmail.com>
Tested-by: Jenkins
This commit is contained in:
Clark Boylan 2013-05-20 12:05:28 -07:00 committed by Jenkins
parent ff66c84a94
commit 6f686f2b09

View File

@ -94,7 +94,7 @@ class LogRetriever(threading.Thread):
}
def __init__(self, eventq, logq, log_address,
filename, retry=False, job_filter=''):
filename, retry=False, job_filter='', tags=None):
threading.Thread.__init__(self)
self.eventq = eventq
self.logq = logq
@ -102,7 +102,9 @@ class LogRetriever(threading.Thread):
self.log_address = log_address
self.filename = filename
self.job_filter = job_filter
self.tag = [self.filename]
self.tags = [self.filename]
if tags:
self.tags.extend(tags)
def run(self):
while True:
@ -125,7 +127,7 @@ class LogRetriever(threading.Thread):
for line in log_lines:
out_event = {}
out_event["@fields"] = fields
out_event["@tags"] = self.tag
out_event["@tags"] = self.tags
out_event["event_message"] = line
self.logq.put(out_event)
@ -308,8 +310,8 @@ class Server(object):
source_file['name'],
retry=source_file.get('retry-get',
self.default_retry),
job_filter=source_file.get('filter',
''))
job_filter=source_file.get('filter', ''),
tags=source_file.get('tags', []))
self.retrievers.append(retriever)
def setup_catchers(self):