
如果你使用 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 无法访问外链,可 打开说明文档 复制全文粘贴。文档会随站点更新,复制内容可能过期,建议定期检查。
Categraf 企业版是一款高性能、多用途的监控数据采集器,专为企业级监控场景设计。该 Docker 镜像封装了 Categraf 企业版核心组件,提供了便捷的部署方式,适用于各类云环境、容器平台及物理机环境。
主要用途包括:
使用默认配置启动容器:
bashdocker run -d --name categraf-enterprise \ --net=host \ --restart=always \ registry.example.com/categraf-enterprise:latest
注意:
--net=host模式用于让容器直接使用主机网络,便于采集主机指标,非必需,根据实际需求选择。
推荐使用外部配置文件进行自定义配置:
bashdocker run -d --name categraf-enterprise \ --restart=always \ -v /path/to/conf:/etc/categraf \ -v /path/to/data:/var/lib/categraf \ registry.example.com/categraf-enterprise:latest
配置文件目录结构:
/path/to/conf/ ├── categraf.conf # 主配置文件 ├── conf.d/ # 插件配置目录 │ ├── cpu.conf │ ├── mem.conf │ ├── disk.conf │ └── ... └── enterprise.conf # 企业版专属配置
支持通过环境变量调整核心配置:
| 环境变量 | 描述 | 默认值 |
|---|---|---|
CATEGRAF_LOG_LEVEL | 日志级别 (debug, info, warn, error) | info |
CATEGRAF_HTTP_LISTEN | HTTP 服务监听地址 | 0.0.0.0:9273 |
CATEGRAF_METRICS_INTERVAL | 默认指标采集间隔 | 15s |
CATEGRAF_TENANT_ID | 企业版多租户ID | default |
CATEGRAF_CLUSTER_NAME | 集群名称标识 | default-cluster |
CATEGRAF_ENTERPRISE_LICENSE | 企业版授权证书内容 | 无 |
CATEGRAF_OUTPUT_PROMETHEUS_REMOTE_WRITE_URL | Prometheus 远程写入地址 | 无 |
CATEGRAF_OUTPUT_INFLUXDB_URL | InfluxDB 服务地址 | 无 |
支持通过命令行参数覆盖配置:
bashdocker run -d --name categraf-enterprise \ registry.example.com/categraf-enterprise:latest \ --log.level=debug \ --configs.dir=/etc/categraf/conf.d \ --enterprise.license=/etc/categraf/license.key
常用命令行参数:
--config: 指定主配置文件路径--configs.dir: 指定插件配置目录--test: 测试配置有效性--dry-run: 模拟运行,不实际采集数据--version: 显示版本信息--help: 显示帮助信息1. 基础监控(主机网络模式)
bashdocker run -d --name categraf-enterprise \ --net=host \ --pid=host \ --restart=always \ -v /:/rootfs:ro \ -v /var/run:/var/run:ro \ -v /sys:/sys:ro \ -v /proc:/proc:ro \ -v /path/to/conf:/etc/categraf \ -e CATEGRAF_LOG_LEVEL=info \ -e CATEGRAF_OUTPUT_PROMETHEUS_REMOTE_WRITE_URL="http://prometheus:9090/api/v1/write" \ registry.example.com/categraf-enterprise:latest
2. 容器监控(非主机网络模式)
bashdocker run -d --name categraf-enterprise \ --restart=always \ -v /var/run/docker.sock:/var/run/docker.sock:ro \ -v /path/to/conf:/etc/categraf \ -e CATEGRAF_LOG_LEVEL=info \ -e CATEGRAF_CLUSTER_NAME="prod-cluster" \ -p 9273:9273 \ registry.example.com/categraf-enterprise:latest \ --configs.dir=/etc/categraf/conf.d
yamlversion: '3.8' services: categraf: image: registry.example.com/categraf-enterprise:latest container_name: categraf-enterprise restart: always network_mode: "host" pid: "host" volumes: - /:/rootfs:ro - /var/run:/var/run:ro - /sys:/sys:ro - /proc:/proc:ro - ./conf:/etc/categraf - ./data:/var/lib/categraf - ./license:/etc/categraf/license environment: - CATEGRAF_LOG_LEVEL=info - CATEGRAF_TENANT_ID=company-a - CATEGRAF_CLUSTER_NAME=prod-k8s-cluster - CATEGRAF_METRICS_INTERVAL=10s - CATEGRAF_OUTPUT_PROMETHEUS_REMOTE_WRITE_URL="http://prometheus:9090/api/v1/write" command: - --config=/etc/categraf/categraf.conf - --enterprise.license=/etc/categraf/license/enterprise.lic
Categraf 企业版提供丰富的插件,可通过配置文件启用和定制:
bash# 进入容器查看插件列表 docker exec -it categraf-enterprise categraf --list-plugins # 查看特定插件帮助 docker exec -it categraf-enterprise categraf --plugin-help cpu
常用插件配置示例(在 conf.d/ 目录下创建对应配置文件):
toml[[instances]] percpu = true totalcpu = true collect_cpu_time = false report_active = false core_tags = false
toml[[instances]] mount_points = ["/"] ignore_fs = ["tmpfs", "devtmpfs", "devfs", "overlay", "aufs", "squashfs"] fs_types = []
toml[[instances]] address = "sqlserver://username:password@localhost:1433?database=master" interval = "30s" collection_query_files = ["/etc/categraf/enterprise/queries/mssql"] tls_skip_verify = false timeout = "10s" [instances.tags] service = "mssql" env = "production"
支持多种数据输出目标,配置示例:
toml[[outputs.prometheus_remote_write]] url = "http://prometheus:9090/api/v1/write" basic_auth_user = "user" basic_auth_pass = "pass" timeout = "10s" interval = "15s" version = "v2" send_batches = true batch_size = 10000 [outputs.prometheus_remote_write.headers] X-Scope-OrgID = "company-a"
toml[[outputs.enterprise_tsdb]] url = "https://tsdb.example.com:8443/write" token = "${ENTERPRISE_TSDB_TOKEN}" tls_ca_file = "/etc/categraf/certs/ca.pem" tls_cert_file = "/etc/categraf/certs/client.pem" tls_key_file = "/etc/categraf/certs/client-key.pem" timeout = "20s" retry_interval = "30s" max_retry_times = 3 [outputs.enterprise_tsdb.tags] cluster = "${CATEGRAF_CLUSTER_NAME}" region = "cn-north-1"
toml[enterprise.tenant] id = "${CATEGRAF_TENANT_ID}" [enterprise.tenant.labels] department = "IT" business_unit = "operations"
toml[enterprise.sampling] [enterprise.sampling.rules] [[enterprise.sampling.rules.rule]] metric_name = "http_requests_total" rate = 0.5 [enterprise.sampling.rules.rule.labels] service = "api-server" [[enterprise.sampling.rules.rule]] metric_name = "db_query_duration_seconds" rate = 0.1 [enterprise.sampling.rules.rule.labels] db_type = "mysql"
bashdocker logs -f categraf-enterprise # 查看特定时间段日志 docker logs --since 30m categraf-enterprise
bash# 拉取新版本镜像 docker pull registry.example.com/categraf-enterprise:latest # 停止并删除当前容器 docker stop categraf-enterprise && docker rm categraf-enterprise # 使用新镜像启动 docker run -d --name categraf-enterprise [原有参数] registry.example.com/categraf-enterprise:latest
bash# 容器内健康检查 docker exec -it categraf-enterprise curl -f http://localhost:9273/health || echo "Unhealthy" # 或通过 Docker 健康检查机制(在 docker run 时添加 --health-cmd 参数)
A: 请联系 *** 获取企业版授权及报价信息。
A: 1. 检查日志确认是否有错误信息;2. 验证授权是否有效;3. 检查输出目标配置是否正确;4. 确认插件是否正确启用。
A: Categraf 支持配置文件的动态 reload,修改配置后可通过 docker kill -SIGHUP categraf-enterprise 发送重载信号。
A: 是的,企业版提供专用的 Helm Chart,支持在 Kubernetes 环境中大规模部署和管理。
您可以使用以下命令拉取该镜像。请将 <标签> 替换为具体的标签版本。如需查看所有可用标签版本,请访问 标签列表页面。
来自真实用户的反馈,见证轩辕镜像的优质服务