Outputs

elasticsearch

class logcabin.outputs.elasticsearch.Elasticsearch(index, type, host='localhost', port=9200)

Outputs to an elasticsearch index.

Parameters:
  • host (string) – elasticsearch host
  • port (integer) – elasticsearch port
  • index (string) – (required) elasticsearch index. This can be formatted by fields in the event.
  • type (string) – (required) elasticsearch type. This can be formatted by fields in the event.

Example configuration for kibana:

Mutate(rename={'@timestamp': 'timestamp', '@message': 'message'})
Elasticsearch(index='logstash-{@timestamp:%Y.%m.%d}', type='event')

file

class logcabin.outputs.file.File(filename, max_size=None, max_count=10, compress=None)

Log to file.

The file format is a line per event as json.

When a log is rolled, a ‘virtual’ event will be generated with the tag ‘fileroll’, and the field ‘filename’ which can be used by further outputs to process a log file when it rolls (eg. batch upload to S3). This event contains a ‘trigger’ field containing the original event that caused the log roll.

Parameters:
  • filename (string) – the log filename (required). You can use event format values in this (eg. ‘output-{program}.log’)
  • max_size (integer) – maximum size of file before rolling to .1, .2, etc.
  • max_count (integer) – maximum number of rolled files (default: 10)
  • compress (string) – set to ‘gz’ to compress the file after rolling.

Example:

File(filename='mylogs.log', max_size=10, compress='gz')

graphite

class logcabin.outputs.graphite.Graphite(host='localhost', port=2004)

Upload stats data to a graphite server.

Parameters:
  • host (string) – graphite server hostname
  • port (string) – graphite server port

Example:

Graphite(host='graphite')

log

class logcabin.outputs.log.Log(message='')

Logging output.

Parameters:message (string) – message to log (optional)

Example:

Log(message="event:")

mongodb

class logcabin.outputs.mongodb.Mongodb(host='localhost', port=27017, database='test', collection='events')

Outputs to a mongodb collection.

Parameters:
  • host (string) – mongodb host
  • port (integer) – mongodb port
  • database (string) – mongodb database
  • collection (string) – mongodb collection

Example:

Mongodb(host="mongodb", database="logs")

perf

class logcabin.outputs.perf.Perf(period=60)

Simple performance counter output.

Parameters:period (integer) – interval between reports in seconds

Example:

Perf(period=5)

s3

class logcabin.outputs.s3.S3(access_key, secret_key, bucket, path)

Uploads to an S3 bucket.

This should follow the File output, in order to upload the rolled log files to S3:

File(filename='log/batch.log', )
If(lambda ev: 'fileroll' in ev.tags):
    S3(access_key='...', secret_key='...',
       bucket='x', path='logs/{timestamp:%Y-%m-%d/%H%M%S}.log')

Bucket or path may by formatted by event, eg. to upload to a timestamped path: path=’{timestamp:%Y-%m-%d/%H%M%S}.log’

Parameters:
  • access_key (string) – Amazon S3 access key
  • secret_key (string) – Amazon S3 secret key
  • bucket (string) – the bucket name
  • path (string) – the path

zeromq

class logcabin.outputs.zeromq.Zeromq(address='tcp://127.0.0.1:2120', mode='connect', socket='PUSH')

Outputs on a zeromq socket.

Parameters:
  • address (string) – zeromq address (default: tcp://*:2120)
  • mode (string) – connect or bind (default: connect)
  • socket (string) – PUSH or PUB (default: PUSH)

Example:

Zeromq(address="tcp://relay:2120", mode="connect", socket="PUSH")