Как отлаживать вывод Logstash?


Ответы

Самый простой добавить stdout {} в output

С помощью Flask

pipelines/pipeline.conf

output {
    http {
        url => "http://127.0.0.1:5000/"
        format => "json"
        http_method => "post"
        mapping => {
            "logdatetime" => "%{logdatetime}"
            "remote_addr" => "%{remote_addr}"
            "server_name" => "%{server_name}"
            "request_method" => "%{request_method}"
            "uri" => "%{uri}"
            "server_protocol" => "%{server_protocol}"
            "status" => "%{status}"
            "request_length" => "%{request_length}"
            "bytes_sent" => "%{bytes_sent}"
            "request_time" => "%{request_time}"
            "http_referer" => "%{http_referer}"
            "http_user_agent" => "%{http_user_agent}"
            "http_x_forwarded_for" => "%{http_x_forwarded_for}"
        }
    }
}

Flask приложение

import logging

from flask import Flask, request

app = Flask(__name__)

@app.route('/', methods=['POST'])
def logstash():
"""Приём обработанного лога из Logstash
"""
logging.info(request.json)
return 'True' if __name__ == '__main__': app.run()

Возможно будут интересны и другие вопросы
© RemiZOffAlex