
tryretool/telemetry本镜像为自托管部署场景提供遥测数据收集能力,旨在帮助用户监控私有环境中应用及系统的运行状态。通过轻量级部署方式,实现对系统指标、应用日志、事件数据的采集、初步处理与转发,支持对接多种监控后端,为自托管环境提供可观测性基础。
bashdocker run -d \ --name telemetry-collector \ --restart unless-stopped \ -p 9090:9090 \ # 数据接收端口(如Prometheus指标暴露) -v /path/to/config.yaml:/app/config.yaml \ # 挂载自定义配置文件 -v /var/log:/host/log:ro \ # 只读挂载主机日志目录(如需收集主机日志) -e BACKEND_TYPE=prometheus \ # 目标后端类型 -e BACKEND_URL=[***] \ # 后端服务地址 -e COLLECTION_INTERVAL=10s \ # 数据采集间隔 telemetry-collector:latest
yamlversion: '3.8' services: telemetry-collector: image: telemetry-collector:latest container_name: telemetry-collector restart: unless-stopped ports: - "9090:9090" volumes: - ./config.yaml:/app/config.yaml - /var/log:/host/log:ro - /proc:/host/proc:ro # 挂载主机proc文件系统(用于系统指标采集) environment: - BACKEND_TYPE=influxdb - BACKEND_URL=[***] - BACKEND_USER=admin - BACKEND_PASSWORD=secret - COLLECTION_INTERVAL=5s - LOG_LEVEL=info depends_on: - influxdb # 假设依赖InfluxDB后端 influxdb: image: influxdb:2.7 container_name: influxdb restart: unless-stopped environment: - DOCKER_INFLUXDB_INIT_MODE=setup - DOCKER_INFLUXDB_INIT_USERNAME=admin - DOCKER_INFLUXDB_INIT_PASSWORD=secret - DOCKER_INFLUXDB_INIT_ORG=my-org - DOCKER_INFLUXDB_INIT_BUCKET=telemetry ports: - "8086:8086"
| 环境变量名 | 描述 | 默认值 | 可选值 |
|---|---|---|---|
BACKEND_TYPE | 目标数据后端类型 | prometheus | prometheus, influxdb, http |
BACKEND_URL | 后端服务地址 | http://localhost:9090 | - |
BACKEND_USER | 后端认证用户名(如需要) | - | - |
BACKEND_PASSWORD | 后端认证密码(如需要) | - | - |
COLLECTION_INTERVAL | 数据采集间隔 | 10s | 支持s(秒)、m(分)单位 |
LOG_LEVEL | 日志输出级别 | info | debug, info, warn, error |
MAX_CACHE_SIZE | 本地数据缓存最大值(MB) | 100 | - |
DATA_RETENTION | 本地缓存数据保留时间 | 24h | - |
通过挂载config.yaml可实现更细粒度配置(优先级高于环境变量),示例配置:
yaml# 数据采集配置 collection: interval: 10s sources: system: # 系统指标采集 enabled: true metrics: [cpu, memory, disk, network] logs: # 日志采集 enabled: true paths: - /host/log/nginx/access.log - /host/log/app/*.log parser: regex # 日志解析方式:regex/json pattern: '^(\S+) \- \[(\S+)\] "(\S+) (\S+) (\S+)" (\d+) (\d+)$' # 自定义正则表达式 custom: # 自定义HTTP指标采集 enabled: true endpoints: - url: [***] method: GET interval: 30s # 数据处理配置 processing: filters: - type: exclude # 排除规则 field: log_level value: debug aggregations: - metric: http_requests_total function: sum window: 5m # 数据传输配置 backend: type: influxdb url: [***] auth: username: admin password: secret timeout: 10s retry: max_attempts: 3 delay: 5s
ro(只读)模式,避免容器对主机文件系统造成意外修改MAX_CACHE_SIZE与COLLECTION_INTERVAL,平衡性能与数据完整性manifest unknown 错误
TLS 证书验证失败
DNS 解析超时
410 错误:版本过低
402 错误:流量耗尽
身份认证失败错误
429 限流错误
凭证保存错误
来自真实用户的反馈,见证轩辕镜像的优质服务