人妖在线一区,国产日韩欧美一区二区综合在线,国产啪精品视频网站免费,欧美内射深插日本少妇

新聞動態(tài)

解析prometheus+grafana監(jiān)控nginx的方法

發(fā)布日期:2021-12-11 04:30 | 文章來源:站長之家

?在prometheus需要向ngxin中打入探針,通過探針獲取ngxin信息,并通過接口輸出。下文將講述如何監(jiān)控ngxin。

1.下載

為了各位小伙伴方便,這里提供了一波下載地址,如果模板不是特別滿意,也可以去官網(wǎng)自行下載。

nginx:

鏈接: https://pan.baidu.com/s/1QxcWrxAEARlEhxSb2ZETjQ

提取碼: 6fp5

nginx-module-vts-master:

鏈接: https://pan.baidu.com/s/1gCyAithAlRkORuZwhpcPmA?

提取碼: h9aa

nginx-vts-exporter
鏈接: https://pan.baidu.com/s/1gVB_I6ifDbeNIBX5x9pGAA

提取碼: upkw?

nginx-vts-stats_rev2 (grafana顯示模板)
鏈接: https://pan.baidu.com/s/1VI9V395OemPkf6W-sNL9HQ

提取碼: da56?

2.安裝nginx與nginx-vts-exporter

1.解壓nginx-vts-exporter

這里nginx是重新安裝 ,解壓nginx-vts-exporter 這里放在usr/local。

unzip nginx-module-vts-master.zip

這里注意nginx版本有要求否則會報錯,以下是nginx對應(yīng)的版本。

2.解壓nginx。

tar -zxvf nginx-1.14.2.tar.gz

3.安裝

把nginx-vts-exporter放到nginx路徑 ,并執(zhí)行安裝操作。

cd usr/local/nginx-1.14.2
./configure --prefix=/usr/local/nginx --add-module=usr/local/nginx-module-vts-master/
注意:注意prefix=/usr/local/nginx意思是安裝位置為/usr/local/nginx文件夾
make install

4.修改conf文件

http {
    vhost_traffic_status_zone;
    vhost_traffic_status_filter_by_host on;
...
server {
    ...
    location /status {
        vhost_traffic_status_display;
        vhost_traffic_status_display_format html;
    }
}

5.啟動

cd /usr/local/nginx/sbin
./nginx

訪問http://ip/status出現(xiàn)以下顯示則表示nginx與nginx-vts-exporter安裝成功。

3.安裝nginx-vts-exporter-0.9.1.linux-amd64.tar

這里安裝包放在usr/local下,解壓。

tar -zxvf nginx-vts-exporter-0.9.1.linux-amd64.tar

啟動。

cd /usr/local/nginx-vts-exporter-0.9.1.linux-amd64
nohup ./nginx-vts-exporter  -nginx.scrape_uri http://ip/status/format/json &

輸入http://ip:9913/metrics,如果出現(xiàn)以下證明完成。

4.配置Prometheus

修改/usr/local/prometheus-2.17.1.linux-amd64/prometheus.yml。

# my global config
global:
  scrape_interval:     15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
  evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
  # scrape_timeout is set to the global default (10s).
 
# Alertmanager configuration
alerting:
  alertmanagers:
  - static_configs:
    - targets:
      # - alertmanager:9093
 
# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
  # - "first_rules.yml"
  # - "second_rules.yml"
 
# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
  # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
  - job_name: 'prometheus'
    static_configs:
    - targets: ['localhost:9090']
  - job_name: 'nginx'
    static_configs:
      - targets: ['ip:9913']    

出現(xiàn)以下配置成功。

5.配置Grafana

輸入grafana可視化頁面地址:ip:3000。

1.配置數(shù)據(jù)源 (prometheus地址:ip:9090)


上圖填寫你prometheus地址,端口切記填寫9090,點(diǎn)擊save后,如果失敗會有提示 。

2.可視化界面模板

選擇上文配置好的數(shù)據(jù)源,prometheus選項就是上文配置的數(shù)據(jù)源。

3.驗證

出現(xiàn)以下顯示則表示成功。

到此這篇關(guān)于解析prometheus+grafana監(jiān)控nginx的方法的文章就介紹到這了,更多相關(guān)prometheus+grafana監(jiān)控nginx內(nèi)容請搜索本站以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持本站!

版權(quán)聲明:本站文章來源標(biāo)注為YINGSOO的內(nèi)容版權(quán)均為本站所有,歡迎引用、轉(zhuǎn)載,請保持原文完整并注明來源及原文鏈接。禁止復(fù)制或仿造本網(wǎng)站,禁止在非www.sddonglingsh.com所屬的服務(wù)器上建立鏡像,否則將依法追究法律責(zé)任。本站部分內(nèi)容來源于網(wǎng)友推薦、互聯(lián)網(wǎng)收集整理而來,僅供學(xué)習(xí)參考,不代表本站立場,如有內(nèi)容涉嫌侵權(quán),請聯(lián)系alex-e#qq.com處理。

實(shí)時開通

自選配置、實(shí)時開通

免備案

全球線路精選!

全天候客戶服務(wù)

7x24全年不間斷在線

專屬顧問服務(wù)

1對1客戶咨詢顧問

在線
客服

在線客服:7*24小時在線

客服
熱線

400-630-3752
7*24小時客服服務(wù)熱線

關(guān)注
微信

關(guān)注官方微信
頂部