You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

寻求AKS中以Sidecar方式部署OTEL Agent的相关文档

AKS中OTEL Agent Sidecar部署及日志转发配置指南

一、Sidecar模式核心部署步骤

在AKS中给应用添加OTEL Agent Sidecar,直接在应用的Pod模板中新增Agent容器即可,核心配置要点如下:

  • 容器镜像选择:使用OpenTelemetry官方的Collector镜像(如otel/opentelemetry-collector-contrib:0.93.0,建议指定稳定版本而非latest)
  • 日志卷挂载:将应用容器的日志存储目录挂载到Sidecar容器中,确保Agent能读取应用日志。比如应用容器将日志写到/var/log/app-logs,则在Sidecar容器中同样挂载该路径
  • 配置文件挂载:通过ConfigMap挂载OTEL Agent的配置文件,定义日志接收、处理和转发规则

二、日志转发流程配置

针对你描述的「Sidecar Agent → 集群级Collector → 网关Agent → Splunk Observability」流程,各环节配置要点如下:

1. Sidecar Agent配置

在Agent的配置文件中定义:

  • 接收器(Receiver):启用filelog接收器,指定监听的日志文件路径(比如/var/log/app-logs/*.log),可配置日志解析规则(如JSON、正则)
  • 处理器(Processor):添加batch处理器批量发送日志,memory_limiter防止内存溢出,attributes处理器补充AKS集群、Pod、命名空间等元数据
  • 输出器(Exporter):启用otlp输出器,指定集群级OTEL Collector的Service地址(如http://otel-collector.cluster-otel.svc.cluster.local:4318,根据实际命名空间调整)

2. 集群级OTEL Collector配置

集群级Collector需要:

  • 启用otlp接收器,接收Sidecar Agent发来的日志数据
  • 配置转发到网关Agent的otlp输出器,指定网关的地址
  • 若需要直接转发到Splunk,可启用splunk_hec输出器,配置Splunk Observability的HEC端点和token

3. 示例Pod配置片段

apiVersion: v1
kind: Pod
metadata:
  name: my-app-with-otel-sidecar
  namespace: default
spec:
  containers:
  - name: my-app
    image: my-app-image:latest
    volumeMounts:
    - name: app-logs
      mountPath: /var/log/app-logs
  - name: otel-agent
    image: otel/opentelemetry-collector-contrib:0.93.0
    volumeMounts:
    - name: app-logs
      mountPath: /var/log/app-logs
    - name: otel-agent-config
      mountPath: /etc/otel/
  volumes:
  - name: app-logs
    emptyDir: {}
  - name: otel-agent-config
    configMap:
      name: otel-agent-sidecar-config

4. 示例OTEL Agent ConfigMap配置

apiVersion: v1
kind: ConfigMap
metadata:
  name: otel-agent-sidecar-config
data:
  config.yaml: |
    receivers:
      filelog:
        include: [/var/log/app-logs/*.log]
        start_at: beginning
        operators:
          - type: json_parser
            timestamp:
              parse_from: attributes.time
              layout: '%Y-%m-%dT%H:%M:%S%z'
    processors:
      batch:
      memory_limiter:
        check_interval: 1s
        limit_mib: 100
        spike_limit_mib: 50
      attributes:
        actions:
          - key: k8s.cluster.name
            value: "my-aks-cluster"
            action: insert
          - key: k8s.namespace.name
            from_attribute: k8s.namespace.name
            action: insert
    exporters:
      otlp:
        endpoint: "otel-collector.cluster-otel.svc.cluster.local:4318"
        tls:
          insecure: true
    service:
      pipelines:
        logs:
          receivers: [filelog]
          processors: [memory_limiter, batch, attributes]
          exporters: [otlp]

三、关键注意事项

  • 权限配置:确保Sidecar Agent容器对挂载的日志目录有读取权限,必要时可通过ServiceAccount赋予view级别的集群权限,以获取Pod元数据
  • 版本兼容:确认AKS集群版本(如1.27+)与OTEL组件版本兼容,避免API或功能不匹配问题
  • 监控调试:可通过kubectl logs <pod-name> otel-agent查看Agent日志,排查日志收集或转发故障

内容的提问来源于stack exchange,提问作者ramesh reddy

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.11 22:33:10