SlideShare a Scribd company logo
using Beats & ELK
MySQL Slow Query log Monitoring
About me
2
dba.kim@gmail.com
Architecture
MySQL Slow Log
DB Servers ELK Server
Logstash Elasticsearch
FileBeat Kibana
3
Install & Config FileBeat
4
# rpm -ivh filebeat-1.0.1-x86_64.rpm
$vi /etc/filebeat/filebeat.yml
filebeat:
prospectors:
paths:
- /db/data01/mysql-slow.log //slow query path
output:
#elasticsearch: //comment
#hosts: ["localhost:9200"] //comment
logstash: //uncomment
# The Logstash hosts
hosts: ["10.xx.xx.xx:5044"] //logstash server ip
1. Install FileBeat – on DB servers
2. Parameter configuration
5
# /etc/init.d/filebeat start
Starting filebeat: [ OK ]
3. Start FileBeat – on DB servers
Install & Config FileBeat
Install & Config Elasticsearch
6
# tar –xzvf elasticsearch-2.1.1.tar.gz
1. Install Elasticsearch – on ELK servers
2. configuration
$ vi ./elasticsearch-2.1.1/config/elasticsearch.yml
cluster.name : log_cluster # cluster name
node.name : slow_log # node name
path.data: /DATA/data # index data path
path.logs: /DATA/logs # log path
network.host : 10.xxx.xxx.xxx # server’s ip
7
3. start elasticsearch
$./bin/elasticsearch
You can’t run elastisearch as root.
Install & Config Elasticsearch
Install & Config Logstash
8
1. Install Logstash – on ELK server
$ rpm –ivh logstash-2.1.1-1.noarch.rpm
2-1. Configure(input plugin)
# vi /etc/logstash/conf.d/10-slow-log.conf
input {
beats {
port => 5044
codec => multiline{
pattern => "^# Time:"
negate => true
what => previous
}
}
}
9
2-2. Configure(filter plugin)
filter {
grok {
match => [ "message", "^# User@Host: %{USER:query_user}(?:[[^]]+])?s+@s+%{HOSTNAME:query_host}?s+[%{IP:query_ip}?]" ]
}
grok {
match => [ "message", "^#
Thread_id: %{NUMBER:thread_id:int}s+Schema: %{USER:schema}s+Last_errno: %{NUMBER:last_errno:int}s+Killed: %{NUMBER:killed:int}"]
}
grok {
match => [ "message", "^# Query_time: %{NUMBER:query_time:float}s+Lock_time: %{NUMBER:lock_time}s+ Rows_sent: %{NUMBER:rows_sent:int}
s+Rows_examined: %{NUMBER:rows_examined:int}s+Rows_affected: %{NUMBER:rows_affected:int}s+Rows_read: %{NUMBER:rows_read:int}"]
}
grok { match => [ "message", "^# Bytes_sent: %{NUMBER:bytes_sent:float}"] }
grok { match => [ "message", "^SET timestamp=%{NUMBER:timestamp}" ] }
grok { match => [ "message", "^SET timestamp=%{NUMBER};s+%{GREEDYDATA:query}" ] }
date { match => [ "timestamp", "UNIX" ] }
mutate {
remove_field => "timestamp"
}
}
Install & Config Logstash
10
2-3. Configure(output plugin)
output {
elasticsearch {
hosts => "10.xx.xx.xx"
}
}
3. Beats plugin install
# cd /opt/logstash/bin
# ./plugin install logstash-input-beats
4. Start logstash
# /etc/init.d/logstash start
Install & Config Logstash
Install & Config Kibana
11
1. Install Kibana – on ELK server
$ tar –xvf kibana-4.3.1-linux-x64.tar.gz
2. Configure
$ vi ./kibana-4.3.1-linux-x64/config/kibana.yml
server.host: "10.xx.xx.xx“ # kibana server ip
elasticsearch.url: "http://10.xx.xx.xx:9200" # elasticsearch server ip
3. Start Kibana
$ ./bin/kibana
Visualize – Slow query graph 12
mouse over
Install & Config Kibana
13
New Visualization > Line chart
Install & Config Kibana
Visualize – Slow query graph
Dashboard - sample 14
http://10.xxx.xxx.xxx:5601
Install & Config Kibana
Thank You

More Related Content

PDF
MySQL Multi-Source Replication for PL2016
PPTX
My sql failover test using orchestrator
PDF
Galera cluster for high availability
PPTX
KOCOON – KAKAO Automatic K8S Monitoring
PDF
Federated Engine 실무적용사례
PDF
MySQL/MariaDB Proxy Software Test
PDF
ProxySQL High Availability (Clustering)
PDF
[2018] MySQL 이중화 진화기
MySQL Multi-Source Replication for PL2016
My sql failover test using orchestrator
Galera cluster for high availability
KOCOON – KAKAO Automatic K8S Monitoring
Federated Engine 실무적용사례
MySQL/MariaDB Proxy Software Test
ProxySQL High Availability (Clustering)
[2018] MySQL 이중화 진화기

What's hot (20)

PDF
MySQL Advanced Administrator 2021 - 네오클로바
PDF
Introduction to Kubernetes RBAC
PDF
No Easy Breach DerbyCon 2016
PDF
Scouter와 influx db – grafana 연동 가이드
PDF
Kubernetes networking & Security
PDF
Lessons Learned: Troubleshooting Replication
PDF
Maxscale switchover, failover, and auto rejoin
PPTX
[135] 오픈소스 데이터베이스, 은행 서비스에 첫발을 내밀다.
PPTX
Mongo DB 완벽가이드 - 4장 쿼리하기
PDF
MySQL GTID Concepts, Implementation and troubleshooting
PPTX
Hashicorp Vault ppt
PPTX
Maxscale 소개 1.1.1
PPTX
MySQL Monitoring using Prometheus & Grafana
PDF
Disaster Recovery with MySQL InnoDB ClusterSet - What is it and how do I use it?
PPTX
Maria db 이중화구성_고민하기
PPT
Galera Cluster Best Practices for DBA's and DevOps Part 1
PPTX
MySQL8.0_performance_schema.pptx
PDF
Introduction to the Mysteries of ClickHouse Replication, By Robert Hodges and...
PDF
Git slides
PDF
MySQL InnoDB Cluster: Management and Troubleshooting with MySQL Shell
MySQL Advanced Administrator 2021 - 네오클로바
Introduction to Kubernetes RBAC
No Easy Breach DerbyCon 2016
Scouter와 influx db – grafana 연동 가이드
Kubernetes networking & Security
Lessons Learned: Troubleshooting Replication
Maxscale switchover, failover, and auto rejoin
[135] 오픈소스 데이터베이스, 은행 서비스에 첫발을 내밀다.
Mongo DB 완벽가이드 - 4장 쿼리하기
MySQL GTID Concepts, Implementation and troubleshooting
Hashicorp Vault ppt
Maxscale 소개 1.1.1
MySQL Monitoring using Prometheus & Grafana
Disaster Recovery with MySQL InnoDB ClusterSet - What is it and how do I use it?
Maria db 이중화구성_고민하기
Galera Cluster Best Practices for DBA's and DevOps Part 1
MySQL8.0_performance_schema.pptx
Introduction to the Mysteries of ClickHouse Replication, By Robert Hodges and...
Git slides
MySQL InnoDB Cluster: Management and Troubleshooting with MySQL Shell
Ad

Similar to MySQL Slow Query log Monitoring using Beats & ELK (20)

PPT
Elk presentation 2#3
PDF
Introducing ELK
PPTX
Elk ruminating on logs
PDF
Brisbane DevOps Meetup - Logstash
PDF
Log analysis with the elk stack
PPT
ELK stack at weibo.com
PPTX
Elastic stack Presentation
PPTX
ELK Ruminating on Logs (Zendcon 2016)
PPT
Logstash
PDF
LogStash in action
PDF
OSDC 2016 - Unifying Logs and Metrics Data with Elastic Beats by Monica Sarbu
PPTX
Log management with ELK
PDF
ELK: a log management framework
PPTX
Kibana+ElasticSearch+LogStash to handle Log messages on Prod servers
PDF
"How about no grep and zabbix?". ELK based alerts and metrics.
KEY
Zero mq logs
PDF
Log analysis with elastic stack
PPTX
Attack monitoring using ElasticSearch Logstash and Kibana
ODP
Log aggregation and analysis
PDF
Null Bachaav - May 07 Attack Monitoring workshop.
Elk presentation 2#3
Introducing ELK
Elk ruminating on logs
Brisbane DevOps Meetup - Logstash
Log analysis with the elk stack
ELK stack at weibo.com
Elastic stack Presentation
ELK Ruminating on Logs (Zendcon 2016)
Logstash
LogStash in action
OSDC 2016 - Unifying Logs and Metrics Data with Elastic Beats by Monica Sarbu
Log management with ELK
ELK: a log management framework
Kibana+ElasticSearch+LogStash to handle Log messages on Prod servers
"How about no grep and zabbix?". ELK based alerts and metrics.
Zero mq logs
Log analysis with elastic stack
Attack monitoring using ElasticSearch Logstash and Kibana
Log aggregation and analysis
Null Bachaav - May 07 Attack Monitoring workshop.
Ad

Recently uploaded (20)

PDF
Data Science Trends & Career Guide---ppt
PPTX
The THESIS FINAL-DEFENSE-PRESENTATION.pptx
PPTX
Introduction-to-Cloud-ComputingFinal.pptx
PPTX
Introduction to Basics of Ethical Hacking and Penetration Testing -Unit No. 1...
PDF
Clinical guidelines as a resource for EBP(1).pdf
PPTX
CEE 2 REPORT G7.pptxbdbshjdgsgjgsjfiuhsd
PPT
Chapter 2 METAL FORMINGhhhhhhhjjjjmmmmmmmmm
PPTX
Major-Components-ofNKJNNKNKNKNKronment.pptx
PPTX
climate analysis of Dhaka ,Banglades.pptx
PPTX
Global journeys: estimating international migration
PPTX
Moving the Public Sector (Government) to a Digital Adoption
PPTX
Introduction to Firewall Analytics - Interfirewall and Transfirewall.pptx
PPTX
Data_Analytics_and_PowerBI_Presentation.pptx
PPT
Reliability_Chapter_ presentation 1221.5784
PPTX
Business Acumen Training GuidePresentation.pptx
PPTX
IB Computer Science - Internal Assessment.pptx
PDF
Launch Your Data Science Career in Kochi – 2025
PDF
Oracle OFSAA_ The Complete Guide to Transforming Financial Risk Management an...
PPTX
1_Introduction to advance data techniques.pptx
PPTX
Understanding Prototyping in Design and Development
Data Science Trends & Career Guide---ppt
The THESIS FINAL-DEFENSE-PRESENTATION.pptx
Introduction-to-Cloud-ComputingFinal.pptx
Introduction to Basics of Ethical Hacking and Penetration Testing -Unit No. 1...
Clinical guidelines as a resource for EBP(1).pdf
CEE 2 REPORT G7.pptxbdbshjdgsgjgsjfiuhsd
Chapter 2 METAL FORMINGhhhhhhhjjjjmmmmmmmmm
Major-Components-ofNKJNNKNKNKNKronment.pptx
climate analysis of Dhaka ,Banglades.pptx
Global journeys: estimating international migration
Moving the Public Sector (Government) to a Digital Adoption
Introduction to Firewall Analytics - Interfirewall and Transfirewall.pptx
Data_Analytics_and_PowerBI_Presentation.pptx
Reliability_Chapter_ presentation 1221.5784
Business Acumen Training GuidePresentation.pptx
IB Computer Science - Internal Assessment.pptx
Launch Your Data Science Career in Kochi – 2025
Oracle OFSAA_ The Complete Guide to Transforming Financial Risk Management an...
1_Introduction to advance data techniques.pptx
Understanding Prototyping in Design and Development

MySQL Slow Query log Monitoring using Beats & ELK

  • 1. using Beats & ELK MySQL Slow Query log Monitoring
  • 3. Architecture MySQL Slow Log DB Servers ELK Server Logstash Elasticsearch FileBeat Kibana 3
  • 4. Install & Config FileBeat 4 # rpm -ivh filebeat-1.0.1-x86_64.rpm $vi /etc/filebeat/filebeat.yml filebeat: prospectors: paths: - /db/data01/mysql-slow.log //slow query path output: #elasticsearch: //comment #hosts: ["localhost:9200"] //comment logstash: //uncomment # The Logstash hosts hosts: ["10.xx.xx.xx:5044"] //logstash server ip 1. Install FileBeat – on DB servers 2. Parameter configuration
  • 5. 5 # /etc/init.d/filebeat start Starting filebeat: [ OK ] 3. Start FileBeat – on DB servers Install & Config FileBeat
  • 6. Install & Config Elasticsearch 6 # tar –xzvf elasticsearch-2.1.1.tar.gz 1. Install Elasticsearch – on ELK servers 2. configuration $ vi ./elasticsearch-2.1.1/config/elasticsearch.yml cluster.name : log_cluster # cluster name node.name : slow_log # node name path.data: /DATA/data # index data path path.logs: /DATA/logs # log path network.host : 10.xxx.xxx.xxx # server’s ip
  • 7. 7 3. start elasticsearch $./bin/elasticsearch You can’t run elastisearch as root. Install & Config Elasticsearch
  • 8. Install & Config Logstash 8 1. Install Logstash – on ELK server $ rpm –ivh logstash-2.1.1-1.noarch.rpm 2-1. Configure(input plugin) # vi /etc/logstash/conf.d/10-slow-log.conf input { beats { port => 5044 codec => multiline{ pattern => "^# Time:" negate => true what => previous } } }
  • 9. 9 2-2. Configure(filter plugin) filter { grok { match => [ "message", "^# User@Host: %{USER:query_user}(?:[[^]]+])?s+@s+%{HOSTNAME:query_host}?s+[%{IP:query_ip}?]" ] } grok { match => [ "message", "^# Thread_id: %{NUMBER:thread_id:int}s+Schema: %{USER:schema}s+Last_errno: %{NUMBER:last_errno:int}s+Killed: %{NUMBER:killed:int}"] } grok { match => [ "message", "^# Query_time: %{NUMBER:query_time:float}s+Lock_time: %{NUMBER:lock_time}s+ Rows_sent: %{NUMBER:rows_sent:int} s+Rows_examined: %{NUMBER:rows_examined:int}s+Rows_affected: %{NUMBER:rows_affected:int}s+Rows_read: %{NUMBER:rows_read:int}"] } grok { match => [ "message", "^# Bytes_sent: %{NUMBER:bytes_sent:float}"] } grok { match => [ "message", "^SET timestamp=%{NUMBER:timestamp}" ] } grok { match => [ "message", "^SET timestamp=%{NUMBER};s+%{GREEDYDATA:query}" ] } date { match => [ "timestamp", "UNIX" ] } mutate { remove_field => "timestamp" } } Install & Config Logstash
  • 10. 10 2-3. Configure(output plugin) output { elasticsearch { hosts => "10.xx.xx.xx" } } 3. Beats plugin install # cd /opt/logstash/bin # ./plugin install logstash-input-beats 4. Start logstash # /etc/init.d/logstash start Install & Config Logstash
  • 11. Install & Config Kibana 11 1. Install Kibana – on ELK server $ tar –xvf kibana-4.3.1-linux-x64.tar.gz 2. Configure $ vi ./kibana-4.3.1-linux-x64/config/kibana.yml server.host: "10.xx.xx.xx“ # kibana server ip elasticsearch.url: "http://10.xx.xx.xx:9200" # elasticsearch server ip 3. Start Kibana $ ./bin/kibana
  • 12. Visualize – Slow query graph 12 mouse over Install & Config Kibana
  • 13. 13 New Visualization > Line chart Install & Config Kibana Visualize – Slow query graph
  • 14. Dashboard - sample 14 http://10.xxx.xxx.xxx:5601 Install & Config Kibana