SlideShare a Scribd company logo
MySQL Monitoring
using Prometheus & Grafana
2
dba.kim@gmail.com
https://kr.linkedin.com/in/youngheon-roy-kim-23a11181
About me
MySQL Monitoring Dashboard
3
Alert using slack
Grafana Dashboard
Architecture
4
DB Servers
Monitoring Server
node_exporter
mysql_exporter
prometheus
alert manager
playbook
node_exporter
mysql_exporter
•
•
•
Deploy Server
Install & config prometheus on monitoring server
5
1. Install Prometheus
Download .tar file
https://prometheus.io/download/
$tar –xvf prometheus-0.17.0rc2.linux-amd64.tar.gz –C /opt
$mv prometheus-0.17.0rc2.linux-amd64 prometheus
Install & config prometheus on monitoring server
6
2. Config prometheus.yml file
global:
scrape_interval: 5s
evaluation_interval: 5s
scrape_configs:
- job_name: linux_hostname1
target_groups:
- targets: [‘ip_addr:9100']
labels:
alias: hostname1
- job_name: mysql_hostname1
target_groups:
- targets: [‘ip_addr:9104']
labels:
alias: hostname1
/opt/prometheus/prometheus.yml
continue right side…
scrape_configs :
you can add server information.
It can be added automatically using ansible playbook.
Install & config alertmanager on monitoring server
7
1. Install alertmanager
Download .tar file
https://prometheus.io/download/
$tar –xvf alertmanager-0.1.1.linux-amd64.tar.gz –C /opt
$mv alertmanager-0.1.1.linux-amd64 alertmanager
2. make a slack Webhook url
You can make a slack webhook url for sending a alert message.
https://slack.com/apps/A0F7XDUAZ-incoming-webhooks
Install & config alertmanager on monitoring server
8
3. Config simple.yml
/opt/alertmanager/simple.yml
global:
slack_api_url: {{ webhook url}}
route:
receiver: 'slack-notifications'
group_by: ['alertname', 'cluster', 'service']
group_wait: 30s
group_interval: 1m
repeat_interval: 3m
receivers:
- name: 'slack-notifications'
slack_configs:
- channel: {{ slack channel name}}
continue right side…
9
4. Config rule file(1/4)
/opt/alertmanager/alert.rules
ALERT LinuxLoad1m
IF node_load1 >15
FOR 1m
ANNOTATIONS {summary="Linux Load is at 10"}
ALERT LinuxMemory
IF ((node_memory_MemTotal - (node_memory_MemFree + node_memory_Buffers +
node_memory_Cached))/node_memory_MemTotal) * 100 >85
FOR 1m
ANNOTATIONS {summary="Linux Memory Usage is at 85%"}
continue next page…
Set a alert rule file
Install & config alertmanager on monitoring server
10
4. Config rule file(2/4)
/opt/alertmanager/alert.rules
ALERT LinuxDiskUsage
IF ((node_filesystem_size{fstype!~"rootfs|selinuxfs|autofs|rpc_pipefs|tmpfs"} -
node_filesystem_avail{fstype!~"rootfs|selinuxfs|autofs|rpc_pipefs|tmpfs"})
/node_filesystem_size{ fstype!~"rootfs|selinuxfs|autofs|rpc_pipefs|tmpfs"}) * 100 > 90
FOR 5m
ANNOTATIONS {summary="Linux Disk Usage over 90%"}
ALERT MySQLSlaveLag
IF mysql_slave_lag_seconds > 300
FOR 1m
LABELS { severity = "warning" }
ANNOTATIONS { summary = "Slave lag is too high.", severity="warning" }
Set a alert rule file
Install & config alertmanager on monitoring server
continue next page…
11
4. Config rule file(3/4)
/opt/alertmanager/alert.rules
ALERT MySQLReplicationSQLThreadStatus
IF mysql_slave_status_slave_sql_running==0
FOR 1m
LABELS { severity = "warning" }
ANNOTATIONS { summary = "SQL thread stop", severity="warning"}
ALERT MySQLReplicationIOThreadStatus
IF mysql_slave_status_slave_io_running==0
FOR 1m
LABELS { severity = "warning" }
ANNOTATIONS { summary = "IO thread stop", severity="warning"}
continue next page…
Set a alert rule file
Install & config alertmanager on monitoring server
12
4. Config rule file(4/4)
/opt/alertmanager/alert.rules
ALERT MySQLstatus
IF mysql_up==0
FOR 30s
LABELS { severity = "warning" }
ANNOTATIONS { summary = "Mysql Process Down" }
continue next page…
Set a alert rule file
Install & config alertmanager on monitoring server
13
5. Add rule file information on prometheus.yml
/opt/prometheus/prometheus.yml
You can add following information between global and scrape_configs section.
global:
rule_files:
- /opt/alertmanager/alert.rules
scrape_configs:
Set a alert rule file
Install & config alertmanager on monitoring server
14
6. Start alertmanager and prometheus
Alertmanager start
#./alertmanager –config.file=simple.yml
Prometheus start
#./prometheus –config.file prometheus.yml –alertmanager.url=http://10.xxx.xxx.xxx:9093
start alertmanager and prometheus
Install & config alertmanager on monitoring server
Install & config alertmanager on monitoring server
15
7. Check status of alertmanager and prometheus
Prometheus status
http://10.xxx.xxx.xxx:9090/status
Install & config alertmanager on monitoring server
16
7. Check status of alertmanager and prometheus
Alertmanager status
http://10.xxx.xxx.xxx:9093/#/status
Auto install & config exporters using Ansible
17
1. Install Ansible
On iOS
$brew install ansible
On Linux
$yum install ansible
1818
2. Consist of Directory & Files
- /etc/hosts
- ~/ansible_hosts
- ~/ansible/playbooks/prometheus_exporter.yml
- ~/ansible/playbooks/files/prometheus/node_exporter-0.12.0.linux-amd64.tar.gz
- ~/ansible/playbooks/files/prometheus/mysqld_exporter-0.8.1.linux-amd64.tar.gz
- ~/ansible/playbooks/files/prometheus/start_node_exporter.sh
- ~/ansible/playbooks/files/prometheus/start_mysqld_exporter.sh
- ~/ansible/playbooks/files/prometheus/.my.cnf
- ~/ansible/playbooks/files/prometheus/prometheus.yml.temp
Auto install & config exporters using Ansible
19
/etc/hosts
~/ansible_hosts
#DB server lists
10.xxx.xxx.xxx dbhost01
10.xxx.xxx.xxx dbhost02
10.xxx.xxx.xxx dbhost03
[Group1]
dbhost01
dbhost02
dbhost03
system hosts file
ansible hosts file
You should set following information on profile.
export ANSIBLE_INVENTORY=~/ansible_hosts
Auto install & config exporters using Ansible
20
~/ansible/playbooks/prometheus_exporter.yml
- name: Prometheus Install and Configuration
user : user1
hosts: Group1
sudo: yes
tasks:
- name: make directory
file: path=/opt/prometheus_exporters/ state=directory
- name: Copy tar.gz files
copy: src=files/prometheus/{{ item }} dest=/opt/prometheus_exporters/{{ item }}
with_items:
- node_exporter-0.12.0.linux-amd64.tar.gz
- mysqld_exporter-0.8.1.linux-amd64.tar.gz
continue next page…
ansible playbook file
for install and config
prometheus exporter
Auto install & config exporters using Ansible
21
~/ansible/playbooks/prometheus_exporter.yml
- name: Uncompress gz files
command: tar -xzvf /opt/prometheus_exporters/{{ item }} -C /opt/prometheus_exporters
with_items:
- node_exporter-0.12.0.linux-amd64.tar.gz
- mysqld_exporter-0.8.1.linux-amd64.tar.gz
- name: Rename node_exporter Directory name
command: mv /opt/prometheus_exporters/node_exporter-0.12.0.linux-amd64 /opt/prometheus_exporters/node_exporter
- name: Rename mysqld_exporter Directory name
command: mv /opt/prometheus_exporters/mysqld_exporter-0.8.1.linux-amd64 /opt/prometheus_exporters/mysqld_exporter
- name: change directory owner
file: path=/opt/prometheus_exporters/{{ item }} state=directory owner=root group=root mode=640
with_items:
- node_exporter
- mysqld_exporter
continue next page…
Auto install & config exporters using Ansible
22
~/ansible/playbooks/prometheus_exporter.yml
- name: Copy start_mysqld_exporter.sh
copy: src=files/prometheus/{{ item }} dest=/opt/prometheus_exporters/mysqld_exporter
with_items:
- start_mysqld_exporter.sh
- name: Copy start_node_exporter.sh
copy: src=files/prometheus/{{ item }} dest=/opt/prometheus_exporters/node_exporter
with_items:
- start_node_exporter.sh
- name: .my.cnf coyp
template: src=files/prometheus/.my.cnf dest=/opt/prometheus_exporters/mysqld_exporter
owner=root group=root mode=640
Auto install & config exporters using Ansible
continue next page…
23
~/ansible/playbooks/prometheus_exporter.yml
- name: .my.cnf coyp
template: src=files/prometheus/.my.cnf dest=/opt/prometheus_exporters/mysqld_exporter
owner=root group=root mode=640
- name: Execute node exporter
command: /bin/sh /opt/prometheus_exporters/node_exporter/start_node_exporter.sh
- name: Execute mysql exporter
command: /bin/sh /opt/prometheus_exporters/mysqld_exporter/start_mysqld_exporter.sh
- name: move new host info on prometheus server
template: src=files/prometheus/prometheus.yml.temp dest=/opt/prometheus/prometheus.yml.{{ansible_hostname}}
owner=root group=root mode=640
delegate_to: monitoring_server_hostname
- name: add new host info on prometheus.yml
shell: cat /opt/prometheus/prometheus.yml.{{ansible_hostname}} >> /opt/prometheus/prometheus.yml
delegate_to: monitoring_server_hostname
Auto install & config exporters using Ansible
24
~/ansible/playbooks/files/prometheus/
node_exporter-0.12.0.linux-amd64.tar.gz
mysqld_exporter-0.8.1.linux-amd64.tar.gz
start_node_exporter.sh
start_mysqld_exporter.sh
: node_exporter install file
: mysqld_exporter install file
: node_exporter start script
nohup /opt/prometheus_exporters/node_exporter/node_exporter &
nohup /opt/prometheus_exporters/mysqld_exporter/mysqld_exporter
-config.my-cnf="/opt/prometheus_exporters/mysqld_exporter/.my.cnf" &
Auto install & config exporters using Ansible
: mysqld_exporter start script
25
~/ansible/playbooks/files/prometheus/
.my.cnf
[client]
host= {{ansible_default_ipv4.address}}
user=mon_user # db user for monitoring
password=mon_user_passwd # db user password
Auto install & config exporters using Ansible
: mysqld_exporter config file
mysql> GRANT REPLICATION CLIENT, PROCESS ON *.* TO ‘mon_user'@'127.0.0.1' identified by ‘mon_user_passwd';
mysql> GRANT SELECT ON performance_schema.* TO ‘mon_user'@'127.0.0.1';
You have to add db user for monitoring on db server
26
~/ansible/playbooks/files/prometheus/
prometheus.yml.temp
- job_name: linux_{{ansible_hostname}}
target_groups:
- targets: ['{{ansible_default_ipv4.address}}:9100']
labels:
alias: {{ansible_hostname}}
- job_name: mysql_{{ansible_hostname}}
target_groups:
- targets: ['{{ansible_default_ipv4.address}}:9104']
labels:
alias: {{ansible_hostname}}
Auto install & config exporters using Ansible
: prometheus config information
Install & config grafana on monitoring server
27
1. Install Grafana
Download rpm file
http://grafana.org/download/
#rpm –ivh grafana-3.1.1-1470047149.x86_64.rpm
#/etc/init.d/grafana start
2. Grafana connect on web browser
http://10.xxx.xxx.xxx:3000/
28
Make grafana dashboard
CPU Usage
Disk
Bandwidth
Disk space
MySQL
Active
Threads
Load
Average
MySQL QPS
Network
Traffic
Memory
Make grafana dashboard
29
1. Register Datasource
Make grafana dashboard
30
2. Create new dashboard and templating
31
Make grafana dashboard
3. Create a templating
32
Make grafana dashboard
4. Add Graph-Load average(1)
33
Make grafana dashboard
4. Add Graph-Load average(2)
34
Make grafana dashboard
4. Add Graph-Load average(3)
35
Make grafana dashboard
4. Add Graph-Load average(4)
36
Make grafana dashboard
4. Add Graph-Load average(5)
37
Make grafana dashboard
4. Add Graph-Load average(6)
38
Make grafana dashboard
4. Add Graph-Load average(7)
39
Make grafana dashboard
5. Add Graph-CPU Usage
6. Add Graph-Disk Bandwidth
40
Make grafana dashboard
7. Add Graph-Disk space
Query Detail
((node_filesystem_size{fstype!~"rootfs|selinuxfs|autofs|rpc_pipefs|tmpfs",alias="$host"} -
node_filesystem_avail{fstype!~"rootfs|selinuxfs|autofs|rpc_pipefs|tmpfs",alias="$host"})
/node_filesystem_size{ fstype!~"rootfs|selinuxfs|autofs|rpc_pipefs|tmpfs",alias="$host"}) * 100
41
Make grafana dashboard
8. Add Graph-MySQL Active Threads
9. Add Graph-MySQL QPS
42
Make grafana dashboard
10. Add Graph-Network Traffic
43
Make grafana dashboard
11. Add Graph-Memory
44
Make grafana dashboard
You can get more various kinds of dashboard.
https://github.com/percona/grafana-dashboards
Thank You

More Related Content

What's hot

Introduction to Prometheus
Introduction to PrometheusIntroduction to Prometheus
Introduction to Prometheus
Julien Pivotto
 
Comprehensive Terraform Training
Comprehensive Terraform TrainingComprehensive Terraform Training
Comprehensive Terraform Training
Yevgeniy Brikman
 
Prometheus
PrometheusPrometheus
Prometheus
wyukawa
 
Helm - Application deployment management for Kubernetes
Helm - Application deployment management for KubernetesHelm - Application deployment management for Kubernetes
Helm - Application deployment management for Kubernetes
Alexei Ledenev
 
Timeseries - data visualization in Grafana
Timeseries - data visualization in GrafanaTimeseries - data visualization in Grafana
Timeseries - data visualization in Grafana
OCoderFest
 
Introduction to Kafka Streams
Introduction to Kafka StreamsIntroduction to Kafka Streams
Introduction to Kafka Streams
Guozhang Wang
 
Prometheus - basics
Prometheus - basicsPrometheus - basics
Prometheus - basics
Juraj Hantak
 
Infrastructure & System Monitoring using Prometheus
Infrastructure & System Monitoring using PrometheusInfrastructure & System Monitoring using Prometheus
Infrastructure & System Monitoring using Prometheus
Marco Pas
 
Monitoring Kubernetes with Prometheus
Monitoring Kubernetes with PrometheusMonitoring Kubernetes with Prometheus
Monitoring Kubernetes with Prometheus
Grafana Labs
 
Server monitoring using grafana and prometheus
Server monitoring using grafana and prometheusServer monitoring using grafana and prometheus
Server monitoring using grafana and prometheus
Celine George
 
Terraform
TerraformTerraform
Terraform
Diego Pacheco
 
Kubernetes Architecture | Understanding Kubernetes Components | Kubernetes Tu...
Kubernetes Architecture | Understanding Kubernetes Components | Kubernetes Tu...Kubernetes Architecture | Understanding Kubernetes Components | Kubernetes Tu...
Kubernetes Architecture | Understanding Kubernetes Components | Kubernetes Tu...
Edureka!
 
Introduction to GitHub Actions
Introduction to GitHub ActionsIntroduction to GitHub Actions
Introduction to GitHub Actions
Knoldus Inc.
 
Building infrastructure as code using Terraform - DevOps Krakow
Building infrastructure as code using Terraform - DevOps KrakowBuilding infrastructure as code using Terraform - DevOps Krakow
Building infrastructure as code using Terraform - DevOps Krakow
Anton Babenko
 
Intro to open source observability with grafana, prometheus, loki, and tempo(...
Intro to open source observability with grafana, prometheus, loki, and tempo(...Intro to open source observability with grafana, prometheus, loki, and tempo(...
Intro to open source observability with grafana, prometheus, loki, and tempo(...
LibbySchulze
 
Intro to Terraform
Intro to TerraformIntro to Terraform
Intro to Terraform
Josh Michielsen
 
Designing a complete ci cd pipeline using argo events, workflow and cd products
Designing a complete ci cd pipeline using argo events, workflow and cd productsDesigning a complete ci cd pipeline using argo events, workflow and cd products
Designing a complete ci cd pipeline using argo events, workflow and cd products
Julian Mazzitelli
 
Introduction to Apache Kafka
Introduction to Apache KafkaIntroduction to Apache Kafka
Introduction to Apache Kafka
Jeff Holoman
 
Terraform introduction
Terraform introductionTerraform introduction
Terraform introduction
Jason Vance
 
Tuning Apache Kafka Connectors for Flink.pptx
Tuning Apache Kafka Connectors for Flink.pptxTuning Apache Kafka Connectors for Flink.pptx
Tuning Apache Kafka Connectors for Flink.pptx
Flink Forward
 

What's hot (20)

Introduction to Prometheus
Introduction to PrometheusIntroduction to Prometheus
Introduction to Prometheus
 
Comprehensive Terraform Training
Comprehensive Terraform TrainingComprehensive Terraform Training
Comprehensive Terraform Training
 
Prometheus
PrometheusPrometheus
Prometheus
 
Helm - Application deployment management for Kubernetes
Helm - Application deployment management for KubernetesHelm - Application deployment management for Kubernetes
Helm - Application deployment management for Kubernetes
 
Timeseries - data visualization in Grafana
Timeseries - data visualization in GrafanaTimeseries - data visualization in Grafana
Timeseries - data visualization in Grafana
 
Introduction to Kafka Streams
Introduction to Kafka StreamsIntroduction to Kafka Streams
Introduction to Kafka Streams
 
Prometheus - basics
Prometheus - basicsPrometheus - basics
Prometheus - basics
 
Infrastructure & System Monitoring using Prometheus
Infrastructure & System Monitoring using PrometheusInfrastructure & System Monitoring using Prometheus
Infrastructure & System Monitoring using Prometheus
 
Monitoring Kubernetes with Prometheus
Monitoring Kubernetes with PrometheusMonitoring Kubernetes with Prometheus
Monitoring Kubernetes with Prometheus
 
Server monitoring using grafana and prometheus
Server monitoring using grafana and prometheusServer monitoring using grafana and prometheus
Server monitoring using grafana and prometheus
 
Terraform
TerraformTerraform
Terraform
 
Kubernetes Architecture | Understanding Kubernetes Components | Kubernetes Tu...
Kubernetes Architecture | Understanding Kubernetes Components | Kubernetes Tu...Kubernetes Architecture | Understanding Kubernetes Components | Kubernetes Tu...
Kubernetes Architecture | Understanding Kubernetes Components | Kubernetes Tu...
 
Introduction to GitHub Actions
Introduction to GitHub ActionsIntroduction to GitHub Actions
Introduction to GitHub Actions
 
Building infrastructure as code using Terraform - DevOps Krakow
Building infrastructure as code using Terraform - DevOps KrakowBuilding infrastructure as code using Terraform - DevOps Krakow
Building infrastructure as code using Terraform - DevOps Krakow
 
Intro to open source observability with grafana, prometheus, loki, and tempo(...
Intro to open source observability with grafana, prometheus, loki, and tempo(...Intro to open source observability with grafana, prometheus, loki, and tempo(...
Intro to open source observability with grafana, prometheus, loki, and tempo(...
 
Intro to Terraform
Intro to TerraformIntro to Terraform
Intro to Terraform
 
Designing a complete ci cd pipeline using argo events, workflow and cd products
Designing a complete ci cd pipeline using argo events, workflow and cd productsDesigning a complete ci cd pipeline using argo events, workflow and cd products
Designing a complete ci cd pipeline using argo events, workflow and cd products
 
Introduction to Apache Kafka
Introduction to Apache KafkaIntroduction to Apache Kafka
Introduction to Apache Kafka
 
Terraform introduction
Terraform introductionTerraform introduction
Terraform introduction
 
Tuning Apache Kafka Connectors for Flink.pptx
Tuning Apache Kafka Connectors for Flink.pptxTuning Apache Kafka Connectors for Flink.pptx
Tuning Apache Kafka Connectors for Flink.pptx
 

Similar to MySQL Monitoring using Prometheus & Grafana

Caching and tuning fun for high scalability
Caching and tuning fun for high scalabilityCaching and tuning fun for high scalability
Caching and tuning fun for high scalability
Wim Godden
 
How to install and configure LEMP stack
How to install and configure LEMP stackHow to install and configure LEMP stack
How to install and configure LEMP stack
RootGate
 
Nginx 0.8.x 安装手册
Nginx 0.8.x 安装手册Nginx 0.8.x 安装手册
Nginx 0.8.x 安装手册Yiwei Ma
 
Installing oracle grid infrastructure and database 12c r1
Installing oracle grid infrastructure and database 12c r1Installing oracle grid infrastructure and database 12c r1
Installing oracle grid infrastructure and database 12c r1
Voeurng Sovann
 
Montreal On Rails 5 : Rails deployment using : Nginx, Mongrel, Mongrel_cluste...
Montreal On Rails 5 : Rails deployment using : Nginx, Mongrel, Mongrel_cluste...Montreal On Rails 5 : Rails deployment using : Nginx, Mongrel, Mongrel_cluste...
Montreal On Rails 5 : Rails deployment using : Nginx, Mongrel, Mongrel_cluste...
addame
 
How To Install OpenFire in CentOS 7
How To Install OpenFire in CentOS 7How To Install OpenFire in CentOS 7
How To Install OpenFire in CentOS 7
VCP Muthukrishna
 
Drupal, Memcache and Solr on Windows
Drupal, Memcache and Solr on WindowsDrupal, Memcache and Solr on Windows
Drupal, Memcache and Solr on Windows
Alessandro Pilotti
 
Mysql
Mysql Mysql
Mysql
Mindtree
 
RAC-Installing your First Cluster and Database
RAC-Installing your First Cluster and DatabaseRAC-Installing your First Cluster and Database
RAC-Installing your First Cluster and Database
Nikhil Kumar
 
Tested install-isp config3-ubuntu-16-04
Tested install-isp config3-ubuntu-16-04Tested install-isp config3-ubuntu-16-04
Tested install-isp config3-ubuntu-16-04
SANTIAGO HERNÁNDEZ
 
How to create a secured cloudera cluster
How to create a secured cloudera clusterHow to create a secured cloudera cluster
How to create a secured cloudera cluster
Tiago Simões
 
BeeGFS Training.pdf
BeeGFS Training.pdfBeeGFS Training.pdf
BeeGFS Training.pdf
ssusercbaa33
 
OSMC 2019 | Use Cloud services & features in your redundant Icinga2 Environme...
OSMC 2019 | Use Cloud services & features in your redundant Icinga2 Environme...OSMC 2019 | Use Cloud services & features in your redundant Icinga2 Environme...
OSMC 2019 | Use Cloud services & features in your redundant Icinga2 Environme...
NETWAYS
 
X64服务器 lnmp服务器部署标准 new
X64服务器 lnmp服务器部署标准 newX64服务器 lnmp服务器部署标准 new
X64服务器 lnmp服务器部署标准 newYiwei Ma
 
My SQL 101
My SQL 101My SQL 101
My SQL 101
Dave Stokes
 
Oracle11g On Fedora14
Oracle11g On Fedora14Oracle11g On Fedora14
Oracle11g On Fedora14
kmsa
 
Oracle11g on fedora14
Oracle11g on fedora14Oracle11g on fedora14
Oracle11g on fedora14
Khalid Matar Albuflasah
 
Virtualization and automation of library software/machines + Puppet
Virtualization and automation of library software/machines + PuppetVirtualization and automation of library software/machines + Puppet
Virtualization and automation of library software/machines + PuppetOmar Reygaert
 

Similar to MySQL Monitoring using Prometheus & Grafana (20)

OTRS
OTRSOTRS
OTRS
 
Caching and tuning fun for high scalability
Caching and tuning fun for high scalabilityCaching and tuning fun for high scalability
Caching and tuning fun for high scalability
 
How to install and configure LEMP stack
How to install and configure LEMP stackHow to install and configure LEMP stack
How to install and configure LEMP stack
 
Nginx 0.8.x 安装手册
Nginx 0.8.x 安装手册Nginx 0.8.x 安装手册
Nginx 0.8.x 安装手册
 
Installing oracle grid infrastructure and database 12c r1
Installing oracle grid infrastructure and database 12c r1Installing oracle grid infrastructure and database 12c r1
Installing oracle grid infrastructure and database 12c r1
 
Freeradius edir
Freeradius edirFreeradius edir
Freeradius edir
 
Montreal On Rails 5 : Rails deployment using : Nginx, Mongrel, Mongrel_cluste...
Montreal On Rails 5 : Rails deployment using : Nginx, Mongrel, Mongrel_cluste...Montreal On Rails 5 : Rails deployment using : Nginx, Mongrel, Mongrel_cluste...
Montreal On Rails 5 : Rails deployment using : Nginx, Mongrel, Mongrel_cluste...
 
How To Install OpenFire in CentOS 7
How To Install OpenFire in CentOS 7How To Install OpenFire in CentOS 7
How To Install OpenFire in CentOS 7
 
Drupal, Memcache and Solr on Windows
Drupal, Memcache and Solr on WindowsDrupal, Memcache and Solr on Windows
Drupal, Memcache and Solr on Windows
 
Mysql
Mysql Mysql
Mysql
 
RAC-Installing your First Cluster and Database
RAC-Installing your First Cluster and DatabaseRAC-Installing your First Cluster and Database
RAC-Installing your First Cluster and Database
 
Tested install-isp config3-ubuntu-16-04
Tested install-isp config3-ubuntu-16-04Tested install-isp config3-ubuntu-16-04
Tested install-isp config3-ubuntu-16-04
 
How to create a secured cloudera cluster
How to create a secured cloudera clusterHow to create a secured cloudera cluster
How to create a secured cloudera cluster
 
BeeGFS Training.pdf
BeeGFS Training.pdfBeeGFS Training.pdf
BeeGFS Training.pdf
 
OSMC 2019 | Use Cloud services & features in your redundant Icinga2 Environme...
OSMC 2019 | Use Cloud services & features in your redundant Icinga2 Environme...OSMC 2019 | Use Cloud services & features in your redundant Icinga2 Environme...
OSMC 2019 | Use Cloud services & features in your redundant Icinga2 Environme...
 
X64服务器 lnmp服务器部署标准 new
X64服务器 lnmp服务器部署标准 newX64服务器 lnmp服务器部署标准 new
X64服务器 lnmp服务器部署标准 new
 
My SQL 101
My SQL 101My SQL 101
My SQL 101
 
Oracle11g On Fedora14
Oracle11g On Fedora14Oracle11g On Fedora14
Oracle11g On Fedora14
 
Oracle11g on fedora14
Oracle11g on fedora14Oracle11g on fedora14
Oracle11g on fedora14
 
Virtualization and automation of library software/machines + Puppet
Virtualization and automation of library software/machines + PuppetVirtualization and automation of library software/machines + Puppet
Virtualization and automation of library software/machines + Puppet
 

More from YoungHeon (Roy) Kim

Query logging with proxysql
Query logging with proxysqlQuery logging with proxysql
Query logging with proxysql
YoungHeon (Roy) Kim
 
My sql failover test using orchestrator
My sql failover test  using orchestratorMy sql failover test  using orchestrator
My sql failover test using orchestrator
YoungHeon (Roy) Kim
 
Airflow를 이용한 데이터 Workflow 관리
Airflow를 이용한  데이터 Workflow 관리Airflow를 이용한  데이터 Workflow 관리
Airflow를 이용한 데이터 Workflow 관리
YoungHeon (Roy) Kim
 
ProxySQL & PXC(Query routing and Failover Test)
ProxySQL & PXC(Query routing and Failover Test)ProxySQL & PXC(Query routing and Failover Test)
ProxySQL & PXC(Query routing and Failover Test)
YoungHeon (Roy) Kim
 
MySQL Slow Query log Monitoring using Beats & ELK
MySQL Slow Query log Monitoring using Beats & ELKMySQL Slow Query log Monitoring using Beats & ELK
MySQL Slow Query log Monitoring using Beats & ELK
YoungHeon (Roy) Kim
 
MySQL Audit using Percona audit plugin and ELK
MySQL Audit using Percona audit plugin and ELKMySQL Audit using Percona audit plugin and ELK
MySQL Audit using Percona audit plugin and ELK
YoungHeon (Roy) Kim
 

More from YoungHeon (Roy) Kim (6)

Query logging with proxysql
Query logging with proxysqlQuery logging with proxysql
Query logging with proxysql
 
My sql failover test using orchestrator
My sql failover test  using orchestratorMy sql failover test  using orchestrator
My sql failover test using orchestrator
 
Airflow를 이용한 데이터 Workflow 관리
Airflow를 이용한  데이터 Workflow 관리Airflow를 이용한  데이터 Workflow 관리
Airflow를 이용한 데이터 Workflow 관리
 
ProxySQL & PXC(Query routing and Failover Test)
ProxySQL & PXC(Query routing and Failover Test)ProxySQL & PXC(Query routing and Failover Test)
ProxySQL & PXC(Query routing and Failover Test)
 
MySQL Slow Query log Monitoring using Beats & ELK
MySQL Slow Query log Monitoring using Beats & ELKMySQL Slow Query log Monitoring using Beats & ELK
MySQL Slow Query log Monitoring using Beats & ELK
 
MySQL Audit using Percona audit plugin and ELK
MySQL Audit using Percona audit plugin and ELKMySQL Audit using Percona audit plugin and ELK
MySQL Audit using Percona audit plugin and ELK
 

Recently uploaded

LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
Peter Spielvogel
 
Assure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyesAssure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Aggregage
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
nkrafacyberclub
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 

Recently uploaded (20)

LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
 
Assure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyesAssure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyes
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 

MySQL Monitoring using Prometheus & Grafana

  • 3. MySQL Monitoring Dashboard 3 Alert using slack Grafana Dashboard
  • 4. Architecture 4 DB Servers Monitoring Server node_exporter mysql_exporter prometheus alert manager playbook node_exporter mysql_exporter • • • Deploy Server
  • 5. Install & config prometheus on monitoring server 5 1. Install Prometheus Download .tar file https://prometheus.io/download/ $tar –xvf prometheus-0.17.0rc2.linux-amd64.tar.gz –C /opt $mv prometheus-0.17.0rc2.linux-amd64 prometheus
  • 6. Install & config prometheus on monitoring server 6 2. Config prometheus.yml file global: scrape_interval: 5s evaluation_interval: 5s scrape_configs: - job_name: linux_hostname1 target_groups: - targets: [‘ip_addr:9100'] labels: alias: hostname1 - job_name: mysql_hostname1 target_groups: - targets: [‘ip_addr:9104'] labels: alias: hostname1 /opt/prometheus/prometheus.yml continue right side… scrape_configs : you can add server information. It can be added automatically using ansible playbook.
  • 7. Install & config alertmanager on monitoring server 7 1. Install alertmanager Download .tar file https://prometheus.io/download/ $tar –xvf alertmanager-0.1.1.linux-amd64.tar.gz –C /opt $mv alertmanager-0.1.1.linux-amd64 alertmanager 2. make a slack Webhook url You can make a slack webhook url for sending a alert message. https://slack.com/apps/A0F7XDUAZ-incoming-webhooks
  • 8. Install & config alertmanager on monitoring server 8 3. Config simple.yml /opt/alertmanager/simple.yml global: slack_api_url: {{ webhook url}} route: receiver: 'slack-notifications' group_by: ['alertname', 'cluster', 'service'] group_wait: 30s group_interval: 1m repeat_interval: 3m receivers: - name: 'slack-notifications' slack_configs: - channel: {{ slack channel name}} continue right side…
  • 9. 9 4. Config rule file(1/4) /opt/alertmanager/alert.rules ALERT LinuxLoad1m IF node_load1 >15 FOR 1m ANNOTATIONS {summary="Linux Load is at 10"} ALERT LinuxMemory IF ((node_memory_MemTotal - (node_memory_MemFree + node_memory_Buffers + node_memory_Cached))/node_memory_MemTotal) * 100 >85 FOR 1m ANNOTATIONS {summary="Linux Memory Usage is at 85%"} continue next page… Set a alert rule file Install & config alertmanager on monitoring server
  • 10. 10 4. Config rule file(2/4) /opt/alertmanager/alert.rules ALERT LinuxDiskUsage IF ((node_filesystem_size{fstype!~"rootfs|selinuxfs|autofs|rpc_pipefs|tmpfs"} - node_filesystem_avail{fstype!~"rootfs|selinuxfs|autofs|rpc_pipefs|tmpfs"}) /node_filesystem_size{ fstype!~"rootfs|selinuxfs|autofs|rpc_pipefs|tmpfs"}) * 100 > 90 FOR 5m ANNOTATIONS {summary="Linux Disk Usage over 90%"} ALERT MySQLSlaveLag IF mysql_slave_lag_seconds > 300 FOR 1m LABELS { severity = "warning" } ANNOTATIONS { summary = "Slave lag is too high.", severity="warning" } Set a alert rule file Install & config alertmanager on monitoring server continue next page…
  • 11. 11 4. Config rule file(3/4) /opt/alertmanager/alert.rules ALERT MySQLReplicationSQLThreadStatus IF mysql_slave_status_slave_sql_running==0 FOR 1m LABELS { severity = "warning" } ANNOTATIONS { summary = "SQL thread stop", severity="warning"} ALERT MySQLReplicationIOThreadStatus IF mysql_slave_status_slave_io_running==0 FOR 1m LABELS { severity = "warning" } ANNOTATIONS { summary = "IO thread stop", severity="warning"} continue next page… Set a alert rule file Install & config alertmanager on monitoring server
  • 12. 12 4. Config rule file(4/4) /opt/alertmanager/alert.rules ALERT MySQLstatus IF mysql_up==0 FOR 30s LABELS { severity = "warning" } ANNOTATIONS { summary = "Mysql Process Down" } continue next page… Set a alert rule file Install & config alertmanager on monitoring server
  • 13. 13 5. Add rule file information on prometheus.yml /opt/prometheus/prometheus.yml You can add following information between global and scrape_configs section. global: rule_files: - /opt/alertmanager/alert.rules scrape_configs: Set a alert rule file Install & config alertmanager on monitoring server
  • 14. 14 6. Start alertmanager and prometheus Alertmanager start #./alertmanager –config.file=simple.yml Prometheus start #./prometheus –config.file prometheus.yml –alertmanager.url=http://10.xxx.xxx.xxx:9093 start alertmanager and prometheus Install & config alertmanager on monitoring server
  • 15. Install & config alertmanager on monitoring server 15 7. Check status of alertmanager and prometheus Prometheus status http://10.xxx.xxx.xxx:9090/status
  • 16. Install & config alertmanager on monitoring server 16 7. Check status of alertmanager and prometheus Alertmanager status http://10.xxx.xxx.xxx:9093/#/status
  • 17. Auto install & config exporters using Ansible 17 1. Install Ansible On iOS $brew install ansible On Linux $yum install ansible
  • 18. 1818 2. Consist of Directory & Files - /etc/hosts - ~/ansible_hosts - ~/ansible/playbooks/prometheus_exporter.yml - ~/ansible/playbooks/files/prometheus/node_exporter-0.12.0.linux-amd64.tar.gz - ~/ansible/playbooks/files/prometheus/mysqld_exporter-0.8.1.linux-amd64.tar.gz - ~/ansible/playbooks/files/prometheus/start_node_exporter.sh - ~/ansible/playbooks/files/prometheus/start_mysqld_exporter.sh - ~/ansible/playbooks/files/prometheus/.my.cnf - ~/ansible/playbooks/files/prometheus/prometheus.yml.temp Auto install & config exporters using Ansible
  • 19. 19 /etc/hosts ~/ansible_hosts #DB server lists 10.xxx.xxx.xxx dbhost01 10.xxx.xxx.xxx dbhost02 10.xxx.xxx.xxx dbhost03 [Group1] dbhost01 dbhost02 dbhost03 system hosts file ansible hosts file You should set following information on profile. export ANSIBLE_INVENTORY=~/ansible_hosts Auto install & config exporters using Ansible
  • 20. 20 ~/ansible/playbooks/prometheus_exporter.yml - name: Prometheus Install and Configuration user : user1 hosts: Group1 sudo: yes tasks: - name: make directory file: path=/opt/prometheus_exporters/ state=directory - name: Copy tar.gz files copy: src=files/prometheus/{{ item }} dest=/opt/prometheus_exporters/{{ item }} with_items: - node_exporter-0.12.0.linux-amd64.tar.gz - mysqld_exporter-0.8.1.linux-amd64.tar.gz continue next page… ansible playbook file for install and config prometheus exporter Auto install & config exporters using Ansible
  • 21. 21 ~/ansible/playbooks/prometheus_exporter.yml - name: Uncompress gz files command: tar -xzvf /opt/prometheus_exporters/{{ item }} -C /opt/prometheus_exporters with_items: - node_exporter-0.12.0.linux-amd64.tar.gz - mysqld_exporter-0.8.1.linux-amd64.tar.gz - name: Rename node_exporter Directory name command: mv /opt/prometheus_exporters/node_exporter-0.12.0.linux-amd64 /opt/prometheus_exporters/node_exporter - name: Rename mysqld_exporter Directory name command: mv /opt/prometheus_exporters/mysqld_exporter-0.8.1.linux-amd64 /opt/prometheus_exporters/mysqld_exporter - name: change directory owner file: path=/opt/prometheus_exporters/{{ item }} state=directory owner=root group=root mode=640 with_items: - node_exporter - mysqld_exporter continue next page… Auto install & config exporters using Ansible
  • 22. 22 ~/ansible/playbooks/prometheus_exporter.yml - name: Copy start_mysqld_exporter.sh copy: src=files/prometheus/{{ item }} dest=/opt/prometheus_exporters/mysqld_exporter with_items: - start_mysqld_exporter.sh - name: Copy start_node_exporter.sh copy: src=files/prometheus/{{ item }} dest=/opt/prometheus_exporters/node_exporter with_items: - start_node_exporter.sh - name: .my.cnf coyp template: src=files/prometheus/.my.cnf dest=/opt/prometheus_exporters/mysqld_exporter owner=root group=root mode=640 Auto install & config exporters using Ansible continue next page…
  • 23. 23 ~/ansible/playbooks/prometheus_exporter.yml - name: .my.cnf coyp template: src=files/prometheus/.my.cnf dest=/opt/prometheus_exporters/mysqld_exporter owner=root group=root mode=640 - name: Execute node exporter command: /bin/sh /opt/prometheus_exporters/node_exporter/start_node_exporter.sh - name: Execute mysql exporter command: /bin/sh /opt/prometheus_exporters/mysqld_exporter/start_mysqld_exporter.sh - name: move new host info on prometheus server template: src=files/prometheus/prometheus.yml.temp dest=/opt/prometheus/prometheus.yml.{{ansible_hostname}} owner=root group=root mode=640 delegate_to: monitoring_server_hostname - name: add new host info on prometheus.yml shell: cat /opt/prometheus/prometheus.yml.{{ansible_hostname}} >> /opt/prometheus/prometheus.yml delegate_to: monitoring_server_hostname Auto install & config exporters using Ansible
  • 24. 24 ~/ansible/playbooks/files/prometheus/ node_exporter-0.12.0.linux-amd64.tar.gz mysqld_exporter-0.8.1.linux-amd64.tar.gz start_node_exporter.sh start_mysqld_exporter.sh : node_exporter install file : mysqld_exporter install file : node_exporter start script nohup /opt/prometheus_exporters/node_exporter/node_exporter & nohup /opt/prometheus_exporters/mysqld_exporter/mysqld_exporter -config.my-cnf="/opt/prometheus_exporters/mysqld_exporter/.my.cnf" & Auto install & config exporters using Ansible : mysqld_exporter start script
  • 25. 25 ~/ansible/playbooks/files/prometheus/ .my.cnf [client] host= {{ansible_default_ipv4.address}} user=mon_user # db user for monitoring password=mon_user_passwd # db user password Auto install & config exporters using Ansible : mysqld_exporter config file mysql> GRANT REPLICATION CLIENT, PROCESS ON *.* TO ‘mon_user'@'127.0.0.1' identified by ‘mon_user_passwd'; mysql> GRANT SELECT ON performance_schema.* TO ‘mon_user'@'127.0.0.1'; You have to add db user for monitoring on db server
  • 26. 26 ~/ansible/playbooks/files/prometheus/ prometheus.yml.temp - job_name: linux_{{ansible_hostname}} target_groups: - targets: ['{{ansible_default_ipv4.address}}:9100'] labels: alias: {{ansible_hostname}} - job_name: mysql_{{ansible_hostname}} target_groups: - targets: ['{{ansible_default_ipv4.address}}:9104'] labels: alias: {{ansible_hostname}} Auto install & config exporters using Ansible : prometheus config information
  • 27. Install & config grafana on monitoring server 27 1. Install Grafana Download rpm file http://grafana.org/download/ #rpm –ivh grafana-3.1.1-1470047149.x86_64.rpm #/etc/init.d/grafana start 2. Grafana connect on web browser http://10.xxx.xxx.xxx:3000/
  • 28. 28 Make grafana dashboard CPU Usage Disk Bandwidth Disk space MySQL Active Threads Load Average MySQL QPS Network Traffic Memory
  • 29. Make grafana dashboard 29 1. Register Datasource
  • 30. Make grafana dashboard 30 2. Create new dashboard and templating
  • 31. 31 Make grafana dashboard 3. Create a templating
  • 32. 32 Make grafana dashboard 4. Add Graph-Load average(1)
  • 33. 33 Make grafana dashboard 4. Add Graph-Load average(2)
  • 34. 34 Make grafana dashboard 4. Add Graph-Load average(3)
  • 35. 35 Make grafana dashboard 4. Add Graph-Load average(4)
  • 36. 36 Make grafana dashboard 4. Add Graph-Load average(5)
  • 37. 37 Make grafana dashboard 4. Add Graph-Load average(6)
  • 38. 38 Make grafana dashboard 4. Add Graph-Load average(7)
  • 39. 39 Make grafana dashboard 5. Add Graph-CPU Usage 6. Add Graph-Disk Bandwidth
  • 40. 40 Make grafana dashboard 7. Add Graph-Disk space Query Detail ((node_filesystem_size{fstype!~"rootfs|selinuxfs|autofs|rpc_pipefs|tmpfs",alias="$host"} - node_filesystem_avail{fstype!~"rootfs|selinuxfs|autofs|rpc_pipefs|tmpfs",alias="$host"}) /node_filesystem_size{ fstype!~"rootfs|selinuxfs|autofs|rpc_pipefs|tmpfs",alias="$host"}) * 100
  • 41. 41 Make grafana dashboard 8. Add Graph-MySQL Active Threads 9. Add Graph-MySQL QPS
  • 42. 42 Make grafana dashboard 10. Add Graph-Network Traffic
  • 43. 43 Make grafana dashboard 11. Add Graph-Memory
  • 44. 44 Make grafana dashboard You can get more various kinds of dashboard. https://github.com/percona/grafana-dashboards