網站自動檢測
Instana 網站自動檢測可快速且輕鬆地啟用網站監視,方法是將 JavaScript 代理程式 自動注入具有最少配置步驟且網站沒有程式碼變更的網站。
此特性僅適用於從 HTTP 感應器 1.2.12開始的 Apache HTTP Server 。
附註: 您可以個別啟用及停用「一般使用者監視 (EUM)」及 HTTPd 追蹤,即使它們可能共用受監視技術的進行中二進位檔。 但如果啟用 EUM ,也會啟用追蹤,以保存端對端監視。
啟用網站自動檢測
若要啟用網站自動檢測,請完成下列步驟:
步驟 1: 建立網站
若要建立您要監視的網站,請完成下列步驟:
在 Instana 使用者介面中,移至 網站及行動式應用程式 ,然後按一下 新增網站。
輸入網站名稱,然後按一下 新增網站。

一切都準備好了! 視窗,寫下
reportingUrl、key及jsAgentUrl的值。 在步驟 2 中,您需要在 Instana 代理程式的<instana-agent-dir>/etc/instana/configuration.yaml配置檔中指定這些值。
步驟 2: 修改代理程式配置檔
您必須修改 Apache HTTP Server 所在 Instana 代理程式的 <instana-agent-dir>/etc/instana/configuration.yaml 檔案。 Instana 代理程式的 configuration.yaml 檔案中提供網站自動檢測的下列配置設定:
#EUM
#com.instana.plugin.eum:
# instrumentation:
# #contentTypes: # List of the 'Content-Type' values for matching requests that need to be instrumented,
# # default values in the list are 'text/html' and 'application/xhtml+xml'.
# # - 'text/html'
# # - 'application/xhtml+xml'
# #aggressive: false # Indicates whether to instrument with the EUM JavaScript agent if Instana cannot determine
# # the 'Content-Type' of the request, default is false.
# #######################################################################################################
# # Following parameters are used as common EUM monitoring configuration.
# # They can be overwritten by specifying them in the website configuration.
# #######################################################################################################
# jsAgentUrl: 'https://eum.instana.io/eum.min.js' # EUM JavaScript agent download URL.
# reportingUrl: <reportingUrl> # The URL to which to send website monitoring data to.
# trackSessions: true # Indicates whether to enable session tracking, default is true.
# #######################################################################################################
# # Following parameters are used to configure each monitored website.
# # Optional parameters are commented out by default. Remove the hashtag (#) when needed.
# #######################################################################################################
# websites:
# - name: <WEBSITE_NAME> # Name of the website for the website configuration in Instana.
# key: <WEBSITE_KEY> # Monitoring key for the website configuration in Instana.
# #enabled: true # Indicates whether to enable website monitoring on this website, default is true.
# #reportingUrl: <reportingUrl> # The URL to which to send website monitoring data to. Overwrites upper-level setting.
# #jsAgentUrl: 'https://eum.instana.io/eum.min.js' # JavaScript agent download URL. Overwrites upper-level setting.
# #trackSessions: true # Indicates whether to enable session tracking, default is true. Overwrites upper-level setting.
# #mode: 'regular' # Mode for monitoring data transmission, default is 'regular'.
# # Available mode is 'regular'.
# selector: # List of match expressions to filter requests.
# matchExpressions: # When all match expressions are evaluated to true, the request is monitored.
# # At least one match expression with the key of the 'url' catalog must be defined.
# - key: 'url/hostname' # Key specified in the <catalog>/<resource> format.
# # Available catalogs in the key include 'url' for request filtering plus
# # 'container' and 'k8s' for Web Server infrastructure filtering.
# # Available keys:
# # 'url/hostname', 'url/path', and 'url/filename'
# # 'container/name' and 'container/imagename'
# # 'k8s/namespace', 'k8s/podname', and 'k8s/containername'
# operator: 'Equals' # Match expression operators: 'Contains', 'ContainsIgnoreCase', 'Equals',
# # 'EqualsIgnoreCase', 'StartWith', and 'StartWithIgnoreCase'.
# values: # List of match expression values.
# - 'example.com'
遵循每一行的註解來配置 EUM 網站的自動檢測。 請參閱下列範例:
com.instana.plugin.eum:
instrumentation:
jsAgentUrl: 'https://eum.instana.io/eum.min.js'
reportingUrl: 'https://eum.example.com'
trackSessions: true
websites:
- name: demo
key: YOURWEBSITEKEYHERE
selector:
matchExpressions:
- key: 'url/hostname'
operator: 'Equals'
values:
- 'example.com'
在此範例中,配置會對主機名稱 example.com的所有 HTTP 要求啟用網站監視。 產生的信標會以索引鍵 YOURWEBSITEKEYHERE 在報告 URL 上 https://eum.example.com傳送至 demo 網站。
儲存已修改的 configuration.yaml 檔案之後,即會自動下載並安裝 HTTPd EUM 模組。 您可以檢查 HTTPd 配置目錄中的 instana_tracing.conf 檔案,以驗證模組。
步驟 3: 重新啟動 Web 伺服器
如果在 HTTP 追蹤中將 autoRestart 設為 true ,則您不需要手動重新啟動 Apache HTTP Server。
com.instana.plugin.httpd:
tracing:
autoRestart: true
否則,請循序重新啟動 Apache HTTP Server ,以載入 EUM 模組。
步驟 4: 在網站儀表板上驗證
請確定工作量存在於網站上,然後移至 Instana 使用者介面中的網站儀表板,以驗證是否收到監視資料。
停用網站自動檢測
若要停用網站自動檢測,請註銷或移除 configuration.yaml 檔案中 com.instana.plugin.eum 的所有行。
比對表示式範例
在多部虛擬主機上進行要求過濾的範例
下列範例顯示如何定義比對表示式,以確保當您在 Apache HTTPd 配置中具有多個 VirtualHost 時,會自動檢測網站。
例如,請參閱下列 VirtualHost 定義:
Listen 80
<VirtualHost *:80>
DocumentRoot "/www/example1"
ServerName www.example.com
# Other directives here
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/www/example2"
ServerName www.example.org
# Other directives here
</VirtualHost>
範例 1
您可以使用 url/hostname 金鑰來符合 ServerName ,如下列配置所示:
com.instana.plugin.eum:
instrumentation:
jsAgentUrl: 'https://eum.instana.io/eum.min.js'
reportingUrl: 'https://eum.example.com'
trackSessions: true
websites:
- name: 'website1'
key: 'WEBSITEKEY1'
selector:
matchExpressions:
- key: 'url/hostname'
operator: 'Equals'
values:
- 'www.example.com'
- name: 'website2'
key: 'WEBSITEKEY2'
selector:
matchExpressions:
- key: 'url/hostname'
operator: 'Equals'
values:
- 'www.example.org'
使用此配置,主機 www.example.com 的用戶端要求的 EUM 資料會顯示在 website1 的儀表板上,而主機 www.example.org 的用戶端要求的 EUM 資料會顯示在 website2的儀表板上。
範例 2
您也可以使用 url/filename 金鑰來符合 DocumentRoot ,如下列配置所示:
com.instana.plugin.eum:
instrumentation:
jsAgentUrl: 'https://eum.instana.io/eum.min.js'
reportingUrl: 'https://eum.example.com'
trackSessions: true
websites:
- name: 'website1'
key: 'WEBSITEKEY1'
selector:
matchExpressions:
- key: 'url/filename'
operator: 'StartWith'
values:
- '/www/example1'
- name: 'website2'
key: 'WEBSITEKEY2'
selector:
matchExpressions:
- key: 'url/filename'
operator: 'StartWith'
values:
- '/www/example2'
使用此配置, /www/example1 中文件的用戶端要求的 EUM 資料會顯示在 website1 的儀表板上,而 /www/example2 中文件的用戶端要求的 EUM 資料會顯示在 website2的儀表板上。
範例 3
您也可以使用 url/path 索引鍵來進一步過濾要監視的要求,如下列配置所示:
com.instana.plugin.eum:
instrumentation:
jsAgentUrl: 'https://eum.instana.io/eum.min.js'
reportingUrl: 'https://eum.example.com'
trackSessions: true
websites:
- name: 'website1'
key: 'WEBSITEKEY1'
selector:
matchExpressions:
- key: 'url/hostname'
operator: 'Equals'
values:
- 'www.example.com'
- key: 'url/path'
operator: 'StartWith'
values:
- '/products'
- '/carts'
- name: 'website3'
key: 'WEBSITEKEY3'
selector:
matchExpressions:
- key: 'url/hostname'
operator: 'Equals'
values:
- 'www.example.com'
- key: 'url/path'
operator: 'StartWith'
values:
- '/offers'
- '/employees'
- name: 'website2'
key: 'WEBSITEKEY2'
selector:
matchExpressions:
- key: 'url/filename'
operator: 'StartWith'
values:
- '/www/example2'
使用此配置,主機 www.example.com 的用戶端要求的 EUM 資料會分割成兩個網站: website1 代表 URL 開頭為 /products 或 /carts 的要求, website3 代表 URL 開頭為 /offers 或 /employees的要求。 /www/example2 中文件的用戶端要求的 EUM 資料會顯示在 website2的儀表板上。
基礎架構過濾的範例
下列範例顯示如何定義比對表示式,以確保自動檢測特定基礎架構部署上的網站。
附註: 與要求過濾不同,基礎架構過濾是選用的。
範例 1: 部署在主機上的 Containerized 網站
com.instana.plugin.eum:
instrumentation:
jsAgentUrl: 'https://eum.instana.io/eum.min.js'
reportingUrl: 'https://eum.example.com'
trackSessions: true
websites:
- name: 'containerized website'
key: 'WEBSITEKEY1'
selector:
matchExpressions:
- key: 'url/hostname'
operator: 'Equals'
values:
- 'www.example.com'
- key: 'container/name'
operator: 'Equals'
values:
- 'example-app'
使用此配置,當網站部署儲存器名稱符合 example-app時,主機 www.example.com 的用戶端要求的 EUM 資料會顯示在 containerized website 的儀表板上。
範例 2: 部署在 Kubernetes 環境中的 Containerized 網站
com.instana.plugin.eum:
instrumentation:
jsAgentUrl: 'https://eum.instana.io/eum.min.js'
reportingUrl: 'https://eum.example.com'
trackSessions: true
websites:
- name: 'k8s website'
key: 'WEBSITEKEY1'
selector:
matchExpressions:
- key: 'url/hostname'
operator: 'Equals'
values:
- 'www.example.com'
- key: 'k8s/namespace'
operator: 'Equals'
values:
- 'prod-example'
- key: 'k8s/podname'
operator: 'Equals'
values:
- 'example-pod'
- key: 'k8s/containername'
operator: 'Equals'
values:
- 'example-app'
使用此配置,當網站部署至 Kubernetes 環境中 prod-example 名稱空間之 Pod example-pod 上的容器 example-app 時,主機 www.example.com 之用戶端要求的 EUM 資料會顯示在 k8s website 儀表板上。