監視 Apache HTTP

安裝 Instana 主機代理程式之後,會自動安裝 Apache HTTPd 感應器,但您需要配置 Apache HTTPd 感應器,如本主題所述。 然後,您可以在 Instana 使用者介面中檢視與 Apache HTTPd 相關的度量值。

支援的資訊

支援的作業系統

Apache HTTPd 感應器的受支援作業系統與主機代理程式需求一致,可以在每一個主機代理程式的 受支援作業系統 區段中檢查這些需求,例如 Unix 的受支援作業系統

支援的 Apache HTTPd 版本及平台

Apache HTTPd 感應器和 Apache HTTPd 追蹤具有不同的版本和平台需求。 如需相關資訊,請參閱 支援的 Apache HTTP 版本和平台

配置

HTTP 伺服器主要配置檔位於 /etc/apache2/apache2.conf/etc/httpd/conf/httpd.conf/etc/apache2/httpd.conf。 可以找到所使用配置檔的確切位置:

  • 在程序引數中: -d 指定根目錄和 -f 配置檔。
  • apachectl -V 輸出中: HTTPD_ROOT=SERVER_CONFIG_FILE=

Debian 使用者將套用專用狀態模組配置檔 (位於 /etc/apache2/mods-enabled/status.conf) 中的變更,而不是主要 HTTPd 配置檔。

您需要在 HTTPd 配置檔中執行下列變更:

  • 在位置 /server-status上啟用伺服器狀態 HTTP 狀態頁面。
  • 載入 status_module (mod_status) 以檢視 Apache Web 伺服器度量值。
  • 啟用 ExtendedStatus,以檢視「資料流量」、「每個要求的資料流量」及 CPU 的詳細度量值。
<Location /server-status>
    SetHandler server-status
</Location>
LoadModule status_module lib/httpd/modules/mod_status.so
ExtendedStatus On

server-status 配置放在 HTTPd 配置檔的開頭。

您可以使用下列指令來檢查配置檔是否有錯誤:

apachectl configtest

重新啟動以套用變更,而不岔斷即時連線 ( apachectl -k gracefulservice apache2 graceful)。

Instana 感應器會自動從 HTTPd 挑選配置,不需要重新啟動代理程式。 因此,您可以選擇狀態頁面的任何位置。 基於效能原因,不會遵循重新導向。

如果狀態 URL 受到保護,您需要在代理程式配置檔 <agent_install_dir>/etc/instana/configuration.yml中提供基本鑑別認證:

com.instana.plugin.httpd:
  user: ''
  password: ''

檢視度量值

若要檢視度量值,請完成下列步驟:

  1. 在 Instana 使用者介面的資訊看板中,選取 基礎架構
  2. 按一下特定的受監視主機。

然後,您可以查看包含所有已收集度量及受監視處理程序的主機儀表板。

配置資料

  • 程序 ID
  • Apache 伺服器版本
  • 架構
  • 啟動或啟動時間
  • 工作者限制
  • MPM
  • 載入的模組

效能度量

度量 說明
要求 存取 Apache 伺服器的次數
資料流量 提供的 kBytes 數目
忙碌的工作程式 忙碌工作程式執行緒及處理程序數目
連線計數 連線總數 (僅含事件 MPM 及 Apache 2.3)
非同步寫入 處於寫入狀態 (僅具有事件 MPM 及 Apache 2.3) 的非同步連線數
非同步保持作用中 處於保持作用中狀態 (僅具有事件 MPM 及 Apache 2.3) 的非同步連線數
非同步關閉中 處於關閉狀態 (僅具有事件 MPM 及 Apache 2.3) 的非同步連線數
工作程式 等待中、啟動中、讀取中、寫入中、保留作用中、DNS 中、關閉中、記載中、循序、閒置
CPU 負載 Apache 伺服器的現行 CPU (以百分比表示)
每個要求的資料流量 每個要求傳送的位元組數

性能簽章

對於每一個感應器,有一個經過策劃的性能簽章知識庫,可針對送入的度量值持續進行評估,並用來提出問題或發生事件,視使用者影響而定。

