最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Nginx配置Prometheus監(jiān)控的實現(xiàn)

 更新時間:2025年02月11日 11:03:50   作者:慕容峻才  
本文主要介紹了Nginx配置Prometheus監(jiān)控的實現(xiàn),文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧

安裝包下載,注意下載nginx版本需要和生產(chǎn)環(huán)境保持一致

wget https://github.com/vozlt/nginx-module-vts/archive/refs/tags/v0.2.2.tar.gz
wget https://github.com/hnlq715/nginx-vts-exporter/releases/download/v0.10.3/nginx-vts-exporter-0.10.3.linux-amd64.tar.gz
wget http://nginx.org/download/nginx-1.26.2.tar.gz

解壓nginx-module-vts

tar -xf /opt/v0.2.2.tar.gz -C /usr/local/src/

查看運行nginx編譯參數(shù)

nginx -V 
./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-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi --http-proxy-temp-path=/var/lib/nginx/tmp/proxy --http-scgi-temp-path=/var/lib/nginx/tmp/scgi --http-uwsgi-temp-path=/var/lib/nginx/tmp/uwsgi --pid-path=/run/nginx.pid --lock-path=/run/lock/subsys/nginx --user=nginx --group=nginx --with-file-aio --with-ipv6 --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module=dynamic --with-http_image_filter_module=dynamic --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_slice_module --with-http_perl_module=dynamic --with-http_auth_request_module --with-mail=dynamic --with-mail_ssl_module --with-pcre --with-pcre-jit --with-stream=dynamic --with-stream_ssl_module --with-google_perftools_module --with-debug --with-cc-opt='-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/generic-hardened-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -specs=/usr/lib/rpm/generic-hardened-ld -Wl,-E'

安裝編譯環(huán)境

yum install pcre-devel openssl-devel libxml2-devel libxslt-devel gd-devel gperftools gperftools-devel

解壓nginx源碼

tar xf nginx-1.26.2.tar.gz

再原來編譯參數(shù)基礎(chǔ)上添加vts模塊,進行編譯

./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-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi --http-proxy-temp-path=/var/lib/nginx/tmp/proxy --http-scgi-temp-path=/var/lib/nginx/tmp/scgi --http-uwsgi-temp-path=/var/lib/nginx/tmp/uwsgi --pid-path=/run/nginx.pid --lock-path=/run/lock/subsys/nginx --user=nginx --group=nginx --with-file-aio --with-ipv6 --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module=dynamic --with-http_image_filter_module=dynamic --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_slice_module --with-http_perl_module=dynamic --with-http_auth_request_module --with-mail=dynamic --with-mail_ssl_module --with-pcre --with-pcre-jit --with-stream=dynamic --with-stream_ssl_module --with-google_perftools_module --with-debug --with-cc-opt='-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/generic-hardened-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -specs=/usr/lib/rpm/generic-hardened-ld -Wl,-E' --add-module=/usr/local/src/nginx-module-vts-0.2.2/
make

備份nginx配置文件

cd /usr/local/nginx/conf
cp nginx.conf nginx.conf.bak

nginx配置文件添加配置

#在nginx.conf http塊添加如下配置
vhost_traffic_status_filter_by_host on;
vhost_traffic_status_zone;
server {
   listen 8089;
    location /status {
     vhost_traffic_status_display;
     vhost_traffic_status_display_format html;
}
}

將so文件替換

