ELK logstash processing MySQL slow query log (Preliminary)

Source: Internet
Author: User
Tags mysql slow query log logstash

Write in front: In doing Elk logstash processing MySQL slow query log when the problem: 1, the test database does not have slow log, so there is no log information, resulting in ip:9200/_plugin/head/interface anomalies (suddenly appear log data, deleted the index disappeared) 2, Processing log script Problem 3, the current single-node configuration script file/usr/local/logstash-2.3.0/config/slowlog.conf "Verbose script file see last" output {elasticsearch {hosts = "1    15.28.3.150:9200 "index =" mysql-slowlog "workers = 1 Flush_size = 20000 Idle_flush_time = 10 Template_overwrite = True}} defines the IP and port of the Elasticsearch in Outpout and the index name [[email protected] config]#. /bin/logstash agent-f Slowlog.confSettings:Default Pipeline workers:1pipeline main started in http://115.28.3.150:9200/ Refresh on _plugin/head/page:

--------------------------------------------------------------------------------------------------------------- ----------------

Cat/usr/local/logstash-2.3.0/config/slowlog.conf

Input {

File {
Type = "Mysql-slow"
Path = "/mnt/data/mysql/mysql-slow.log"
Start_position = "Beginning"
Codec = Multiline {
Pattern = "^# time:"
Negate = True
what = "Previous"
}
}
}
Filter {
Grok {
Match + = {"Message" = "Select SLEEP"}
Add_tag = ["Sleep_drop"]
Tag_on_failure = []
}
If "Sleep_drop" in [tags] {
Drop {}
}
Grok {
Match + = ["Message", "(? m) ^# time:.*\s+# [email protected]:%{user:user}\[[^\]]+\] @ (?:(?) <clienthost>\s*)? \[(?:%{ip:clientip})? \]\s*id:%{number:id:int}\s+# query_time:%{number:query_time:float} \s+lock_time:%{number:lock_time:float}\s+rows_sent:%{number:rows_sent:int}\s+rows_examined:%{NUMBER:rows_ examined:int}\s* (?: Use%{data:database};\s*)? SET timestamp=%{number:timestamp};\s* (?<query> (? <action>\w+) \s+.*) $ "]
}
Date {
Match = ["timestamp", "UNIX"]
Remove_field = ["Timestamp"]
}
}
Output {
Elasticsearch {
hosts = "192.168.98.163:9200"
index = "Mysql-slowlog"
Workers = 1
Flush_size = 20000
Idle_flush_time = 10
Template_overwrite = True
}
}

ELK logstash processing MySQL slow query log (Preliminary)

Related Article

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.