How to send logs to filebeat with python logging

(Tony Wang) #1

The code I used shows below. I want to send logs with python. But What I got from Kibana is :

elk_1 | {"type":"log","@timestamp":"2017-05-10T04:23:51Z","tags":["connection","client","error"],"pid":194,"level":"error","message":"Parse Error","error":{"message":"Parse Error","name":"Error","stack":"Error: Parse Error\n at Error (native)","code":"HPE_INVALID_METHOD"}}

The images I used is here :

Is there any better solution for python? Thanks!
import logger

logger = logger.configure()'hello world')
import logging
import logstash
import logging.handlers

def configure():
    host = ''
                        format="%(asctime)s - %(module)s - line %(lineno)d  - process-id %(process)d -  (%(threadName)-5s)- %(levelname)s - %(message)s")
    # fileConfig(log_file_path)
    logger = logging.getLogger(__name__)
    logger.addHandler(logstash.TCPLogstashHandler(host, 5601, version=1))
    return logger

(Steffen Siering) #2

One doesn't send logs to Filebeat. Filebeat ships logs from files. One just logs to a file (don't forget about logrotation in logger or via logrotate) and filebeat picks it up. When logging e.g. python stack-traces, you might want to configure multiline in filebeat.

(system) #3

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.