Nginx 是免費、開放原始碼的高效能 HTTP 伺服器與反向 Proxy,同時也是 IMAP/POP3 Proxy 伺服器。詳情請參閱 nginx.org。
這項功能僅適用於在 Linux 上執行的代理程式。但無法在 Windows 上使用。
探索
即使並未設定 Nginx 外掛程式,Cloud Monitoring 也會透過以下方式探索在 Cloud Platform 專案中執行的 Nginx 服務:
- 搜尋執行個體名稱 nginx
- 檢查透過防火牆規則向 80 或 443 開啟的通訊埠
如要查看 Nginx 的指標,請按照下列步驟操作:
-
在 Google Cloud 控制台中,前往「Dashboards」(資訊主頁)
頁面:
如果您是使用搜尋列尋找這個頁面,請選取子標題為「Monitoring」的結果。
- 從清單中選取「Nginx」Nginx資訊主頁。
設定讓 Monitoring 監控 Nginx
安裝監控代理程式後,請按照下列操作說明,對您的執行個體設定 Nginx 外掛程式。
必備條件
Nginx 外掛程式需要您在 Nginx 中啟用狀態資訊處理常式。您可從 GitHub 設定存放區下載 status.conf,並放進 Nginx 設定目錄 (通常為 /etc/nginx/conf.d/
):
(cd /etc/nginx/conf.d/ && sudo curl -O https://raw.githubusercontent.com/Stackdriver/stackdriver-agent-service-configs/master/etc/nginx/conf.d/status.conf)
您也可以將 status.conf 的內容附加至 nginx.conf
檔案,此檔通常位於 VM 執行個體的下列其中一個目錄中:/etc/nginx
、/usr/local/nginx/conf
或 /usr/local/etc/nginx
。
請執行下列指令,重新載入 Nginx 設定:
sudo service nginx reload
啟用 Nginx 監控外掛程式
在您的 VM 執行個體上,從 GitHub 設定存放區下載 nginx.conf,並放進 /etc/stackdriver/collectd.d/
目錄中:
(cd /etc/stackdriver/collectd.d/ && sudo curl -O https://raw.githubusercontent.com/Stackdriver/stackdriver-agent-service-configs/master/etc/collectd.d/nginx.conf)
新增設定檔之後,執行下列指令來重新啟動監控代理程式:
sudo service stackdriver-agent restart
如要進一步瞭解 collectd
nginx
外掛程式,請參閱「外掛程式:nginx」。
監控的內容
如要查看 Nginx 外掛程式監控的指標完整清單,請參閱代理程式指標:Nginx。