
如果你使用 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 无法访问外链,可 打开说明文档 复制全文粘贴。文档会随站点更新,复制内容可能过期,建议定期检查。
gitlab-ci-pipelines-exporter 允许您通过 https://prometheus.io/ 或任何支持 https://github.com/OpenObservability/OpenMetrics 格式的监控工具,监控您的 https://docs.gitlab.com/ee/ci/pipelines.html%E3%80%82%E6%9C%89%E5%85%B3%E5%85%B6%E5%A6%82%E4%BD%95%E5%B8%AE%E5%8A%A9%E6%8F%90%E5%8D%87%E6%B5%81%E6%B0%B4%E7%BA%BF%E6%95%88%E7%8E%87%E7%9A%84%E6%9B%B4%E5%A4%9A%E4%BF%A1%E6%81%AF%EF%BC%8C%E5%8F%AF%E5%8F%82%E8%80%83 https://docs.gitlab.com/ee/ci/pipelines/pipeline_efficiency.html#pipeline-monitoring%E3%80%82
该工具可导出 GitLab CI 流水线的关键指标(如运行状态、持续时间、成功率等),支持与 Grafana 集成以实现可视化监控。提供多种预配置的 Grafana 仪表盘,覆盖流水线、作业、环境/部署等维度的监控需求。
流水线监控
!https://grafana.com/grafana/dashboards/***
Grafana 仪表盘 https://grafana.com/grafana/dashboards/***
作业监控
!https://grafana.com/grafana/dashboards/***
Grafana 仪表盘 https://grafana.com/grafana/dashboards/***
环境/部署监控
!https://grafana.com/grafana/dashboards/***
Grafana 仪表盘 https://grafana.com/grafana/dashboards/***
如需快速体验,可参考 https://github.com/mvisonneau/gitlab-ci-pipelines-exporter/tree/main/examples/quickstart 目录,通过 docker-compose 在约5分钟内部署包含 exporter、Prometheus 和 Grafana 的测试环境。
基础运行
bash# 直接运行(需后续通过配置文件或环境变量指定 GitLab 信息) docker run -it --rm mvisonneau/gitlab-ci-pipelines-exporter
挂载配置文件运行
config.yml:yamlgitlab: url: https://gitlab.example.com # GitLab 实例 URL token: <your_private_token> # GitLab 访问令牌(需有 api 权限) projects: - name: foo/project # 需监控的项目(格式:<namespace>/<project>) - name: bar/project wildcards: - owner: # 通配符匹配(批量监控群组/用户下的项目) name: foo # 群组/用户名 kind: group # 类型:group 或 user
bashdocker run -it --rm \ --name gitlab-ci-pipelines-exporter \ -v $(pwd)/config.yml:/etc/config.yml \ # 挂载配置文件 -p 8080:8080 \ # 暴露指标端口(默认 8080) mvisonneau/gitlab-ci-pipelines-exporter:latest \ --config /etc/config.yml # 指定配置文件路径
docker-compose 部署(含 Prometheus 和 Grafana)
参考以下 docker-compose.yml 配置(完整示例见 https://github.com/mvisonneau/gitlab-ci-pipelines-exporter/tree/main/examples/quickstart%EF%BC%89%EF%BC%9A
yamlversion: '3' services: exporter: image: mvisonneau/gitlab-ci-pipelines-exporter:latest volumes: - ./config.yml:/etc/config.yml ports: - "8080:8080" command: --config /etc/config.yml prometheus: image: prom/prometheus:latest volumes: - ./prometheus.yml:/etc/prometheus/prometheus.yml ports: - "9090:9090" depends_on: - exporter grafana: image: grafana/grafana:latest ports: - "3000:3000" depends_on: - prometheus
启动服务:
bashdocker-compose up -d
访问 http://localhost:8080/metrics 即可查看导出的指标,通过 Grafana 导入仪表盘(ID:、、***)可可视化监控数据。
配置文件语法
完整配置语法见 https://github.com/mvisonneau/gitlab-ci-pipelines-exporter/blob/main/docs/configuration_syntax.md%EF%BC%8C%E6%A0%B8%E5%BF%83%E5%8F%82%E6%95%B0%E8%AF%B4%E6%98%8E%EF%BC%9A
| 参数路径 | 说明 |
|---|---|
gitlab.url | GitLab 实例 URL(默认:[***] |
gitlab.token | GitLab 私有令牌(优先级:命令行参数 > 环境变量 > 配置文件) |
projects | 需监控的项目列表(name 为必填,支持 refs 指定分支/标签,variables 指定变量) |
wildcards | 通配符配置,通过 owner.name 和 owner.kind(group/user)批量匹配项目 |
server.webhook | Webhook 配置(enabled: true 开启,secret_token 用于验证 GitLab 请求) |
redis.url | Redis URL(用于 HA 部署,格式:redis://[:password@]host:port[/db]) |
环境变量与命令行参数
| 环境变量 | 命令行参数 | 说明 |
|---|---|---|
GCPE_CONFIG | --config, -c | 配置文件路径(默认:~/.gitlab-ci-pipelines-exporter.yml) |
GCPE_GITLAB_TOKEN | --gitlab-token | GitLab 访问令牌(覆盖配置文件中的 gitlab.token) |
GCPE_REDIS_URL | --redis-url | Redis URL(用于 HA 部署) |
GCPE_LOG_LEVEL | --log-level | 日志级别(debug/info/warn/fatal/panic,默认:info) |
通过 Redis 实现多实例共享存储,分摊 GitLab API 调用压力,确保指标一致性:
--redis-url/GCPE_REDIS_URL):yaml# config.yml 中添加 redis: url: redis://redis-host:6379/0 # Redis 实例 URL
启用 Webhook 接收 GitLab 流水线事件,减少轮询频率:
yamlserver: webhook: enabled: true secret_token: <your_webhook_secret> # 需与 GitLab Webhook 配置中的 "Secret token" 一致
http://exporter-ip:8080/webhooksecret_tokenbashdocker run -it --rm mvisonneau/gitlab-ci-pipelines-exporter --help
输出:
NAME: gitlab-ci-pipelines-exporter - 导出 GitLab CI 流水线状态指标 USAGE: gitlab-ci-pipelines-exporter [全局选项] 命令 [命令选项] [参数...] COMMANDS: help, h 显示命令列表或单个命令帮助 GLOBAL OPTIONS: --config file, -c file 配置文件路径(默认:"~/.gitlab-ci-pipelines-exporter.yml") [$GCPE_CONFIG] --redis-url url Redis URL(用于 HA 部署) [$GCPE_REDIS_URL] --gitlab-token token GitLab API 访问令牌(覆盖配置文件) [$GCPE_GITLAB_TOKEN] --webhook-secret-token token Webhook 验证令牌(覆盖配置文件) [$GCPE_WEBHOOK_SECRET_TOKEN] --log-level level 日志级别(debug,info,warn,fatal,panic)(默认:"info") [$GCPE_LOG_LEVEL] --log-format format 日志格式(json,text)(默认:"text") [$GCPE_LOG_FORMAT] --help, -h 显示帮助(默认:false)
您可以使用以下命令拉取该镜像。请将 <标签> 替换为具体的标签版本。如需查看所有可用标签版本,请访问 标签列表页面。
来自真实用户的反馈,见证轩辕镜像的优质服务