Monitor MySQL with Prometheus and Grafana

Source: Internet
Author: User
Tags grafana

First, Prometheus is an open source service monitoring system and time series database. :

The official GitHub address is: Https://github.com/prometheus/prometheus

Official address: https://prometheus.io/

The official topology map is as follows

650) this.width=650; "Src=" https://s1.51cto.com/wyfs02/M01/98/A6/wKiom1k_T1_iPyeZAABYjYY42Hw608.png-wh_500x0-wm_ 3-wmp_4-s_3448237193.png "title=" 082749_47dp_5189.png "alt=" Wkiom1k_t1_ipyezaabyjyy42hw608.png-wh_50 "/>


Characteristics:

    • High-dimensional data model

    • Custom Query Language

    • Visual data display

    • Efficient Storage Policy

    • Easy operation

      li>
    • Provides a variety of client development libraries

    • Warnings and alarms

    • Data export

Second, installation Prometheus (server environment for Centos7.2, this experiment server is monitored with MySQL on the same servers)

Prerequisites Please close SELinux and Firewalld (Centos6 to Iptables)

Download and install PROMETHEUS$ WGET HTTPS://GITHUB.COM/PROMETHEUS/PROMETHEUS/RELEASES/DOWNLOAD/V1.7.1/ prometheus-1.7.1.linux-amd64.tar.gz$ mkdir  /opt/prometheus$ tar zxf  prometheus-1.7.1.linux-amd64.tar.gz  -c /opt/prometheus --strip-components= 1 Edit the configuration prometheus.yml file with the contents as follows:global:  scrape_interval:     15s   evaluation_interval: 15s  external_labels:      monitor:  ' Codelab-monitor ' rule_files:scrape_configs:  - job_name:  ' Prometheus '      static_configs:      - targets: [' 192.168.1.199:9090 ']   - job_name: linux    static_configs:      -  targets: [' 192.168.1.199:9100 ']        labels:           instance: db1  - job_name: mysql    static_configs:       - targets: [' 192.168.1.199:9104 ']        labels:           INSTANCE: DB1 Background Boot prometheus nohup /opt/ prometheus/prometheus -config.file=prometheus.yml & tail -200f nohup.out  Time= "2017-06-12t11:51:16+08:00"  level=info msg= "starting prometheus  (version=1.7.0,  BRANCH=MASTER, REVISION=BFA37C8EE39D11078662DCE16C162A61DCCF616C) " source=" main.go:88 " time=" 2017-06-12t11:51:16+08:00 " level=info msg=" build context  (go=go1.8.3, [email  protected], date=20170607-09:43:48) " source=" main.go:89 " time=" 2017-06-12t11:51:16+08:00 "  Level=info msg= "host details  (linux 3.10.0-327.el7.x86_64  #1  SMP Thu  Nov 19 22:10:57 utc 2015 x86_64 monitor  (none)) " source=" main.go:90 " time=" 2017-06-12t11:51:16+08:00 " level=info msg=" Loading configuration file prometheus.yml "  source= "main.go:252"  time= "2017-06-12t11:51:16+08:00"  level=info msg= "Loading series  map and head chunks ... " source=" storage.go:428 " time=" 2017-06-12T11:51:16+08:00 " level=info msg=" 2200 series loaded. "  source= "storage.go:439"  time= "2017-06-12t11:51:16+08:00"  level=info msg= " source=" web.go:259 "
Prometheus provides a built-in web interface. We can pass the http://192.168.1. 199:9,090 Visits

650) this.width=650; "Src=" https://s4.51cto.com/wyfs02/M01/98/A7/wKiom1k_VuSzjWuWAACw3bfnMEA288.png-wh_500x0-wm_ 3-wmp_4-s_1786131749.png "title=" 22.png "alt=" Wkiom1k_vuszjwuwaacw3bfnmea288.png-wh_50 "/>

in theStatus -Targetspage, we can see the two target we configured, theirState 

650) this.width=650;" src="https://s3.51cto.com/wyfs02/M02/98/A7/wKiom1k_V6TQeZGqAADUtT_TxoI972.png-wh_500x0-wm_3-wmp_4-s_4186660654.png" title="44.png" alt="wKiom1k_V6TQeZGqAADUtT_TxoI972.png-wh_50" />

Third, next we install client clients

