Skip to main content

Log handler that ships json formatted messages to logstash via TCP and UDP

Project description

logstashHandler is a basic logging handler for sending to a logstash instance via UDP or TCP encoded as json.

Basic usage

Setup an input on the relevant logstash server:

input {
  udp {
    port => 12345
    codec => json
  }
}

Setup handler and ship logs:

python
from logstashHandler import logstashHandler

lhandler = logstashHandler(host='mylogserver.example.com',port=12345,proto='UDP')
logger.addHandler(lhandler)
logger.warn("Something went wrong")

To send additional fields to logstash, use the keyword extra and send a dict starting with extraFields:

logger.warn('DANGER DANGER',extra={'extraFields':{'name':'W. Robinsson', 'planet':'Unkown'}})

The default level field name and individual level names can be overridden as so:

levels = {'ERROR': 3, 'WARNING': 2, 'INFO': 1, 'DEBUG': 0}
lhandler = logstashHandler(
    host='mylogserver.example.com',
    port=12345,proto='UDP',
    levels=levels,
    levelLabel='severity'
)

More info can be found on the github page.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

logstashHandler-0.1.1.tar.gz (2.2 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page