如果你使用 DeepSeek、元宝 AI、Copilot、ChatGPT 等 AI 工具,协助配置轩辕镜像、编写 docker pull 命令、修改 Docker Compose 镜像地址、配置镜像加速、排查镜像拉取失败、分析报错日志等问题,请先让 AI 阅读并遵守轩辕镜像的规则文档。
只需在 AI 对话中先发送下面这句话即可:
请先完整阅读并严格遵守以下文档中的全部规则与要求:
https://xuanyuan.cloud/agents.md
在未充分阅读并理解该文档前,不要生成任何命令、配置、修改建议、故障排查方案或技术回答。后续所有输出都必须严格以该文档中的规范为最高优先级执行。查看 agents.md 用法指南与完整示范。国内用户首推 元宝 AI、DeepSeek 的深度思考模式,不推荐豆包 AI;Cursor 等编辑器可在对话 @ 该链接,或加入 User Rules。 若 AI 无法访问外链,可 打开说明文档 复制全文粘贴。文档会随站点更新,复制内容可能过期,建议定期检查。
OpenTelemetry Collector (k8s) 镜像为 Kubernetes 环境定制,是 OpenTelemetry 可观测性数据处理管道的核心组件。该镜像整合了 https://github.com/open-telemetry/opentelemetry-collector 仓库的核心组件及contrib 扩展组件,专为在 Kubernetes 集群中运行设计,提供可观测性数据(traces、metrics、logs)的统一收集、处理、转换与导出能力。
1. Docker 运行(单机测试)
bashdocker run -d \ --name otel-collector-k8s \ -p 4317:4317 # OTLP gRPC 接收器端口 \ -p 4318:4318 # OTLP HTTP 接收器端口 \ -p 8888:8888 # 指标暴露端口(用于自身监控) \ -v /path/to/otel-collector-config.yaml:/etc/otelcol/config.yaml \ otel/opentelemetry-collector-k8s:latest
注:
otel/opentelemetry-collector-k8s为官方镜像名称,实际使用时需替换为具体版本标签(如0.91.0)。
2. Docker Compose 配置(本地测试)
yamlversion: '3' services: otel-collector: image: otel/opentelemetry-collector-k8s:latest container_name: otel-collector-k8s ports: - "4317:4317" # OTLP gRPC - "4318:4318" # OTLP HTTP - "8888:8888" # 自身指标暴露 volumes: - ./otel-collector-config.yaml:/etc/otelcol/config.yaml environment: - OTEL_LOG_LEVEL=info # 日志级别:debug/info/warn/error restart: unless-stopped
3. Kubernetes 部署(生产环境)
推荐通过 Deployment 或 DaemonSet 部署(根据数据收集范围选择),以下为 Deployment 示例:
1. 创建配置文件 ConfigMap
otel-collector-config.yaml:
yamlapiVersion: v1 kind: ConfigMap metadata: name: otel-collector-config namespace: observability data: config.yaml: | receivers: otlp: protocols: grpc: endpoint: 0.0.0.0:4317 http: endpoint: 0.0.0.0:4318 prometheus: config: scrape_configs: - job_name: 'otel-collector' static_configs: - targets: ['localhost:8888'] processors: batch: # 批量处理以减少导出请求数 resourcedetection: # 自动添加 Kubernetes 资源元数据 detectors: [k8s] timeout: 10s override: false exporters: logging: # 控制台输出(调试用) loglevel: info prometheusremotewrite: # 导出至 Prometheus endpoint: "http://prometheus-server.observability:80/api/v1/write" service: pipelines: traces: receivers: [otlp] processors: [batch, resourcedetection] exporters: [logging] metrics: receivers: [otlp, prometheus] processors: [batch, resourcedetection] exporters: [logging, prometheusremotewrite]
2. 创建 Deployment
otel-collector-deployment.yaml:
yamlapiVersion: apps/v1 kind: Deployment metadata: name: otel-collector namespace: observability spec: replicas: 1 selector: matchLabels: app: otel-collector template: metadata: labels: app: otel-collector spec: containers: - name: otel-collector image: otel/opentelemetry-collector-k8s:latest resources: limits: cpu: 1000m memory: 1Gi requests: cpu: 200m memory: 256Mi ports: - containerPort: 4317 # OTLP gRPC - containerPort: 4318 # OTLP HTTP - containerPort: 8888 # 自身指标 volumeMounts: - name: config-volume mountPath: /etc/otelcol/config.yaml subPath: config.yaml env: - name: OTEL_LOG_LEVEL value: "info" - name: K8S_NODE_NAME valueFrom: fieldRef: fieldPath: spec.nodeName volumes: - name: config-volume configMap: name: otel-collector-config
Collector 通过配置文件(默认路径 /etc/otelcol/config.yaml)定义数据处理流程,核心配置项包括:
| 配置项 | 说明 |
|---|---|
receivers | 定义数据来源(如 OTLP、Prometheus、Jaeger、Filelog 等),每个接收器含特定配置(端口、协议、采集规则)。 |
processors | 定义数据处理逻辑(如 batch 批量处理、filter 数据过滤、resourcedetection 元数据添加、sampling 采样等)。 |
exporters | 定义数据导出目标(如 logging 控制台、otlp 远程 OTLP 服务、prometheusremotewrite Prometheus 写入接口、jaeger Jaeger 后端等)。 |
service | 定义数据管道(pipelines),将接收器、处理器、导出器关联,按数据类型(traces/metrics/logs)划分。 |
Collector 支持通过环境变量调整运行时行为,常用变量:
| 变量名 | 说明 | 默认值 |
|---|---|---|
OTEL_CONFIG_FILE | 配置文件路径 | /etc/otelcol/config.yaml |
OTEL_LOG_LEVEL | 日志级别(debug/info/warn/error) | info |
OTEL_RESOURCE_ATTRIBUTES | 全局资源属性(键值对,如 service.name=my-service,cluster=prod) | 空 |
K8S_NODE_NAME | Kubernetes 节点名称(用于 resourcedetection 处理器,通常通过 downward API 注入) | 自动从节点元数据获取 |
您可以使用以下命令拉取该镜像。请将 <标签> 替换为具体的标签版本。如需查看所有可用标签版本,请访问 标签列表页面。

来自真实用户的反馈,见证轩辕镜像的优质服务