內建事件 會根據實體上失敗的性能簽章來觸發問題或突發事件,而 自訂事件 會根據任何實體的個別度量值臨界值來觸發問題或突發事件。

如需 Apache HTTPd 感應器之內建事件的相關資訊,請參閱 內建事件參照

追蹤

本節說明如何安裝及配置 Apache HTTPd 追蹤。

必要條件

在 Windows 上啟用 HTTP 追蹤之前,請先安裝 Visual C++ Redistributable Packages for Visual Studio 2015-2022。

安裝

依預設會停用 HTTPd 追蹤。 如 啟用追蹤中所述啟用 HTTPd 追蹤時,若啟用 HTTPd 感應器,則會 自動 下載「HTTPd 追蹤模組」。 追蹤配置位於 <agent_install_dir>/etc/instana/configuration.yaml,且 Instana 代理程式的現行版本包含可用配置設定的範例。

手動安裝

如果在儲存器化環境中以有限唯讀專用權執行 HTTPd 伺服器,則自動安裝「HTTPd 追蹤模組」在這種狀況下無法運作。 您可以在下列步驟中手動安裝「HTTPd 追蹤模組」:

  1. 針對您的 HTTP Server 版本 取得正確的模組
  2. 複製模組 至 HTTP Server modules 資料夾。
  3. 在 HTTPd 配置檔中 載入模組
下載模組

受支援 HTTP 伺服器版本的模組下載鏈結可在「 HTTP d 追蹤模組 」頁面上找到。

複製模組

前一個步驟中下載的兩個模組必須放在包含其他 HTTP 模組的資料夾中,且必須獲得相關檔案許可權。 對於模組 1.0.7 版或更低版本, tracelibrary_x86_64-1.0.7.so 檔案需要重新命名為 tracelibrary.so

載入模組

在 HTTPd 配置檔的相同位置建立名為 instana_tracing.conf 的檔案 (例如 /etc/httpd/conf/httpd.conf)。 檔案內容可能看起來如下:

LoadModule dem_module /usr/lib64/httpd/modules/mod_dem_x86_64-1.0.8.so

然後,在 HTTPd 配置檔中新增一行,以併入檔案 instana_tracing.conf

Include /etc/httpd/conf/instana_tracing.conf

配置

會列出 Instana 代理程式 configuration.yaml 檔中可用的 HTTPd 追蹤配置設定:

# Apache Httpd
#com.instana.plugin.httpd:
#  tracing:
#    # Enabling tracing will automatically download the HTTPd Tracing module and
#    # load it in your Apache configuration file. You will need to manually restart
#    # Apache HTTP Server unless you specify a restart script in notificationScript
#    # or enable autoRestart. Disabling tracing will not remove the HTTPd Tracing module.
#    # It will only remove the tracing module config from the Apache configuration file.
#    enabled: false
#    # Pins the HTTPd Tracing module to download and install to a specific version.
#    # This can be used to rollback to previous versions of the module or to test
#    # beta versions (when asked to do so). Expects the version to be given as
#    # major.minor.patch format, e.g. 1.0.0
#    pinModuleVersion: x.y.z
#    # The absolute path to the script to trigger whenever the sensor installed
#    # a different version of the HTTPd Tracing module than is currently installed.
#    # Works for upgrades and downgrades. Default is empty.
#    notificationScript: /path/to/restart_apache.sh
#    # Enabling auto-restart will let the sensor attempt a graceful restart of your
#    # Apache HTTP Server to load the updated HTTPd Tracing module into memory.
#    # If you specify a notificationScript, then the sensor will ignore autoRestart setting
#    # unless the execution of.notificationScript failed.
#    autoRestart: false

啟用追蹤

使用文字編輯器開啟 <agent_install_dir>/etc/instana/configuration.yaml 。 這些項目本質類似:

#com.instana.plugin.httpd:
#  tracing:
#    enabled: false

解除註銷這些行,並將 enabled: false 變更為 enabled: true

