Ingress监控
听云支持对 NGINX Ingress Controller 、 Apache APISIX Ingress Controller 和 Kong Ingress Controller 的监控
当Ingress嵌入探针后,经过Ingress的请求的事务名称只能按照URL进行命名,且不支持获取用户溯源的数据。
Kubernetes UniAgent 2.5.3.1及以上版本支持通过Ingress探针自动对html页面嵌入JS探针,采集Web前端性能数据。
开启流程为在 "用户体验" -> "Web" -> "应用" 页面点击 "添加应用" 按钮,录入页面应用名称,嵌码方式选择 "APM注入", 选择Ingress对应的后端应用,点击启用即可。
在以下场景,无法嵌入JS探针:
非浏览器发起的请求,例如Curl、Wget等工具发起的请求,上游应用利用HttpClient发起的请求
Upstream响应的Content-Encoding为gzip等压缩格式时
Upstream响应的Content-Type不是text/html格式时
响应状态码不为200时
JS可嵌码位置超过64K时
NGINX Ingress Controller 监控
兼容性要求
- Kubernetes UniAgent:AMD64的探针需要2.4.2.0及以上版本,ARM64的探针需要2.5.0.0及以上版本
- Kubernetes集群版本:1.16~1.29
- ingress-nginx-controller版本: v0.40.0 ~ v1.10.1
嵌码步骤
Step 1:对namespace ingress-nginx打标签
kubectl label namespace ingress-nginx tingyun-injection=enabled
或编辑ingress-nginx对应的yaml:找到name为ingress-nginx的namespace,在metadata.labels 内增加 tingyun-injection: enabled
。
apiVersion: v1
kind: Namespace
metadata:
labels:
app.kubernetes.io/instance: ingress-nginx
app.kubernetes.io/name: ingress-nginx
tingyun-injection: enabled #增加此行
name: ingress-nginx
Step 2:对deployment ingress-nginx-controller打标签
编辑ingress-nginx对应的yaml:找到name为ingress-nginx-controller的deployment,在spec.template.metadata.labels 增加 tingyun-agent-injected: "true"
和 tingyun-ingress-nginx: "true"
。
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app.kubernetes.io/component: controller
app.kubernetes.io/instance: ingress-nginx
app.kubernetes.io/name: ingress-nginx
app.kubernetes.io/part-of: ingress-nginx
app.kubernetes.io/version: 1.8.0
name: ingress-nginx-controller
namespace: ingress-nginx
spec:
minReadySeconds: 0
revisionHistoryLimit: 10
selector:
matchLabels:
app.kubernetes.io/component: controller
app.kubernetes.io/instance: ingress-nginx
app.kubernetes.io/name: ingress-nginx
template:
metadata:
labels:
app.kubernetes.io/component: controller
app.kubernetes.io/instance: ingress-nginx
app.kubernetes.io/name: ingress-nginx
app.kubernetes.io/part-of: ingress-nginx
app.kubernetes.io/version: 1.8.0
tingyun-agent-injected: "true" #增加此行
tingyun-ingress-nginx: "true" #增加此行
spec:
containers:
- args:
- /nginx-ingress-controller
Step 3:重启ingress-nginx-controller Pod
kubectl apply -f ingress-nginx对应的yaml
验证
访问Ingress,查看是否嵌入了基调听云探针,describe内容应该包括基调听云探针镜像。
kubectl -n ingress-nginx describe pod ingress-nginx-controller-5b486bcc4b-bsgcw | grep tingyun
进入ingress-nginx-controller:
kubectl -n ingress-nginx exec -it ingress-nginx-controller-5b486bcc4b-bsgcw -- bash
以下均在ingress-nginx-controller Pod内执行:
查看pod内进程列表,应该包含transagent进程:
ps -ef
查看初始化日志:
cat /opt/tingyun-oneagent/logs/agent/ingress-init.log
查看探针日志:
cat /opt/tingyun-oneagent/logs/agent/nginx.log
cat /opt/tingyun-oneagent/logs/agent/daemon.log
Apache APISIX Ingress Controller 监控
兼容性要求
- Kubernetes UniAgent:AMD64的探针需要2.4.2.0及以上版本,ARM64的探针需要2.5.0.0及以上版本
- Kubernetes集群版本:1.16~1.29
- apisix-ingress-controller版本 v1.0.0 - v1.8.2
嵌码步骤
Step 1:对namespace ingress-apisix打标签
kubectl label namespace ingress-apisix tingyun-injection=enabled
Step 2:对deployment apisix打标签
kubectl -n ingress-apisix edit deployment.apps/apisix
在spec.template.metadata.labels 增加 tingyun-agent-injected: "true"
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
meta.helm.sh/release-name: apisix
meta.helm.sh/release-namespace: ingress-apisix
labels:
app.kubernetes.io/name: apisix
helm.sh/chart: apisix-2.2.0
name: apisix
namespace: ingress-apisix
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/instance: apisix
app.kubernetes.io/name: apisix
template:
metadata:
labels:
app.kubernetes.io/instance: apisix
app.kubernetes.io/name: apisix
tingyun-agent-injected: "true" #增加此行
验证
访问Ingress,查看是否嵌入了基调听云探针,describe内容应该包括基调听云探针镜像。
kubectl -n ingress-apisix describe pod apisix-556b6fddd8-hqnmc | grep tingyun
进入apisix:
kubectl -n ingress-apisix exec -it apisix-556b6fddd8-hqnmc -- bash
以下在apisix Pod内执行:
查看探针日志:
cat /opt/tingyun-oneagent/logs/agent/nginx.log
cat /opt/tingyun-oneagent/logs/agent/daemon.log
Kong Ingress Controller 监控
兼容性要求
- Kubernetes UniAgent:AMD64的探针需要2.4.2.0及以上版本,ARM64的探针需要2.5.0.0及以上版本
- Kubernetes集群版本:1.16~1.29
- Kong Ingress Controller 版本 v2.0.0 - v2.12.0
嵌码步骤
Step 1:对namespace kong打标签
kubectl label namespace kong tingyun-injection=enabled
Step 2:对deployment apisix打标签
kubectl -n kong edit deployment.apps/ingress-kong
在spec.template.metadata.labels 增加 tingyun-agent-injected: "true"
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: ingress-kong
name: ingress-kong
namespace: kong
spec:
replicas: 1
selector:
matchLabels:
app: ingress-kong
template:
metadata:
annotations:
kuma.io/gateway: enabled
kuma.io/service-account-token-volume: kong-serviceaccount-token
traffic.sidecar.istio.io/includeInboundPorts: ""
labels:
app: ingress-kong
tingyun-agent-injected: "true" #增加此行
验证
访问Ingress,查看是否嵌入了基调听云探针,describe内容应该包括基调听云探针镜像。
kubectl -n kong describe pod ingress-kong-6d448686f-vjbwv | grep tingyun
进入ingress-kong:
kubectl -n kong exec -it ingress-kong-6d448686f-vjbwv -- bash
以下在ingress-kong Pod内执行:
查看探针日志:
cat /opt/tingyun-oneagent/logs/agent/nginx.log
cat /opt/tingyun-oneagent/logs/agent/daemon.log