Prometheus監(jiān)控實(shí)戰(zhàn)篇Nginx、Hbase操作詳解
一、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)制文件以及模塊放到對(duì)應(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中添加模塊


數(shù)據(jù)展示

到此這篇關(guān)于Prometheus監(jiān)控實(shí)戰(zhàn)篇Nginx、Hbase的文章就介紹到這了,更多相關(guān)Prometheus監(jiān)控Nginx、Hbase內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
- Prometheus 和 Grafana 通過nginx-exporter監(jiān)控nginx的詳細(xì)步驟
- 解析prometheus+grafana監(jiān)控nginx的方法
- prometheus監(jiān)控nginx并實(shí)現(xiàn)可視化的操作指南
- prometheus監(jiān)控nginx的兩種方式
- 詳解Prometheus 抓取 nginx 訪問日志的指標(biāo)
- Nginx配置Prometheus監(jiān)控的實(shí)現(xiàn)
- prometheus監(jiān)控nginx的實(shí)現(xiàn)
- Nginx使用Prometheus+Grafana實(shí)現(xiàn)日志分析與監(jiān)控
- 通過Nginx(basic auth)實(shí)現(xiàn)Prometheus賬號(hào)密碼登錄
相關(guān)文章
Nginx gateway集群和動(dòng)態(tài)網(wǎng)關(guān)的實(shí)現(xiàn)思路
這篇文章主要介紹了Nginx gateway集群和動(dòng)態(tài)網(wǎng)關(guān),動(dòng)態(tài)網(wǎng)關(guān)即任何配置都實(shí)現(xiàn)不用重啟網(wǎng)關(guān)服務(wù)器都可以及時(shí)刷新,對(duì)Nginx gateway集群相關(guān)知識(shí)感興趣的朋友一起看看吧2022-10-10
Nginx端口被占用的解決方案(systemctl restart nginx失敗)
ginx (engine x) 是一個(gè)高性能的HTTP和反向代理服務(wù)器,也是一個(gè)IMAP/POP3/SMTP服務(wù)器,它也是一種輕量級(jí)的Web服務(wù)器,可以作為獨(dú)立的服務(wù)器部署網(wǎng)站(類似Tomcat),本文給大家介紹了NGINX啟動(dòng)報(bào)錯(cuò),端口被占用解決方案,需要的朋友可以參考下2024-10-10
Ubuntu系統(tǒng)下的Nginx服務(wù)器軟件安裝時(shí)的常見錯(cuò)誤解決
這篇文章主要介紹了Ubuntu系統(tǒng)下的Nginx服務(wù)器軟件安裝時(shí)的常見問題解決,包括徹底卸載Nginx的方法介紹,需要的朋友可以參考下2016-03-03
nginx多域名轉(zhuǎn)發(fā)的實(shí)現(xiàn)
本文主要介紹了nginx多域名轉(zhuǎn)發(fā)的實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2023-03-03
解決nginx 503 Service Temporarily Unavailable方法示例
這篇文章主要介紹了解決nginx 503 Service Temporarily Unavailable方法示例,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2019-12-12
Nginx access.log日志詳解及統(tǒng)計(jì)分析小結(jié)
nginx有一個(gè)非常靈活的日志記錄模式,本文主要介紹了Nginx access.log日志詳解及統(tǒng)計(jì)分析小結(jié),文中通過示例代碼介紹的非常詳細(xì),需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2024-03-03

