In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article shows you how to achieve Prometheus application monitoring, the content is concise and easy to understand, can definitely brighten your eyes, through the detailed introduction of this article, I hope you can get something.
Monitoring Nginx
Nginx:1.16.1 、 nginx-vts-exporter:0.10.3 、 nginx-module-vts:1.6.3
Monitoring Nginx mainly uses the following three modules:
Nginx-module-vts:Nginx monitoring module, can provide data output in JSON format.
Nginx-vts-exporter: mainly used to collect monitoring data of Nginx and provide monitoring interface to Prometheus. The default port number is 9913.
Prometheus: monitor the Nginx data provided by Nginx-vts-exporter and store it in the time series database. You can use PromQL to query and aggregate the time series data
Nginx-module-vts module compilation
Nginx_vts_exporter relies on the nginx-module-vts module, and no additional dependencies are required to install this module. The version compatibility of the module with Nginx is as follows:
1.11.x (last tested: 1.11.10) 1.10.x (last tested: 1.10.3) 1.8.x (last tested: 1.8.0) 1.6.x (last tested: 1.6.3) 1.4.x (last tested: 1.4.7)
1. Install dependency packages
$yum-y install gcc gcc-c++ autoconf automake make $yum-y install zlib zlib-devel openssl openssl-devel pcre pcre-devel
two。 Add www user
$groupadd-f www$ useradd-g www www
3. Download nginx (version 1.16.1)
$wget http://nginx.org/download/nginx-1.16.1.tar.gz$ tar xf nginx-1.16.1.tar.gz
3. Clone vts module repository
Https://github.com/vozlt/nginx-module-vts/releases
$git clone git://github.com/vozlt/nginx-module-vts.git
4. Compile nginx configuration and add vts module
Add the vts module when nginx compiles:-- add-module=/path/to/nginx-module-vts
$cd nginx-1.16.1/# configuration nginx#-- prefix specifies the installation directory # / usr/local/nginx is the installation directory You cannot duplicate the directory of files you downloaded #. / configure-- prefix=/usr/local/nginx$. / configure-- user=www-- group=www\-- prefix=/usr/local/nginx\-- with-http_stub_status_module\-- with-http_ssl_module\-- with-stream\-- with-http_gzip_static_module\-- with-http_sub_module\-- add-module=/root/nginx-module-vts$ make & & make install
5.Nginx config configuration
Change the configuration of Nginx Conf and add monitoring interface / status
$vim / usr/local/nginx/conf/nginx.confuser www;worker_processes 1 leading events {worker_connections 1024;} http {include mime.types; default_type application/octet-stream Log_format main'$remote_addr-$remote_user [$time_local] "$request"'$status $body_bytes_sent "$http_referer"'"$http_user_agent"$http_x_forwarded_for"; access_log logs/access.log main; sendfile on; tcp_nopush on; keepalive_timeout 65 # enabled nginx status vhost_traffic_status_zone; gzip on; server {listen 80; server_name localhost; location / status {vhost_traffic_status_display; vhost_traffic_status_display_format html; # Only allow local access the url allow 127.0.0.1;}
Check the nginx syntax and start
$/ usr/local/nginx/sbin/nginx-tnginx: the configuration file / usr/local/nginx/conf/nginx.conf syntax is oknginx: configuration file / usr/local/nginx/conf/nginx.conf test is successful$ / usr/local/nginx/sbin/nginx
6.curl View captured nginx data
$curl http://127.0.0.1/status/format/json
7. Install nginx-vts-exporter
Download address: https://github.com/hnlq715/nginx-vts-exporter/releases
$tar xf nginx-vts-exporter-0.10.3.linux-amd64.tar.gz$ cp nginx-vts-exporter-0.10.3.linux-amd64/nginx-vts-exporter / usr/local/bin/// launch command nginx-vts-exporter- nginx.scrape_uri= http://127.0.0.1/status/format/json
6. Add nginx-vts-exporter to the system system service
$vim / usr/lib/systemd/system/nginx-vts-exporter.service [Unit] Description=PrometheusWants=network-online.targetAfter=network- online.target [service] User=rootGroup=rootType=simpleExecStart=/usr/local/bin/nginx-vts-exporter\-nginx.scrape_uri= http://127.0.0.1/status/format/json[Install]WantedBy=multi-user.target
7. Start the added system service
$systemctl daemon-reload$ systemctl start nginx-vts-exporter.service$ systemctl enable nginx-vts-exporter.service// nginx-vts-exporter default port-9913$ netstat-lntup | grep "9913" tcp6 0 0:: 9913:: * LISTEN 9195/nginx-vts-expo
8. Use prometheus monitoring to modify the configuration file on the monitoring side
$vim / usr/local/prometheus/prometheus.yml-job_name: 'nginx' static_configs:-targets: [' 10.0.0.171pur9913']
9. Start the prometheus service
$systemctl restart prometheus.service
10. Check whether the monitoring side is involved.
11.Granfana Import Nginx Monitoring Chart
Https://grafana.com/grafana/dashboards/2949
Monitoring MySQL
This paper mainly monitors the master-slave information of MySQL/MySQL.
Version: mysql-5.7,mysql_exporter-0.12.1
Mysql_exporter download address: https://github.com/prometheus/mysqld_exporter/releases
1. Download mysql_exporter and decompress it
$tar xf mysqld_exporter-0.12.1.linux-amd64.tar.gz// copies the mysql_ exporter binary file to / usr/local/bin$ cp mysqld_exporter-0.12.1.linux-amd64/mysqld_exporter / usr/local/bin/
two。 Users need to be authorized to use exporter.
> CREATE USER 'exporter'@'localhost' IDENTIFIED BY' abc12345' WITH MAX_USER_CONNECTIONS 3 Splitter / can view master-slave running status view threads, and all databases. > GRANT PROCESS, REPLICATION CLIENT, SELECT ON *. * TO 'exporter'@'localhost'
Set the maximum number of connections for the user to avoid overloading the server due to excessive monitoring data
3. Modify the mysql configuration file to add the exporter user and password you just created
$vim / etc/ my.cnf [client] user=exporterpassword=abc12345
4. To start the exporter client, you need to specify the mysql configuration file and read the exporter user and password
$mysqld_exporter-- Common parameters for config.my-cnf=/etc/my.cnf: / / Select Collection innodb--collect.info_schema.innodb_cmp// innodb Storage engine status-- collect.engine_innodb_status// specified configuration file-- config.my-cnf= "/ etc/my.cnf"
5. Add system system service
$vim / usr/lib/systemd/system/mysql_ exporter.service[ unit] Description=PrometheusWants=network-online.targetAfter=network- online.target[ service] User=rootGroup=rootType=simpleExecStart=/usr/local/bin/mysqld_exporter\-- config.my-cnf=/etc/my.cnf [Install] WantedBy=multi-user.target
6. Start the added system service
$systemctl daemon-reload$ systemctl start mysql_exporter.service$ systemctl enable mysql_exporter.service// mysql_export default port-9104$ netstat-lntup | grep "9104" tcp6 0 0:: 9104:: * LISTEN 34137/mysqld_export
7.curl View captured mysql data
Curl http://localhost:9104/metrics
8. Use prometheus monitoring to modify the configuration file on the monitoring side
$vim / usr/local/prometheus/prometheus.yml-job_name: 'mysql' scrape_interval: 5s # statically add node static_configs:-targets: [' 10.0.0.171job_name 9104']
9. Start the prometheus service
$systemctl restart prometheus.service
10. Check whether the monitoring side is involved.
11.Granfana Import MySQL Monitoring Chart
Https://grafana.com/grafana/dashboards/8564/revisions
Monitoring Redis
This article mainly monitors redis information.
Version: redis-3.2.2,redis_exporter-1.3.4
Install and deploy redis: https://blog.51cto.com/12643266/2349586
Redis_exporter download address: https://github.com/oliver006/redis_exporter/releases/
1. Download the redis_exporter plug-in
The agent plug-in does not have to be installed on the rediss side
$wget https://github.com/oliver006/redis_exporter/releases/download/v1.3.4/redis_exporter-v1.3.4.linux-amd64.tar.gz$ tar xf redis_exporter-v1.3.4.linux-amd64.tar.gz$ cp redis_exporter-v1.3.4.linux-amd64/redis_exporter / usr/local/bin/
two。 Start redis_exporter and log in to redis
/ / No password redis_exporter-redis.addr 127.0.0.1 redis_exporter 6379 / / password redis_exporter-redis.addr 172.0.0.1 redis_exporter 6379-redis.password 123456
3. Add system system service
$vim / usr/lib/systemd/system/redis_ exporter.service[ Unit] Description=PrometheusWants=network-online.targetAfter=network- online.target[ Service] User=rootGroup=rootType=simpleExecStart=/usr/local/bin/redis_exporter\-redis.addr 127.0.0.1 User=rootGroup=rootType=simpleExecStart=/usr/local/bin/redis_exporter [Install] WantedBy=multi-user.target
4. Start the added system service
$systemctl daemon-reload$ systemctl start redis_exporter.service$ systemctl enable redis_exporter.service// redis_exporter default port-9121$ netstat-lntup | grep 9121 "" tcp6 0 0: 9121:: * LISTEN 4465/redis_exporter
5. Local curl access
Curl http://127.0.0.1:9121/metrics
6.prometheus.yml joins the redis node, and then restart prometheus:
-job_name: 'redis' static_configs:-targets: [' 10.0.0.171purl 9121']
7. Restart the prometheus server
Systemctl restart prometheus.service
8. Check whether the monitoring side is involved.
9.Granfana Import Redis Monitoring Chart
Redis Node Monitoring: https://grafana.com/grafana/dashboards/2751
Redis Sentinel Monitoring: https://grafana.com/grafana/dashboards/9570
The above content is how to implement Prometheus application monitoring. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.