com.instana.plugin.httpd:
  tracing:
    enabled: true

如果未配置 自動重新啟動 ,您需要手動重新啟動 HTTP Server ,以將「HTTPd 追蹤模組」載入記憶體中。

停用追蹤

使用文字編輯器開啟 <agent_install_dir>/etc/instana/configuration.yaml 。 將 enabled: true 變更為 enabled: false。 依預設會停用附註追蹤,因此註解此行會達到相同的目的。 變更之後,項目應該類似下列程式碼:

com.instana.plugin.httpd:
  tracing:
    enabled: false

如果未配置 自動重新啟動 ,您需要手動重新啟動 HTTP Server ,以從記憶體卸載「HTTPd 追蹤模組」。

版本 Binning

下載及安裝的「HTTP 追蹤」模組可以固定至特定版本。 如果註解行 pinModuleVersion: x.y.z ,則會下載並安裝現行版本的「HTTPd 追蹤模組」。

x.y.z 取代為 <agent_install_dir>/etc/instana/configuration.yaml中第 pinModuleVersion: x.y.z 行的指定模組版本。 變更之後,項目應該類似於下列 yaml 程式碼:

com.instana.plugin.httpd:
  tracing:
    enabled: true
    pinModuleVersion: 1.0.8

如果手動下載並安裝「HTTPd 追蹤模組」,則應該將 pinModuleVersion 配置的值指定為下載模組的版本。

自動重新啟動

啟用追蹤中啟用追蹤時, HTTPd 感應器會自動下載並安裝適用於 HTTP Server 設定的「HTTP 追蹤模組」。 此外,感應器可能會嘗試循序重新啟動 (apachectl -k graceful) HTTP Server。 循序重新啟動會將「HTTPd 追蹤模組」載入記憶體,而不重新啟動主要處理程序。 因此,即使處理程序在儲存器內以 PID 1 執行,它也會運作。

您可以在 <agent_install_dir>/etc/instana/configuration.yaml中配置 autoRestart 配置設定,以啟用或停用自動重新啟動。 例如,下列設定會啟用自動重新啟動:

com.instana.plugin.httpd:
  tracing:
    enabled: true
    autoRestart: true

您也可以透過 notificationScript 配置設定,變更 HTTPd 感應器嘗試重新啟動 HTTP Server 環境的方式。 此設定會採用可執行 Shell Script 的絕對路徑。 如果 HTTP Server 在儲存器內執行,則它是儲存器中的絕對路徑。 每當感應器安裝的「HTTP 追蹤」模組版本與已安裝的版本不同時,即會觸發此 Script。 當此 Script 順利配置並執行時,它會置換自動重新啟動的預設機制。

請注意,如果手動下載並安裝「HTTPd 追蹤模組」,則應該在 autoRestart 配置設定及註解 notificationScript 配置設定中停用自動重新啟動。 您需要手動重新啟動 HTTP Server ,以載入或卸載「HTTPd 追蹤模組」。

移除 HTTP 追蹤模組

在下列步驟中,可以手動移除 HTTP 追蹤模組:

  1. 在 HTTPd 配置檔的相同位置尋找 instana_tracing.conf (例如 /etc/httpd/conf/httpd.conf)。 從 instana_tracing.conf的內容取得「HTTPd 追蹤模組」的絕對路徑。 例如,檔案內容可能類似於下列程式碼:

    LoadModule dem_module /usr/lib64/httpd/modules/mod_dem_x86_64-1.0.8.so
    

    然後, HTTPd 追蹤模組位於 /usr/lib64/httpd/modules/mod_dem_x86_64-1.0.8.so

  2. 停用追蹤中停用 HTTP 追蹤。

  3. 移除相同位置 (例如, /usr/lib64/httpd/modules/tracelibrary_x86_64-1.0.8.so) 中的 HTTP 追蹤模組 mod_dem_[arch]-[version].so (例如, /usr/lib64/httpd/modules/mod_dem_x86_64-1.0.8.so) 和 tracelibrary_[arch]-[version].so