配置主機代理程式
安裝主機代理程式之後,您可以視需要配置主機代理程式。
配置 Instana 後端
Instana 主機代理程式使用 HTTP/2 通訊協定搭配 TLSv1.3 加密,連接至 Instana 後端。 連線一律以安全且加密的方式建立。 如需相關資訊,請參閱 設定代理程式端點的 TLS 加密。
<instana-agent-dir>/etc/instana/com.instana.agent.main.sender.Backend.cfg 檔包含主機代理程式用來與 Instana 後端通訊的配置。
可以使用下列環境變數來置換 <instana-agent-dir>/etc/instana/com.instana.agent.main.sender.Backend.cfg 檔案的值:
INSTANA_AGENT_ENDPOINTINSTANA_AGENT_ENDPOINT_PORTINSTANA_AGENT_KEY
配置多個後端
在某些情況下,您可能需要代理程式向多個後端報告。 例如,如果分隔環境使用共用服務,則您可以手動配置代理程式,以向這些分隔環境中的多個後端報告。
代理程式會個別計入所有後端中,因為代理程式使用的授權數目,而且設定會有效地乘以代理程式的頻寬耗用量。
若要配置主機代理程式以向多個後端報告,請遵循下列步驟:
- 將
<instana-agent-dir>/etc/instana/com.instana.agent.main.sender.Backend.cfg配置檔重新命名為<instana-agent-dir>/etc/instana/com.instana.agent.main.sender.Backend-1.cfg - 使用代理程式向其報告的各種後端的適當配置來建立
<instana-agent-dir>/etc/instana/com.instana.agent.main.sender.Backend-2.cfg配置檔的副本。
可以調整在前一個步驟中建立的每一個檔案,以說明不同的 主機代理程式端點 及 代理程式金鑰。 這些檔案甚至可以包含不同的 Proxy 設定。
附註:
您可以在配置檔中使用任何數值或英數 ID。 例如:
<instana-agent-dir>/etc/instana/com.instana.agent.main.sender.Backend-<alphanumeric>.cfg如果
<instana-agent-dir>/etc/instana/com.instana.agent.main.sender.Backend.cfg配置檔存在,則會忽略所有其他後端檔案。Instana 主機代理程式 Docker 映像檔特別配置,因此可以透過裝載後端檔案 (例如
com.instana.agent.main.sender.Backend-2.cfg) 輕鬆地新增額外後端。Docker 化代理程式的範例引數如下:
--volume <path-to-additional-backend-config>:/opt/instana/agent/etc/instana/com.instana.agent.main.sender.Backend-2.cfg
設定代理程式 Proxy
為了有效地與後端通訊, Instana 使用 HTTP/2 通訊協定來傳送資料。
在許多情況下,可以授與從主機代理程式到後端的直接通訊,以簡化代理程式的部署。
在某些情況下,需要一個進入或離開網路的專用項目。 因此,請將 Instana 與各種 Proxy 組合使用。 一般而言,支援 HTTP、HTTPS、 SOCKS4和 SOCKS5 Proxy。 Proxy 需要支援 CONNECT 方法才能通過。
附註: 不支援 Proxy 終止 SSL 連線,然後嘗試管理它自己與 Instana 後端的連線。 在沒有 ALPN的情況下使用安全 HTTP/2 。
對於主機代理程式配置,請修改下列檔案:
<instana-agent-dir>/etc/mvn-settings.xml<instana-agent-dir>/etc/instana/com.instana.agent.main.sender.Backend.cfg
在 <instana-agent-dir>/etc/mvn-settings.xml 檔案中,下列資訊必須存在,且未在 <settings></settings> 區段中註銷:
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository>data/repo</localRepository>
<servers>
<server>
<id>features</id>
<username>_</username>
<password>_</password>
</server>
<server>
<id>shared</id>
<username>_</username>
<password>_</password>
</server>
<!-- for mirrors requiring auth
<server>
<id>features-mirror</id>
<username>myuser</username>
<password>mypassword</password>
</server>
<server>
<id>shared-mirror</id>
<username>myuser</username>
<password>mypassword</password>
</server>
-->
</servers>
<!-- If you want to access the Instana repository using an HTTP/Socks proxy,
uncomment the proxies section and insert proxy details. -->
<!-- https://maven.apache.org/guides/mini/guide-proxies.html -->
<!--
<proxies>
<proxy>
<id>agent-proxy</id>
<active>true</active>
<protocol>http</protocol>
<username></username>
<password></password>
<host></host>
<port></port>
</proxy>
</proxies>
-->
<!-- If you want to use a company internal mirror, make sure that mirror is
configured to use the Instana repository, uncomment the mirrors section
and insert maven mirror details.
If the mirror also requires auth it can be added above. -->
<!-- https://maven.apache.org/guides/mini/guide-mirror-settings.html -->
<!-- Repos that need to be mirrored -->
<!-- feature: https://artifact-public.instana.io/artifactory/features-public -->
<!-- shared: https://artifact-public.instana.io/artifactory/shared -->
<!--
<mirrors>
<mirror>
<id>features-mirror</id>
<url>http://repo.mycompany.com/artifactory/instana-public</url>
<mirrorOf>features</mirrorOf>
</mirror>
<mirror>
<id>shared-mirror</id>
<url>http://repo.mycompany.com/artifactory/instana-shared</url>
<mirrorOf>shared</mirrorOf>
</mirror>
</mirrors>
-->
</settings>
Proxy 的配置會在具有 Proxy 的環境中使用 Instana 代理程式,以與 mvn-settings.xml 檔中所配置的 Maven 端點進行通訊。
此外,您需要重新配置 <instana-agent-dir>/etc/instana/com.instana.agent.main.sender.Backend.cfg 配置檔,以使用 Proxy 在代理程式與 Instana 後端之間進行通訊。
請確定下列字行存在且未註銷:
proxy.type=http
proxy.host=your-proxy-address-goes-here
proxy.port=your-proxy-port-goes-here
proxy.user=user-if-needed
proxy.password=password-if-needed
proxy.dns=true
Squid Proxy 配置範例
當沒有其他 Proxy 可用時,您可以將 squid Proxy (www.squid-cache.org) 與 Instana 組合配置。
有數種方法可以在系統上安裝 Squid 。 大部分 Linux® 發行套件在其儲存庫中包括 Squid ,並且可以使用偏好的套件管理程式來安裝軟體。
如果沒有可用的套件,或您想要在 Microsoft® Windows®上執行 Squid ,則可以從 (Squid Web Cache 文件) 取得 Squid 二進位檔。
安裝 Squid 之後,會建立範例配置 squid.conf ,且它具有預設配置。 如果您想要專門使用 Proxy 來進行 Instana 通訊,則可以備份預設配置,並使用下列 squid.conf 配置:
# The tcp port squid is listening on
http_port 3128
# Please specify subnet with instana agents
acl instana_agent_net src 10.0.0.0/8
# This is the ip of the instana backend
acl instana_backend dstdomain saas-eu-west-1.instana.io
#acl instana_backend dstdomain ec2-54-144-114-141.compute-1.amazonaws.com
#acl instana_backend dstdomain saas-us-east-1.instana.io
#acl instana_backend dstdomain saas-us-east-1.instana.io
# This is the port used by Instana
acl instana_backend_port port 443
# This is the repo to download updates and additional sensors
acl instana_repo dstdomain artifact-public.instana.io
acl instana_repo_port port 80
acl instana_repo_port_secure port 443
# Protocol used for instana backend
acl instana_backend_proto proto HTTP
# Protocol used for instana backend
acl instana_repo_proto proto HTTP
acl instana_repo_proto_secure proto HTTPS
http_access allow instana_agent_net instana_backend instana_backend_port
http_access allow instana_agent_net instana_repo instana_repo_port
http_access allow instana_agent_net instana_repo instana_repo_port_secure
# DO NOT REMOVE THIS RULE!
http_access deny all
設定代理程式端點的 TLS 加密
依預設,不會加密埠 42699 上代理程式的 HTTP 網路連線及埠 4317 上的 gRPC 連線。
您可以配置代理程式以接受 TLS 加密要求。
已啟用下列 TLS 版本: TLSv1、 TLSv1.1、 TLSv1.2及 TLSv1.3。 當代理程式本身發出安全要求 (例如當代理程式連接至外部度量資源時) 時,也會套用可用的 TLS 版本。
您可以透過在 <agent_installation>/etc/certs/ 目錄中新增憑證,在埠 42699 及 4317 上的代理程式端點上啟用 TLS 加密。 依預設,代理程式會尋找下列檔案:
<agent_installation>/etc/certs/tls.crt<agent_installation>/etc/certs/tls.key
如果 <agent_installation>/etc/certs/ 目錄只有一個檔案,則 .crt 和 .key 檔案也容許其他名稱,例如 <agent_installation>/etc/certs/<your_certificate_name>.crt 或 <agent_installation>/etc/certs/<your_key_name>.key。
新增憑證之後,請重新啟動代理程式以起始設定網路連線。
重要事項: 主機代理程式不容許 _enforcing_TLS 加密。 只有在用戶端要求時,才會在連線上啟用 TLS。
Monitoring 問題
在設定代理程式端點的 TLS 加密時,您可能會遇到下列監視問題。 這些問題顯示在 Instana 使用者介面中的代理程式儀表板內。 您需要先解決這些問題,然後再繼續進行。
監視問題類型: agent_tls_cert_expired
用來為代理程式端點設定 TLS 加密的憑證到期。 請確定您以新的憑證檔取代過期的憑證。
監視問題類型: agent_tls_cert_about_to_expire
用來為代理程式端點設定 TLS 加密的憑證將在幾天後到期。 請確定您將憑證取代為新的憑證檔。
配置主機代理程式模式
附註: 單行主機代理程式安裝 方法及 Instana 主機代理程式 Docker 映像檔 接受額外模式,即 AWS 模式。
主機代理程式的 AWS 模式不用於監視主機。 INFRASTRUCTURE 模式加上 AWS 資料收集的部分自動配置 (如 AWS 代理程式 文件中所述) 用於監視主機。
您可以透過配置 <instana-agent-dir>/etc/instana/com.instana.agent.main.config.Agent.cfg 配置檔來設定主機代理程式模式:
mode = APM
# APM, INFRASTRUCTURE or OFF
變更 <instana-agent-dir>/etc/instana/com.instana.agent.main.config.Agent.cfg 配置檔之後,您必須重新啟動主機代理程式,變更才會生效。
配置動態主機代理程式的更新
動態主機代理程式可以自行更新,從而減少管理額外負擔。 若要配置動態主機代理程式的更新 (例如配置更新間隔) ,請參閱 配置動態主機代理程式的更新。
防止代理程式模式從使用者介面置換
由於代理程式模式也可以從 Instana 使用者介面來配置,配置檔有一個旗標可用來停用這項置換。 在此情況下,只能使用配置檔或已安裝代理程式本端的環境變數來配置代理程式模式。
如果您不想從使用者介面設定代理程式模式,請將下列行新增至 <instana-agent-dir>/etc/instana/com.instana.agent.main.config.Agent.cfg 配置檔:
mode.web-override.allowed = false
使用代理程式配置檔來配置主機代理程式
大部分主機代理程式配置都是使用代理程式配置檔 (<instana-agent-dir>/etc/instana/configuration.yaml) 來套用。
透過使用代理程式配置檔,您可以達到下列目標:
- 建立多個配置檔
- 整合主機代理程式與密鑰管理程式
- 從程序環境和檔案取得配置
- 監視額外檔案系統
- 指定主機標籤
- 解壓縮已安裝的套件清單
- 設定自訂區域
- 監視自訂處理程序
- 配置密鑰
- 擷取自訂 HTTP 標頭
- 配置 Kafka 追蹤相關性標頭
- 忽略程序
- 取消啟動 Instana 使用者介面所觸發的代理程式功能
- 將程式碼原始檔上傳至 Instana
- 配置錯誤報告事件 (僅限 AIX 作業系統)
如需相關資訊,請參閱 使用代理程式配置檔來配置主機代理程式 主題。
代理程式記載
依預設, Instana 代理程式會記載至 <instana-agent-dir>/data/log/agent.log 日誌檔,如果檔案變得太大,則會輪換該日誌檔。 如果您在容器中執行代理程式,則 Instana 代理程式會改為記載至主控台,該主控台由 Docker 管理,並且可使用 Docker 日誌來存取。
透過將 <instana-agent-dir>/etc/org.ops4j.pax.logging.cfg 配置檔中的層次從 log4j2.logger.instana.level=INFO 變更為 log4j2.logger.instana.level=DEBUG,可以將記載層次增加至除錯。
重要事項: 請確定此行沒有尾端空格。
較舊的代理程式安裝需要將此行從 log4j.logger.com.instana=INFO, out, osgi:* 變更為 log4j.logger.com.instana=DEBUG, out, osgi:*
日誌旋轉
依預設,代理程式會使用 10 乘以 5 MB 代理程式日誌檔的日誌循環。 也就是說,每 5 MB 會輪換檔案,並保留 10 個檔案,然後刪除檔案 11。
log4j2.appender.rolling.policy.type = SizeBasedTriggeringPolicy
log4j2.appender.rolling.policy.size = 5MB
log4j2.appender.rolling.strategy.type = DefaultRolloverStrategy
log4j2.appender.rolling.strategy.max = 10
系統日誌
代理程式使用 Log4j2,這是現代且彈性的記載機能。 請參閱下列範例,以配置 syslog:
log4j2.rootLogger.appenderRef.Syslog.ref = Syslog
log4j2.rootLogger.appenderRef.Syslog.level = ERROR
log4j2.appender.syslog.type=Syslog
log4j2.appender.syslog.name=Syslog
log4j2.appender.syslog.layout.type=PatternLayout
log4j2.appender.syslog.layout.pattern = ${log4j2.pattern}
log4j2.appender.syslog.facility=SYSLOG
log4j2.appender.syslog.host=localhost
log4j2.appender.syslog.port=514
log4j2.appender.syslog.protocol=UDP
記載至 STDOUT
在自訂容器映像檔中,您可能想要記載至 STDOUT。 您可以透過在 <instana-agent-install-dir>etc/org.ops4j.pax.logging.cfg 配置檔中提供下列配置來執行此動作:
log4j2.rootLogger.appenderRef.Console.ref = Console
log4j2.appender.console.type = Console
log4j2.appender.console.name = Console
log4j2.appender.console.layout.type = PatternLayout
log4j2.appender.console.layout.pattern = ${log4j2.pattern}
Log4j2
由於記載會使用標準 log4j2 記載,因此可以依照 log4j2 說明文件的說明,以多種方式來配置它。
將度量或追蹤記載至檔案
代理程式可以暫時記載透過此代理程式傳送至磁碟上檔案的度量值或追蹤資料。 將度量或追蹤記載至檔案的特性通常用來除錯與度量、追蹤、追蹤或跨距相關的各種問題。
若要啟用此特性,請尋找 <instana-agent-dir>/etc/instana/com.instana.agent.main.sender.File.cfg 配置檔,並使用下列指令來更新其內容:
# Configuration of local logging. Changes will be hot-reloaded.
# Activate logging of outgoing payloads to local disk by setting a non-empty
# prefix. The log file will be written to data/log, and the file will have the
# defined prefix followed by a timestamp.
# Note: There is no automatic rotation of those files.
prefix=locallog
# The file can be filtered to either "metrics" or "traces".
# If empty or absent, there will be no filtering.
type=traces
如所指出,變更會熱重新載入,且可以立即啟動。 必須僅暫時啟用此特性,因為如果給定足夠的時間和資料流量,則保留啟用此特性可能會佔用所有可用的磁碟空間。
當您追蹤問題時,在對元件產生資料流量時,容許記載繼續進行一或兩分鐘。 然後,回復變更或註解該檔案中的所有行。 同樣地, Instana 代理程式會重新熱載入寫入磁碟的變更。
如果您正在使用支援問題單,請將產生的日誌檔附加至支援問題單。 日誌檔位於 <instana-agent-dir>/data/log/locallog_*.log 日誌檔中。
限制主機代理程式 CPU 及記憶體
在某些情況下,密切控制程序的資源耗用至關重要。 在使用資源共用的環境中,以及對於資源較少的系統,此控制特別有用。 雖然 Instana 代理程式設計為儘可能使用少量資源,但遵循這些指示可進一步限制資源,以作為遵循明確資源限制的另一項保護措施。
下列所有範例都將代理程式的 CPU 限制為計算相當於半 CPU 的資源,並限制為最多 512 MB 記憶體。 不過,並非所有資源都必須來自相同的 CPU。
系統
- 建立名為
/etc/systemd/system/instana-agent.service.d/20-resource_limits.conf的配置檔,並在其中新增下列內容:
[Service]
CPUAccounting=true
CPUQuota=50%
MemoryAccounting=true
MemoryMax=512M
- 執行
systemctl daemon-reload。 - 重新啟動
instana-agent服務。
Docker
Run the `instana-agent` container with the following extra parameters:
若為 Docker 1.13 以及更新版本:
--cpus=0.5 --memory=512m
若為 Docker 1.12 及更舊版本:
--cpu-period=100000 --cpu-quota=50000 --memory=512m
Kubernetes
將下列配置 Snippet 新增至主機代理程式的儲存器配置:
livenessProbe:
httpGet: # Agent liveness is published on localhost:42699/status
path: /status
port: 42699
initialDelaySeconds: 75
periodSeconds: 5
resources:
requests:
memory: "256Mi"
cpu: "0.5"
limits:
memory: "512Mi"
cpu: "1.0"
配置會要求 instana-agent 儲存器的較少記憶體及 CPU。