1, installation Client$ wget https://github.com/prometheus/node_exporter/releases/download/v0.14.0/node_ exporter-0.14.0.linux-amd64.tar.gz$ wget https://github.com/prometheus/mysqld_exporter/releases/ download/v0.10.0/mysqld_exporter-0.10.0.linux-amd64.tar.gz$ mkdir /opt/prometheus_exporters$  tar zxf node_exporter-0.14.0.linux-amd64.tar.gz -c /opt/prometheus_exporters -- Strip-components=1  && tar zxf mysqld_exporter-0.10.0.linux-amd64.tar.gz  -C /OPT/PROMETHEUS_EXPORTERS --STRIP-COMPONENTS=12, start OS monitoring client nohup /opt/ Prometheus_exporters/node_exporter & tail -200f nohup.out time= "2017-06-12T11 : 28:52+08:00 " level=info msg="  - hwmon " source=" node_exporter.go:162 "Time=" 2017-06-12t11:28:52+08:00 " level=info msg="  - netstat " source=" node_exporter.go:162 " Time= "2017-06-12t11:28:52+08:00"  level=info msg= " - stat " source=" node_exporter.go:162 "time=" 2017-06-12t11:28:52+08:00 " level=info msg = " - vmstat"  source= "node_exporter.go:162" time= "2017-06-12t11:28:52+08:00"  level=info  source= "node_exporter.go:186" 3, Mysqld_exporter need to connect to MySQL, need authorization mysql> grant replication  client, process on *.* to  ' monitor ' @ ' localhost '  identified by  ' test123 ';mysql> grant select on performance_schema.* to  ' monitor ' @ ' localhost '; 4, create  .my.cnf  file and run mysqld_exporter[[email protected] prometheus_exporters]# cat . my.cnf [client]user=monitorpassword=test123 Start Mysqld_exporternohup /opt/prometheus_exporters/mysqld_ Exporter -config.my-cnf= ". My.cnf"  &tail -200f nohup.outtime= "2017-06-12T11:30:07+08:00 " level=info msg=" starting mysqld_exporter  (version=0.10.0, branch=master,  revision=80680068f15474f87847c8ee8f18a2939a26196a) " source=" mysqld_exporter.go:460 "time=" 2017-06-12t11:30:07+08:00 " level=info  msg= "build context  (go=go1.8.1, [email protected], date=20170425-11:24:12)"  source= "mysqld_exporter.go:461" time= "2017-06-12t11:30:08+08:00"  level=info msg= " source=" mysqld_exporter.go:479 "

We go back to 192.168.1.199:9090 and we can see

 Status -Targetspage

650) this.width=650; "Src=" https://s1.51cto.com/wyfs02/M02/98/A8/wKiom1k_XLrwwLDTAADUtT_TxoI102.png-wh_500x0-wm_ 3-wmp_4-s_4156037158.png "title=" 44.png "alt=" Wkiom1k_xlrwwldtaadutt_txoi102.png-wh_50 "/>

IV,

1, installation grafana#wget https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-4.3.2-1.x86_64.rpm   #yum  localinstall grafana-4.3.2-1.x86_64.rpm 2, edit config file  /etc/grafana/grafana.ini  , modify the values of the two parameters under the  dashboards.json  paragraph: [dashboards.json]enabled = truepath = /var/lib/ GRAFANA/DASHBOARDS2, running  grafana systemctl start grafana-server# [[email protected ] prometheus_exporters]# ps aux |grep grafanaroot       3211  0.0  0.0 112664   972 pts/1    s+    11:40   0:00 grep --color=auto grafanagrafana  21241   0.3  0.8 805720 39620 ?        ssl   6 Month 12   4:42 /usr/sbin/grafana-server --config=/etc/grafana/grafana.ini  --pidfile= cFg:default.paths.logs=/var/log/grafana cfg:default.paths.data=/var/lib/grafana cfg: Default.paths.plugins=/var/lib/grafana/plugins

We can access the Grafana Web interface via http://192.168.1.199:3000 (the default account/password is admin/admin):

650) this.width=650; "Src=" https://s1.51cto.com/wyfs02/M01/98/A9/wKioL1k_X1eRfQY0AAFCKRY7Lek874.png-wh_500x0-wm_ 3-wmp_4-s_2248006387.png "title=" 55.png "alt=" Wkiol1k_x1erfqy0aafckry7lek874.png-wh_50 "/>

Log in and set up the data source

650) this.width=650; "Src=" https://s4.51cto.com/wyfs02/M01/98/A9/wKiom1k_X_GQYFWJAAB03lcav4g535.png-wh_500x0-wm_ 3-wmp_4-s_2446619685.png "style=" Float:none; "title=" 7.png "alt=" Wkiom1k_x_gqyfwjaab03lcav4g535.png-wh_50 "/>

650) this.width=650; "Src=" https://s4.51cto.com/wyfs02/M01/98/A9/wKioL1k_X_OC-PsOAAC5kut_L9Y172.png-wh_500x0-wm_ 3-wmp_4-s_1518185236.png "style=" Float:none; "title=" 8.png "alt=" Wkiol1k_x_oc-psoaac5kut_l9y172.png-wh_50 "/>

It's done.

We can see the OS and database monitoring data.

650) this.width=650; "Src=" https://s3.51cto.com/wyfs02/M00/98/A9/wKioL1k_YNaRHWPBAAFbttD6Xyc255.png-wh_500x0-wm_ 3-wmp_4-s_1948612843.png "style=" Float:none; "title=" 9.png "alt=" Wkiol1k_ynarhwpbaafbttd6xyc255.png-wh_50 "/>

650) this.width=650; "Src=" https://s1.51cto.com/wyfs02/M02/98/A9/wKiom1k_YN3BxezxAAFDx7hNFBs450.png-wh_500x0-wm_ 3-wmp_4-s_1388032206.png "style=" Float:none; "title=" 10.png "alt=" Wkiom1k_yn3bxezxaafdx7hnfbs450.png-wh_50 "/>





This article is from the "Linux-letian" blog, make sure to keep this source http://412166174.blog.51cto.com/3102369/1934854

Monitor MySQL with Prometheus and Grafana

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.