Permalink
Browse files

add more options tags/message_type/fqdn

  • Loading branch information...
1 parent a0b80f7 commit a22d71ae02e2805011a8a640ffafd819b20fce85 @sebest committed Feb 6, 2014
Showing with 20 additions and 8 deletions.
  1. +6 −0 debian/changelog
  2. +1 −1 pystash/__init__.py
  3. +7 −1 pystash/cli.py
  4. +5 −5 pystash/server.py
  5. +1 −1 setup.py
View
@@ -1,3 +1,9 @@
+pystash (0.3-1~precise1) precise-dc; urgency=low
+
+ * Add more options
+
+ -- Sebastien Estienne <sebastien.estienne@gmail.com> Thu, 06 Feb 2014 12:37:30 +0100
+
pystash (0.2-1~precise1) precise-dc; urgency=low
* New logstash event format
View
@@ -3,4 +3,4 @@
__author__ = 'Sebastien Estienne'
__email__ = 'sebastien.estienne@gmail.com'
-__version__ = '0.2'
+__version__ = '0.3'
View
@@ -11,6 +11,12 @@ def main():
parser.add_argument('--redis-host', metavar='HOST', help='IP address of the redis server', default='localhost')
parser.add_argument('--redis-port', metavar='PORT', help='Port number of the redis server', default=6379, type=int)
parser.add_argument('--redis-queue', metavar='NAME', help='Name of the queue on the redis server', default='logstash')
+ parser.add_argument('--message-type', metavar='TYPE', help='Type in the event message', default='pystash')
+ parser.add_argument('--fqdn', action='store_true', help='Use the fully qualified domain name')
+ parser.add_argument('--logstash-version', metavar='VERSION', help='Version of logstash event message', default=1, type=int)
+ parser.add_argument('--logstash-tags', metavar='TAG1 TAG2', help='Tags for the logstash event message', nargs='+')
args = parser.parse_args()
Server(bind_ip=args.bind_ip, tcp_port=args.tcp_port, udp_port=args.udp_port, \
- redis_host=args.redis_host, redis_port=args.redis_port, redis_queue=args.redis_queue).start()
+ redis_host=args.redis_host, redis_port=args.redis_port, redis_queue=args.redis_queue, \
+ message_type=args.message_type, fqdn=args.fqdn, logstash_version=args.logstash_version, \
+ logstash_tags=args.logstash_tags).start()
View
@@ -21,21 +21,21 @@
class Server(object):
- def __init__(self, bind_ip='127.0.0.1', tcp_port=DEFAULT_TCP, udp_port=DEFAULT_UDP, redis_host='localhost', redis_port=6379, redis_queue='logstash', message_type='logstash', fqdn=True, version=1):
+ def __init__(self, bind_ip='127.0.0.1', tcp_port=DEFAULT_TCP, udp_port=DEFAULT_UDP, redis_host='localhost', redis_port=6379, redis_queue='logstash', message_type='pystash', fqdn=True, logstash_version=1, logstash_tags=None):
self.redis = redis.Redis(redis_host, redis_port)
self.redis_queue = redis_queue
- if version == 1:
- self.formatter = formatter.LogstashFormatterVersion1(message_type, [], fqdn)
+ if logstash_version == 1:
+ self.formatter = formatter.LogstashFormatterVersion1(message_type, logstash_tags, fqdn)
else:
- self.formatter = formatter.LogstashFormatterVersion0(message_type, [], fqdn)
+ self.formatter = formatter.LogstashFormatterVersion0(message_type, logstash_tags, fqdn)
self.udp_server = DatagramServer('%s:%s' % (bind_ip, udp_port), self.udp_handle)
self.tcp_server = StreamServer('%s:%s' % (bind_ip, tcp_port), self.tcp_handle)
logging.info('Listening on %s (udp=%s tcp=%s) sending to %s:%s.', bind_ip, udp_port, tcp_port, redis_host, redis_port)
def obj_to_redis(self, obj):
record = logging.makeLogRecord(obj)
payload = self.formatter.format(record)
- logger.debug('message %s', payload)
+ #logger.debug('message %s', payload)
self.redis.rpush(self.redis_queue, payload)
def udp_handle(self, data, address):
View
@@ -19,7 +19,7 @@
setup(
name='pystash',
- version='0.2',
+ version='0.3',
description='A proxy for python logging UDP/TCP to logstash/redis',
long_description=readme + '\n\n' + history,
author='Sebastien Estienne',

0 comments on commit a22d71a

Please sign in to comment.