cd /usr/lib64/nginx/modules/
mkdir backup
mv ./* backup/
cp /root/nginx-1.26.2/objs/*.so .

替換nginx二進制文件,并啟動nginx

#先備份二進制文件
cd /usr/local/nginx/sbin
cp nginx nginx.20241206
#停止nginx,不然新的二進制文件覆蓋不了
systemctl stop nginx
#替換二進制文件
cp /root/nginx-1.20.2/nginx-1.20.2/objs/nginx .
#檢查配置文件語法
./nginx -t
#啟動Nginx
systemctl start nginx

部署exporter

tar -xf nginx-vts-exporter-0.10.3.linux-amd64.tar.gz
cp /opt/nginx-vts-exporter-0.10.3.linux-amd64/nginx-vts-exporter /usr/local/bin/
cat > /etc/systemd/system/nginx_vts_exporter.service << EOF
[Unit]
Description=nginx_exporter
After=network.target
[Service]
Type=simple
ExecStart=/usr/local/bin/nginx-vts-exporter -telemetry.address :9145 -nginx.scrape_uri=http://192.168.20.3:8089/status/format/json
Restart=on-failure
[Install]
WantedBy=multi-user.target
EOF
systemctl start nginx_vts_exporter
systemctl enable nginx_vts_exporter

測試插件

curl http://x.x.x.x:9145/metrics

到此這篇關(guān)于Nginx配置Prometheus監(jiān)控的實現(xiàn)的文章就介紹到這了,更多相關(guān)Nginx Prometheus監(jiān)控內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家! 

相關(guān)文章

  • Nginx proxy_pass如何到https后端

    Nginx proxy_pass如何到https后端

    這篇文章主要介紹了Nginx proxy_pass如何到https后端問題,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2024-05-05
  • Nginx的偽靜態(tài)配置中使用rewrite來實現(xiàn)自動補全的實例

    Nginx的偽靜態(tài)配置中使用rewrite來實現(xiàn)自動補全的實例

    這篇文章主要介紹了Nginx的偽靜態(tài)配置中使用rewrite來實現(xiàn)自動補全的實例,文中對rewrite的相關(guān)參數(shù)和正則表達使用也做了介紹,需要的朋友可以參考下
    2015-12-12
  • 一個Nginx實現(xiàn)部署多個不同的項目方式

    一個Nginx實現(xiàn)部署多個不同的項目方式

    這篇文章主要介紹了一個Nginx實現(xiàn)部署多個不同的項目方式,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2024-03-03
  • Jenkins實現(xiàn)集群化管理以及流水線項目配置

    Jenkins實現(xiàn)集群化管理以及流水線項目配置

    這篇文章主要為大家介紹了Jenkins基本概念,配置實現(xiàn)集群化管理以及配置流水線項目的實現(xiàn),有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪
    2022-03-03
  • Nginx+SSL實現(xiàn)雙向認證的示例代碼

    Nginx+SSL實現(xiàn)雙向認證的示例代碼

    這篇文章主要介紹了Nginx+SSL實現(xiàn)雙向認證的示例代碼,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2019-01-01
  • Nginx安裝完成沒有生成sbin目錄的解決方法

    Nginx安裝完成沒有生成sbin目錄的解決方法

    這篇文章主要介紹了Nginx安裝完成沒有生成sbin目錄的解決方法,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2021-03-03
  • 詳解nginx 代理多個服務(wù)器(多個server方式)

    詳解nginx 代理多個服務(wù)器(多個server方式)

    本篇文章主要介紹了詳解nginx 代理多個服務(wù)器(多個server方式),小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-10-10
  • Nginx服務(wù)啟動和停止實現(xiàn)

    Nginx服務(wù)啟動和停止實現(xiàn)

    使用Nginx的過程中,我們可能總是需要修改nginx配置文件,然后不停地啟動或者停止nginx服務(wù),本文就來介紹一下,感興趣的可以了解一下
    2023-11-11
  • Nginx中配置防盜鏈的方法實現(xiàn)

    Nginx中配置防盜鏈的方法實現(xiàn)

    在數(shù)字化時代,保護網(wǎng)站內(nèi)容免受盜鏈至關(guān)重要,Nginx防盜鏈通過檢查請求頭Referer字段來拒絕非法來源請求,本文就來詳細的介紹一下,感興趣的可以了解一下
    2024-10-10
  • windows系統(tǒng)下安裝Nginx及簡單使用過程

    windows系統(tǒng)下安裝Nginx及簡單使用過程

    Nginx是一個很強大的高性能Web和反向代理服務(wù),也是一種輕量級的Web服務(wù)器,可以作為獨立的服務(wù)器部署網(wǎng)站,應(yīng)用非常廣泛,特別是現(xiàn)在前后端分離的情況下,這篇文章主要介紹了windows系統(tǒng)下安裝Nginx以及簡單使用,需要的朋友可以參考下
    2024-04-04

最新評論

怀远县| 新丰县| 井研县| 岳西县| 醴陵市| 西乌| 淳安县| 腾冲县| 鸡泽县| 涡阳县| 长春市| 辽阳县| 定西市| 尼勒克县| 鄂托克前旗| 交口县| 彩票| 维西| 长治市| 石嘴山市| 库伦旗| 贵州省| 咸丰县| 永城市| 根河市| 永寿县| 山东省| 兴城市| 大英县| 和平区| 四川省| 菏泽市| 平谷区| 双辽市| 襄城县| 望奎县| 富顺县| 天气| 唐海县| 德兴市| 剑川县|