Use logstash to collect php-fpmslowlog

Source: Internet
Author: User
Tags php error log logstash
Use logstash to collect php-fpmslowlog. Currently, the php-fpm service is deployed in docker. the php-fpm log and php error log can be sent through the syslog protocol, however, the slow log of php-fpm cannot be configured as a syslog protocol and can only be output to files, because an slow log consists of multiple lines.

To collect slow logs, you can collect them using tools such as logstash and flume. This article uses logstash to collect slow logs and write the collected logs to kafka for subsequent processing. Logstash input adopts the file reading method, which is similar to the principle of tail-f. To merge multiline logs as one row, multiline logs in the filter are used. The logstash configuration is as follows:

Input {file {path => ["/var/log/php-fpm/fpm-slow.log"]} filter {multiline {pattern => "^ $" negate => true what => "previous" }}output {stdout {codec => rubydebug} kafka {codec => plain {format => "tag |%{ host }%{ message}"} topic_id => "fpm-slowlog" bootstrap_servers => "kafka1.hostname: 8082, kafka2.hostname: 8082 "}}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.