Monitoring PHP
Instana 提供 PHP 應用程式環境的綜合性監視,提供系統的端對端可見性。 安裝 Instana 主機代理程式之後,代理程式會自動在 PHP 環境中部署 PHP 感應器及追蹤器。 您可以在 Instana 使用者介面中,檢視 PHP 環境中所有要求的基礎架構度量及端對端追蹤。
支援的資訊
支援的作業系統
PHP 感應器僅在 Linux 作業系統上受支援。 如需此支援的相關資訊,請參閱 支援的 PHP 版本中表格的 CPU 架構直欄。
支援的 PHP 版本
Instana 支援下列 PHP 版本的度量及配置資料:
| PHP 版本 | CPU 架構 | 支援的 Zend 執行緒安全 (ZTS) | 支援的類型 |
|---|---|---|---|
| PHP 5.3 -PHP 8.2 | x86_64 | ZTS 和非 ZTS | 全球接受 (GA) |
| PHP 7.2-PHP 8.1 | aarch64 | ZTS 和非 ZTS | GA 版 |
PHP 追蹤器 2.0
若要在 PHP 追蹤期間加強 Instana 代理程式的效能,請使用 Instana PHP Tracer 2.0。 如需相關資訊,請參閱 啟用 Instana PHP 追蹤器 2.0。
對於 PHP Tracer 2.0,支援下列 PHP 版本:
| PHP 版本 | CPU 架構 | 支援的 Zend 執行緒安全 (ZTS) | 支援的類型 |
|---|---|---|---|
| PHP 7.0-PHP 8.2 | X86 | 非 ZTS | GA 版 |
支援的 PHP SAPI
Instana 支援下列 PHP 伺服器應用程式設計介面 (SAPI) 來進行配置資料、度量及追蹤:
| SAPI | 支援的類型 |
|---|---|
| PHP-FPM | GA 版 |
| PHP-CGI | GA 版 |
| 含 mod_php 的 Apache | GA 版 |
| CLI | 實驗 |
如果您使用旗標 instana.enable_cli = 1來配置追蹤延伸, Instana 可以提供 CLI 的追蹤。 不過,因為 CLI 要求通常持續時間較短, Instana 無法將它們連接至動態圖形。 因此,您可以查看追蹤,但無法取得已連接服務或基礎架構的任何相關資訊。 此外,您必須安裝追蹤延伸。 如需設定 CLI 追蹤的支援,請聯絡 IBM 支援中心。
限制
Instana 不支援下列 PHP 配置:
- 在 Windows 系統上使用 PHP
- 使用 Apache HTTP Server ,其配置為提供含執行緒 MPM「工作者」或「事件」及 PHP ZTS 的 PHP 內容
- 使用多個追蹤工具 (例如 Instana 和協力廠商追蹤程式) ,例如 New Relic、Otel、Dynatrace 或 Datadog ,同時使用 PHP
配置 PHP 感應器
安裝 Instana 代理程式之後, PHP 感應器會自動安裝並配置合理的預設值。 通常,您不需要在 Instana 代理程式的 configuration.yaml 檔案中修改這些設定: <agent_install_dir>/etc/instana/configuration.yaml。
下列 YAML Snippet 顯示可用的設定:
# PHP Tracing
#com.instana.plugin.php:
# # Lightweight PHP Tracing. Requires the Instana Tracing extension. Enabled by default.
# tracing:
# # Enabling tracing will automatically download the Instana Tracing
# # extension and enable it in your php.ini. If you are using preforked
# # PHP workers, like PHP-FPM, you will need to restart them. Disabling
# # tracing again will not remove the extension. It will only disable the
# # tracing sensor.
# enabled: true
# # Whether to install the PHP Tracing extension. Default is true. Disabling
# # the installation will still create the TraceAcceptor daemon though.
# installExtension: true
# # The filename to use when querying Apache or PHP-CGI installations for
# # environment data such as version, architecture, etc. By default, this
# # is "instana." + Math.random(). + ".php". Uncommenting the setting
# # as follows will force a static filename instead.
# phpInfoFilename: instana.php
# # Pins the PHP Tracing extension to download and install to a specific
# # version. This can be used to rollback to previous versions of the
# # extension or to test beta versions (when asked to do so). Expects
# # the version to be given as major.minory.patch, e.g. 0.3.7
# pinExtensionVersion: x.y.z
# # The absolute path to the script to trigger whenever the sensor installed
# # a different version of the PHP tracing extension than is currently
# # installed. Works for upgrades and downgrades. Default is empty.
# notificationScript: /path/to/restart_php.sh
# # The number of executor threads to use for processing traces. This setting
# # can be used to fine tune the PHP sensor for specific load environments.
# # Defaults to the number of available logical processors or 8 (whichever is less).
# # In general, you don't need to touch this setting unless advised to do so.
# executorThreads: n
# # The maximum number of traces the sensor is allowed to keep in the backlog
# # for processing. Can be used in conjunction with executorThreads to fine tune
# # the sensor for specific load environments. In general, you don't need to touch
# # this setting unless advised to do so. Defaults to 1000.
# executorQueueLimit: 1000
# # Port on which the sensor is listening for traces. Changing this setting will
# # not automatically update any .ini files created for the PHP Tracing extension.
# # In general, you don't need to touch this setting unless advised to do so.
# # Defaults to port 16816.
# port: 16816
# # Whether to remove values in SQL queries to prevent sensitive data from
# # reaching our backend. This can help to improve agent performance in certain
# # setups. In general, you don't need to touch this setting unless advised to do so.
# sanitizeSql: true
啟用 PHP 8.2 支援
若要啟用 PHP 8.2 支援,請使用下列配置:
# PHP Tracing
com.instana.plugin.php:
tracing:
enabled: true
pinExtensionVersion: 1.20.0
針對監視 PHP 8.2報告一些次要問題。 如果您遇到任何問題,請與 IBM 支援中心開啟一個案例。
啟用自動重新啟動
您可以透過 notificationScript 配置設定,變更 PHP 感應器嘗試重新啟動 PHP 環境的方式。 如需如何使用 notificationScript 設定的相關資訊,請參閱 自動重新啟動 一節。
啟用 PHP-FPM 狀態頁面
若要徹底監視 PHP-FPM 度量,您需要啟用狀態頁面。 若要啟用頁面,請開啟工作者節點儲存區配置檔,並新增項目 pm.status_path = /status。 Instana PHP-FPM 感應器會直接存取端點,以透過 FastCGI存取 PHP-FPM 狀態頁面。
啟用 Apache
Apache 配置必須包含下列行:
SetHandler application/x-httpd-php
沒有線路,感應器無法載入,且會記載下列錯誤訊息:
> "PHP Sensor is failing because of "NO Version found"
檢視度量值
若要檢視 PHP 的度量值,請完成下列步驟:
- 在 Instana 使用者介面的資訊看板中,選取 基礎架構。
- 按一下特定的受監視主機。
您可以查看包含所有已收集度量及受監視處理程序的主機儀表板。
如同任何其他 Instana 感應器, PHP 感應器不需要任何配置。 它會自動偵測 PHP 安裝,並從安裝中收集下列資料:
對於 PHP ,配置資料、效能度量及性能簽章取決於所使用的 SAPI。 如需相關資訊,請參閱 支援的 PHP SAPI。
配置資料和度量
下表列出一般追蹤的配置資料:
- PHP 版本
- 伺服器 API
- Zend 執行緒安全
- 已載入模組
- 主要 INI 檔案
- Ini 目錄
- 已剖析的其他 INI 檔案
- PHP 延伸目錄
附註: Apache 儀表板中包括 Apache 與 mod_php 的一般追蹤配置。 若為 PHP-CGI ,此配置資料包含在已使用的 Web 伺服器儀表板中 (如果適用的話)。
除了一般追蹤的配置之外, PHP-FPM 儀表板還包含下列配置資料:
- 主要程序 ID
- 主要配置
- 工作者儲存區
PHP-FPM 儀表板也包括下列度量:
- 連線
- 程序
- 資源
性能簽章
每一個感應器都有經過策劃的性能簽章知識庫,可根據送入的度量來持續評估。 這些性能簽章用來提出取決於使用者影響的問題或發生事件。
內建事件 會根據實體上失敗的性能簽章來觸發問題或突發事件,而 自訂事件 會根據任何特定實體的個別度量值臨界值來觸發問題或突發事件。
如需 PHP-FPM 的建置事件相關資訊,請參閱 內建事件參照。
追蹤
Instana 提供 PHP 的自動及手動設備測試。
自動檢測
Instana 會自動指示 PHP 應用程式。 若要指示 PHP 應用程式, Instana 代理程式需要 PHP 追蹤延伸。
PHP 追蹤延伸
啟用 PHP 感應器時,會自動下載 PHP 追蹤延伸。 配置位於 <agent_install_dir>/etc/instana/configuration.yaml ,且 Instana 代理程式的現行版本包含所需配置設定的範例。
依預設, PHP 追蹤處於作用中。 如需停用追蹤的相關資訊,請參閱 停用 PHP 追蹤感應器。 PHP 感應器會鏈結至 PHP SAPI 感應器。 因此,只有在 Instana 代理程式偵測到支援的 SAPI 感應器 (目前是 PHP-FPM、mod_php 和 php-cgi) 時,才會啟動追蹤。 如需相關資訊,請參閱 支援的 PHP SAPI 感應器。
PHP 感應器會收集 SAPI 配置的相關資訊,並根據您的 PHP 版本和主機架構來下載適當的 Instana 延伸。 PHP 感應器一律會下載 Instana 延伸的最新版本。 不過,您也可以在 configuration.yaml 檔中設定 pinExtensionVersion: x.y.z ,以固定 (強制) 特定版本。
如需 PHP 追蹤延伸及下列設定的相關資訊,請參閱 PHP 追蹤延伸:
- 必要的 PHP 延伸
- 自訂 PHP 延伸設定
- 可用的旗標
- 解除安裝 Instana PHP 追蹤延伸
- 自動重新啟動
追蹤
Instana 會在 PHP 引擎層次對 PHP 應用程式進行指示,並針對選取的函數呼叫提供下列追蹤資料:
HTTP
- cURL
fastcgi_finish_request- HTTP 串流
- 階段作業
架構
- Wordpress
- Laravel
- Symfony
- Zend 架構
資料庫
- AMQP (pecl-amqp) -AMQP (php-amqp-lib)
- Cassandra
- Couchbase
- Elasticsearch
- Google Cloud Pub/Sub
- IBM Db2
- LDAP
- MEMCACHE
- Memcached
- MongoDB
- MySQL
- mysqli
- OCI8
- CUBRID (PDO)
- MS SQL Server (PDO)
- 火鳥 (PDO)
- IBM (PDO)
- Informix (PDO)
- MySQL (PDO)
- MS SQL Server (PDO)
- Oracle (PDO)
- ODBC 和 Db2 (PDO)
- PostgreSQL (PDO)
- SQLite (PDO)
- PostgreSQL (PDO , not ext-pgsql)
- Redis (透過 predis 或 PECL redis)
記載
- Drupal 日誌程式
- Kohana 日誌程式
- Magento 日誌程式
- 莫諾洛格
- Yii 日誌程式
- Zend_Log
範本
- Twig
- 刀鋒伺服器
其他
- Shell 呼叫
- 編譯時間
- OpCache 度量
附註: 只有 PHP 5.4 以及更新版本才支援跨距詳細資料中的堆疊追蹤。
手動檢測
您也可以透過追蹤 SDK 來手動檢測 PHP 程式碼。 透過使用追蹤 SDK ,您可以將追蹤資料新增至 Instana 自動收集的追蹤資料。
PHP-SDK
PHP 追蹤延伸隨附最小 SDK。 透過使用此 SDK ,您可以手動檢測程式碼。 如需相關資訊,請參閱 PHP-SDK。
與 OpenTracing
Instana 提供個別 PHP SDK ,可使用 OpenTracing進行追蹤。 與 Instana 自己的 PHP 檢測不同, OpenTracing SDK 需要您手動檢測程式碼。 透過 PHP OpenTracing SDK 產生的追蹤資料與 Instana 自己的追蹤所產生的追蹤資料是分開的。
服務命名
如需服務命名的相關資訊,請參閱 廣域設定服務名稱。
「PHP 追蹤器」會在 PHP 的 $_SERVER 和 $_ENV 陣列中搜尋索引鍵 INSTANA_SERVICE_NAME ,並使用索引鍵值作為服務名稱。
設定程序名稱
您可以使用環境變數 INSTANA_PROCESS_NAME ,為代表 PHP 程序的基礎架構實體設定自訂標籤。