Nginx 外掛程式

Nginx 是免費的開放原始碼高效能 HTTP 伺服器和反向 Proxy,也是 IMAP/POP3 Proxy 伺服器。詳情請造訪 nginx.org。

這項功能僅適用於在 Linux 上執行的代理程式。這項功能不適用於 Windows。

探索

即使未設定 Nginx 外掛程式,Cloud Monitoring 仍會透過下列方式,探索在 Cloud Platform 專案中執行的 Nginx 服務:

  • 搜尋執行個體名稱中的 nginx
  • 透過防火牆規則檢查通訊埠 80 或 443 是否已開啟

如要查看 Nginx 的指標,請按照下列步驟操作:

  1. 在 Google Cloud 控制台中,前往「Dashboards」(資訊主頁) 頁面:

    前往「Dashboards」(資訊主頁)

    如果您是使用搜尋列尋找這個頁面,請選取子標題為「Monitoring」的結果。

  2. 從清單中選取「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」。