# Agent 配置文件 apiVersion: v1 kind: ConfigMap metadata: name: otel-agent-config namespace: monitoring data: config.yaml: | receivers: # 1. 采集宿主机宏观指标 hostmetrics: collection_interval: 30s root_path: /hostfs scrapers: cpu: {} memory: {} load: {} disk: {} filesystem: {} network: {} paging: {} processes: {} # 2. 采集 Pod/Container/Volume 微观指标 kubeletstats: collection_interval: 30s auth_type: "serviceAccount" endpoint: "https://${env:K8S_NODE_NAME}:10250" # 使用环境变量定位本地 Kubelet insecure_skip_verify: true metric_groups: - node - pod - container - volume processors: batch: send_batch_size: 1000 timeout: 10s resourcedetection: detectors: [env, system] # 3. 提取 K8s 详细标签,确保指标唯一性 k8sattributes: auth_type: "serviceAccount" passthrough: false extract: metadata: - k8s.pod.name - k8s.pod.uid - k8s.namespace.name - k8s.node.name - k8s.deployment.name - k8s.container.name pod_association: - sources: - from: resource_attribute name: k8s.pod.uid - sources: - from: connection exporters: # 发送给集群内的 Gateway Service otlp: endpoint: "otel-gateway.monitoring.svc.cluster.local:4317" tls: insecure: true service: pipelines: metrics: receivers: [hostmetrics, kubeletstats] processors: [resourcedetection, k8sattributes, batch] exporters: [otlp]