配置 AutoTrace 网络钩子
您可以根据具体需求配置 Instana AutoTrace 的 webhook。 请参阅以下可用配置选项列表:
固定 AutoTrace Webhook 版本
从 AutoTrace 开始 Webhook 版本 1.295.7
在 Webhook 版本 1.295.7 中,引入了一个新标志,用于锁定 AutoTrace Webhook 版本。 如有必要,您可以使用 标志 --set global.version=<version> 来手动指定 AutoTrace webhook部署的版本。 有关所有 Instana AutoTrace Webhook 版本的更多信息,请参阅 Instana autotrace Webhook。
此前,图像版本通过SHA哈希值进行固定,这使得跨多个图像识别和对齐版本变得困难。 从 webhook 1.295.7 开始,您可以通过设置 标志 global.version ,使用单个版本值同时控制两张图片。 该标志默认已设置。 当设置时, global.version 该选项优先于并覆盖在 webhook.image 和 中定义的任何版本 autotrace.instrumentation.image或 SHA。 如果 未设置 global.version ,则使用 在 webhook.imageautotrace.instrumentation.image 或 中定义的值。
AutoTrace 发布前 Webhook 版本 1.295.7
在 1.295.7 版本之前,可通过为 webhook 和监控镜像设置各自的镜像标志,来固定 AutoTrace Webhook 版本在图表中的显示。 例如,如果要锁定的版本是 1.294.0 ,可以使用这两个标志来实现 --set webhook.image="containers.instana.io/instana/release/agent/instana-autotrace-webhook:1.294.0" --set autotrace.instrumentation.image="icr.io/instana/instrumentation:1.294.0"。 此方法已弃用,应改用 flag global.version 。
禁用追踪器
您可以禁用以下跟踪器:
- .NET Core (netcore)
- Python (Python)
- Node.js (Node.js)
- Ruby (ruby)
如果启用了 .NET Core 跟踪,请勿禁用其他跟踪器( Python、 Node.js 和 Ruby )。 禁用这些跟踪器可能会影响 .NET Core 的跟踪功能。
要单独禁用对特定技术的追踪,请在 AutoTrace webhook安装命令中添加如下 --set autotrace.<technology>.enabled=false 示例所示的行。 用您想要禁用跟踪 <technology> 的技术替换。
helm install --create-namespace --namespace instana-autotrace-webhook instana-autotrace-webhook \
--repo https://agents.instana.io/helm instana-autotrace-webhook \
--set webhook.imagePullCredentials.password=<download_key> \
--set autotrace.ruby.enabled=false \
配置基于角色的访问控制
要将 AutoTrace webhook 部署到由 保护 ClusterRole 且匹配 的 ClusterRoleBinding中 ServiceAccount ,请在部署 Helm 图表时设置 标志 rbac.enabled=true 。
除了基于角色的访问控制外,若使用 pod 安全策略, rbac.psp.enabled=true 请在 ` Helm ` 参数中添加 `--add-pod-security-policy=`。
您还可以通过内置的 Pod 安全准入控制器强制执行 Pod 安全标准。 有关 Pod 安全准入的更多信息,请参阅 Kubernetes 文档。
若在 Helm 安装中设置 rbac.enabled=falsewebhook.pod.hostNetwork=false 标志和,可通过以下命令以严格的Pod安全标准运行 AutoTrace webhook:
kubectl label --overwrite ns instana-autotrace-webhook pod-security.kubernetes.io/enforce=restricted
设置容器端口
您必须将 AutoTrace Webhook Pod 部署在主机网络上,并进行正确配置,以确保 Kubernetes API 服务器能够访问它(apiserver)。
默认情况下,容器绑定到端口 42650。
如果端口 42650 已被占用, AutoTrace webhook 将崩溃。 为避免此问题,可通过修改 属性 webhook.pod.port 来更改端口。
选择加入或退出仪器监测
AutoTrace 网页钩子监控所有 pod 中的所有容器。
然而,您可以对哪些资源被监控拥有更多控制权。 要指定仅对选定的资源进行监控,请在部署 Helm 时首先添加该 autotrace.opt_in=true 参数。
然后,通过在所需的 Pod、副本集、有状态集、守护进程集和部署中添加标签 instana-autotrace: "true" ,指定必须进行监控的资源。 AutoTrace webhook 使用此标签来识别所需资源并对其进行变异。 此外,您还可以在命名空间级别设置标签,该命名空间内的所有资源都将被纳入监控范围。
autotrace.opt_in的值为何,该webhook都不会修改命名空间内带有` instana-autotrace: "false" `标签的Pod或资源。该 instana-autotrace: "false" 标签在 DaemonSets, 部署、 DeploymentConfigs,、 ReplicaSets,、 StatefulSets, 以及命名空间的元数据中均被遵循,包括嵌套的Pod模板和独立的Pod中。
忽略命名空间
您可以通过配置 autotrace.exclude.namespaces 来排除整个命名空间,使其不被自动注入。
instana-autotrace: "true" 的资源将被纳入监控,无论是否存在命名空间排除规则。该 instana-autotrace 标签在 DaemonSets, 部署、 DeploymentConfigs,、 ReplicaSets, 和 StatefulSets, 的元数据中均被遵循,包括嵌套Pod模板和独立Pod中。
忽略资源
您可以通过添加标签 instana-autotrace: "false" 来将特定资源排除在自动监控之外。 AutoTrace 无论其他设置如何,webhook都会忽略带有此标签的资源。
该 instana-autotrace 标签在 DaemonSets, 部署、 DeploymentConfigs,、 ReplicaSets, 和 StatefulSets, 的元数据中均被遵循,包括嵌套Pod模板和独立Pod中。
更高层级的资源变异
从 1.304.6 开始, Instana 的 AutoTrace webhook 默认仅修改 pod 和 ConfigMaps。 这使得更新和卸载变得更容易。 当新的Webhook Pod运行时,更高层级的资源可被重启,从而触发新Pod的创建,这些Pod将被新监控镜像进行变异处理。
若需恢复直接修改更高层级资源(部署、守护进程集、副本集、有状态集和部署配置)的旧行为,可通过启用 `--enable-mutate-higher-level-resources` autotrace.enableHigherLevelResourceMutation=true 标志实现:
helm install --create-namespace --namespace instana-autotrace-webhook instana-autotrace-webhook \
--repo https://agents.instana.io/helm instana-autotrace-webhook \
--set webhook.imagePullCredentials.password=<download_key> \
--set autotrace.enableHigherLevelResourceMutation=true
为 NGINX 和ingress-nginx启用webhook监控功能
要启用 NGINX 和ingress-nginx的自动监控功能,您必须通过设置标签来选择 autotrace.ingress_nginx.enabled=true加入。
在继续操作前,请参阅 《 AutoTrace Webhook 故障排除指南 》,并确保相关对象已更新或重新创建。
AutoTrace 网页钩子支持 ingress-nginx Kubernetes 入站控制器 0.34.1 或更高版本, 提供 45 天的支持策略,并与 Helm 图表 2.11.2 或更高版本兼容。
要将 Instana AutoTrace 的 webhook 与 NGINX 进行配置,请运行以下命令:
helm install --create-namespace --namespace instana-autotrace-webhook \
--repo https://agents.instana.io/helm instana-autotrace-webhook instana-autotrace-webhook \
--set webhook.imagePullCredentials.password=<download-key> \
--set autotrace.ingress_nginx.enabled=true
对于常规版或独立版 NGINX ,您需要手动添加其 nginx_status 安装路径。 不过,对于 ingress-nginx,该 nginx_status location 会由 AutoTrace webhook 自动添加。
要对 Ingress NGINX 进行监控,必须进行部署并修改 ConfigMap 文件。 因此,请在安装 Ingress NGINX 之前,先安装 Instana AutoTrace 的 webhook。 如果已安装 Ingress NGINX ,请执行以下步骤:
若要删除现有部署并创建新部署,同时不影响服务,请运行以下命令:
kubectl get deploy ingress-nginx-deployment -o yaml > your_deployment_backup.yaml # Back up your deployment configkubectl delete deploy your_deployment_name --cascade=orphan # Delete the existing deployment, cascade option ensures that pods are not deleted.kubectl apply -f your_deployment_backup.yaml # Re-apply the deployment config要替换 ConfigMap, ,请运行以下命令:
kubectl get cm ingress-nginx-configmap -o yaml > your_configmap_backup.yaml # Back-up your configmapkubectl replace --force -f your_configmap_backup.yaml # replace the configmap to trigger mutation webhook API
NGINX 服务器监控
要全面监控 NGINX 服务器, Instana 需要启用 NGINX 状态端点。 AutoTrace 的 webhook 会根据 NGINX 的部署类型以不同的方式处理此情况:
- NGINX Ingress 控制器 :当 autotrace.ingress_nginx.enabled 参数设置为
true时, AutoTrace webhook 会自动配置状态端点。 - 独立部署的 NGINX :您必须在 NGINX 配置文件中手动配置该
nginx_status位置。 - NGINX 此外 :与独立版 NGINX 一样,状态端点需要手动配置。
有关手动启用 NGINX 状态端点以及全面监控 NGINX 服务器的详细说明(包括指标收集和分布式追踪配置),请参阅 《监控 NGINX 》。
Instana AutoTrace Webhook 不支持在独立版 NGINX 中使用 ConfigMap。 如需更多信息,请参阅《 监控 NGINX 》。
为 IBM MQ 和ACE (已弃用) 启用Webhook监控
- Instana IBM MQ 对 Autotrace webhook 的支持已弃用。 自 2027 年 5 月 31 日起, Instana 将正式停止支持,并宣布该功能终止生命周期(EOL)。 此功能已被 IBM MQ 运算符取代
- Instana IBM ACE 对 Autotrace webhook 的支持已弃用。 自 2027 年 5 月 31 日起, Instana 将正式终止支持,并宣布该功能达到生命周期终止(EOL),此举与 IBM ACE 11 的产品生命周期i 保持一致,该产品自 2026 年 4 月 30 日起已结束扩展支持。 如需了解更多信息,请参阅 “已弃用的功能”。
要激活 IBM MQ 和ACE自动仪器化功能,您必须通过设置标签 autotrace.ibmmq.enable=true 和来选择 autotrace.ace.enable=true加入。 AutoTrace Webhook 仅支持在 IBM Cloud Pak for Integration 中运行的 IBM MQ 和 ACE。
由于 IBM Cloud Pak for Integration 在 Red Hat OpenShift 集群上运行,您还必须在部署 Helm 时 openshift.enabled=true 设置。
要设置启用了 IBM MQ 和 ACE 自动配置功能的 Instana AutoTrace webhook,请输入以下命令:
helm install --create-namespace --namespace instana-autotrace-webhook instana-autotrace-webhook \
--repo https://agents.instana.io/helm instana-autotrace-webhook \
--set webhook.imagePullCredentials.password=<download_key> \
--set openshift.enabled=true \
--set autotrace.ibmmq.enabled=true \
--set autotrace.ace.enabled=true
Node.js ECMAScript 模块
如果您的应用程序使用了ECMAScript模块,请使用该 autotrace.nodejs.application_type 设置。 为确保您使用的是 AutoTrace 网络钩子的最新版本,请参阅 《更新 AutoTrace 网络钩子 》。
设置
autotrace.nodejs.application_type为module_v2( Node.js 版本 18.19 及更高版本):helm install --create-namespace --namespace instana-autotrace-webhook instana-autotrace-webhook \ --repo https://agents.instana.io/helm instana-autotrace-webhook \ --set webhook.imagePullCredentials.password=<download_key> \ --set autotrace.nodejs.application_type=module_v2注:- 该
module_v1选项已弃用。 - 仅当
module_v1满足以下条件时autotrace.nodejs.application_type设置:- 您的应用程序运行在早于 18.19.0 的 Node.js 版本上。
- 您使用的是 AutoTrace webhook 或更早版本。
- 该
module_v1选项在当前版本中已不再支持,并将在下次升级时被移除。 更多详情请参阅 “重大变更 ”部分。
- 该
要恢复默认行为或完全移除该配置选项,请将 设置
autotrace.nodejs.application_type为commonjs:helm install --create-namespace --namespace instana-autotrace-webhook instana-autotrace-webhook \ --repo https://agents.instana.io/helm instana-autotrace-webhook \ --set webhook.imagePullCredentials.password=<download_key> \ --set autotrace.nodejs.application_type=commonjs
最小化所需的临时存储空间
该webhook会修改部署并添加 initContainer。 initContainer 会获取包含所有受支持技术( Node.js、.NET Core、 Ruby、 Python 以及 NGINX )的仪器配置文件的镜像,并将这些文件复制到卷中。 这些文件存储在 emptyDir 卷下 instana-instrumentation-volume ,位于卷挂载点处 path /opt/instana/instrumentation/。 emptyDir 卷存储在节点的本地文件系统中,因此这些监控文件会增加 Pod 的临时存储使用量。 仪器文件的总大小约为300 MB。 请参阅下表了解每种技术的存储要求:
| 技术 | 存储需求 |
|---|---|
| libinstana_初始化 | 5M - 所有技术均需具备 |
| IBM MQ | 17M |
| Ruby | 151M |
| IBM App Connect Enterprise | 9M |
| .NET Core | 4M |
| NGINX | 66M |
| Node.js | 32M |
| Python | 20M |
在某些情况下,您的集群可能仅使用特定技术。 为优化性能,可限制安装过程中复制的文件数量,从而减少临时存储空间并提升 initContainer 的运行速度。 请按以下步骤操作,将文件范围限定为所需技术:
确定集群中使用的技术。 在此示例中,选中了 Node.js 和 .NET Core。
通过显式启用使用 Helm 图表标志的必要技术来配置 webhook 安装。 语法如下所示:
--set autotrace.instrumentation.manual.<technology>=true用以下任一
<techonology>选项替换:- nodejs
- 网核
- Python
- ruby
- nginx
例如,要同时启用 Node.js 和 .NET Core ,请使用以下标志:
--set autotrace.instrumentation.manual.nodejs=true --set autotrace.instrumentation.manual.netcore=true成功安装 helm 图表后,请务必重新创建部署,以便新配置对集群工作负载生效。
有关环境变量或 Helm 图表标志的更多信息,请参阅 Helm 值。