一、Prometheus監(jiān)控Nginx
1、監(jiān)控Nginx相關(guān)插件下載地址
nginx_exporter下載地址
Nginx_module-vts下載地址
nginx-release下載地址
Prometheus(8.3.3)和grafana(2.32.1)我使用的是官網(wǎng)最新版
2、編譯Nginx
注意:我這邊是使用rpm安裝的Nginx。所以要進(jìn)行編譯一下,可以根據(jù)自己的實(shí)際情況進(jìn)行操作
2.1 下載 nginx-release 并解壓
如果有這兩個(gè)目錄將其刪除掉
rm -rf Makefile objs
2.2 解壓 Nginx-module-vts,到/opt/nginx/
2.3 執(zhí)行以下命令,進(jìn)行編譯Nginx
./configure --prefix=/usr/share/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/lib/nginx/tmp/client_body --http-proxy-temp-path=/var/lib/nginx/tmp/proxy --http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi --http-uwsgi-temp-path=/var/lib/nginx/tmp/uwsgi --http-scgi-temp-path=/var/lib/nginx/tmp/scgi --pid-path=/run/nginx.pid --lock-path=/run/lock/subsys/nginx --user=nginx --group=nginx --with-compat --with-debug --with-file-aio --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_degradation_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_image_filter_module=dynamic --with-http_mp4_module --with-http_perl_module=dynamic --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-http_xslt_module=dynamic --with-mail=dynamic --with-mail_ssl_module --with-pcre --with-pcre-jit --with-stream=dynamic --with-stream_ssl_module --with-stream_ssl_preread_module --with-threads --with-cc-opt="-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic" --with-ld-opt="-Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,-E" --add-module=/opt/nginx/nginx-module-vts-0.1.18
2.4 再執(zhí)行 make 命令
注意: 不要執(zhí)行make install
make
2.5 將編譯后的二進(jìn)制文件以及模塊放到對應(yīng)的目錄下,并將原來的做備份
2.6 在Nginx 添加以下內(nèi)容到Nginx配置文件中
location /status { vhost_traffic_status_display; vhost_traffic_status_display_format html; }
2.7 重新啟動(dòng)Nginx,并檢查服務(wù)是否正常
http://127.0.0.1:80/status/
2.8 解壓Nginx-vts-exporter,并啟動(dòng)
啟動(dòng)nginx-vts-exporter(默認(rèn)端口為9913)
nohup ./nginx-vts-exporter -nginx.scrape_uri=http://127.0.0.1:80/status/format/json &
2.9 在Prometheus中添加Nginx-vts-exporter,并重啟Prometheus
vim promethues.yml - job_name: "nginx_exporter" static_configs: - targets: ["localhost:9913"]
2.10 在grafana 中添加模塊 使用的模塊是2949,也可以自己定義
數(shù)據(jù)展示
二、Prometheus監(jiān)控hbase
1. 監(jiān)控hbase插件下載地址
jmx_prometheus_javaagent
grafana模塊
2. 部署
2.1 將下載好的jmx_prometheus_javaagent 移動(dòng)到hbase的lib下
2.2 配置 hbase_jmx_config.yaml
vim /usr/hbase/conf/ hbase_jmx_config.yaml
--- lowercaseOutputName: true lowercaseOutputLabelNames: true rules: - pattern: Hadoop<service=HBase, name=RegionServer, sub=Regions><>Namespace_([^W_]+)_table_([^W_]+)_region_([^W_]+)_metric_(w+) name: HBase_metric_$4 labels: namespace: "$1" table: "$2" region: "$3" - pattern: Hadoop<service=(w+), name=(w+), sub=(w+)><>([w._]+) name: hadoop_$1_$4 labels: "name": "$2" "sub": "$3" - pattern: .+
2.3 在hbase-env.sh 中添加以下參數(shù),并重啟hbase
注意:分別在master和regionserver 都要添加,但是要注意端口不可以相同。(每臺(tái)服務(wù)都做以上操作)
master
-javaagent:$HBASE_HOME/lib/jmx_prometheus_javaagent-0.16.1.jar=17000:$HBASE_HOME/conf/hbase_jmx_config.yaml
regionserver
-javaagent:$HBASE_HOME/lib/jmx_prometheus_javaagent-0.16.1.jar=18000:$HBASE_HOME/conf/hbase_jmx_config.yaml
2.4 查看是否采集數(shù)據(jù)
http://127.0.0.1:17000/metrics
2.5 配置Prometheus server,并重啟服務(wù)
IP地址根據(jù)實(shí)際情況改寫
vim prometheus.yml - job_name: "hbase_exporter" static_configs: - targets: ["127.0.0.1:17000"] - targets: ["127.0.0.1:18000"] - targets: ["127.0.0.1:18000"] - targets: ["127.0.0.1:18000"] - targets: ["127.0.0.1:18000"]
2.6 在granfan中添加模塊
grafana模塊
數(shù)據(jù)展示
到此這篇關(guān)于Prometheus監(jiān)控實(shí)戰(zhàn)篇Nginx、Hbase的文章就介紹到這了,更多相關(guān)Prometheus監(jiān)控Nginx、Hbase內(nèi)容請搜索服務(wù)器之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持服務(wù)器之家!
原文地址:https://blog.csdn.net/yuansheng730/article/details/123114061