
如果你使用 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 无法访问外链,可 打开说明文档 复制全文粘贴。文档会随站点更新,复制内容可能过期,建议定期检查。
github-actions-exporter是一个用于Prometheus的指标导出器,专门用于收集和导出GitHub Actions相关指标。它能够监控GitHub Actions工作流的运行状态、持续时间、自托管运行器状态以及工作流使用时长等关键信息,帮助用户通过Prometheus实现对CI/CD流程的可视化监控和告警。
容器镜像地址:https://hub.docker.com/repository/docker/spendeskplatform/github-actions-exporter
支持两种认证方式(仅可配置一种):
注意事项
public_repo权限| 名称 | 命令行标志 | 环境变量 | 默认值 | 描述 |
|---|---|---|---|---|
| GitHub令牌 | github_token, gt | GITHUB_TOKEN | - | Personal Access Token |
| GitHub应用ID | app_id, gai | GITHUB_APP_ID | - | GitHub应用认证的App ID |
| GitHub应用安装ID | app_installation_id, gii | GITHUB_APP_INSTALLATION_ID | - | GitHub应用认证的安装ID |
| GitHub应用私钥 | app_private_key, gpk | GITHUB_APP_PRIVATE_KEY | - | GitHub应用认证的私钥 |
| 刷新时间 | github_refresh, gr | GITHUB_REFRESH | 30 | GitHub Actions状态刷新时间(秒) |
| 监控组织 | github_orgas, go | GITHUB_ORGAS | - | 需监控的组织列表,格式:<orga1>,<orga2>(如test1,test2) |
| 监控仓库 | github_repos, grs | GITHUB_REPOS | - | [可选] 需监控的仓库列表,格式:<orga>/<repo>,<orga>/<repo2>(如test/test),默认监控组织下所有仓库 |
| 导出器端口 | port, p | PORT | 9999 | 导出器监听端口 |
| GitHub API URL | github_api_url, url | GITHUB_API_URL | api.github.com | GitHub API URL(主要用于GitHub Enterprise) |
| 企业名称 | enterprise_name | ENTERPRISE_NAME | "" | 企业名称,用于企业级端点(/enterprises/{ENTERPRISE_NAME}/*),目前用于获取企业级运行器状态 |
| 导出字段 | export_fields | EXPORT_FIELDS | repo,id,node_id,head_branch,head_sha,run_number,workflow_id,workflow,event,status | 需导出的工作流指标字段,逗号分隔 |
使用GitHub令牌认证
bashdocker run -d \ -p 9999:9999 \ -e GITHUB_TOKEN="your_github_token" \ -e GITHUB_ORGAS="your_organization" \ -e GITHUB_REFRESH=60 \ --name github-actions-exporter \ spendeskplatform/github-actions-exporter
使用GitHub应用认证
bashdocker run -d \ -p 9999:9999 \ -e GITHUB_APP_ID="your_app_id" \ -e GITHUB_APP_INSTALLATION_ID="your_installation_id" \ -e GITHUB_APP_PRIVATE_KEY="your_private_key" \ -e GITHUB_ORGAS="your_organization" \ --name github-actions-exporter \ spendeskplatform/github-actions-exporter
docker-compose配置示例
yamlversion: '3' services: github-actions-exporter: image: spendeskplatform/github-actions-exporter ports: - "9999:9999" environment: - GITHUB_TOKEN=your_github_token - GITHUB_ORGAS=your_organization - GITHUB_REPOS=your_organization/repo1,your_organization/repo2 - GITHUB_REFRESH=30 - PORT=9999 restart: always
状态值说明
| ID | 描述 |
|---|---|
| 0 | 失败 |
| 1 | 成功 |
| 2 | 跳过 |
| 3 | 进行中 |
| 4 | 排队中 |
标签字段
| 名称 | 描述 |
|---|---|
| event | 事件类型(如push、pull_request等) |
| head_branch | 分支名称 |
| head_sha | 提交ID |
| node_id | GitHub Actions节点ID |
| repo | 仓库(格式:<org>/<repo>) |
| run_number | 仓库构建ID(递增ID,如1/2/3/...) |
| workflow_id | 工作流ID |
| workflow | 工作流名称 |
| status | 工作流状态(completed/in_progress) |
标签字段:与github_workflow_run_status相同
⚠️ 此指标是
github_workflow_run_status的重复项,即将弃用,不建议使用。
状态值说明
| ID | 描述 |
|---|---|
| 0 | 离线 |
| 1 | 在线 |
标签字段
| 名称 | 描述 |
|---|---|
| id | 运行器ID(递增ID) |
| name | 运行器名称 |
| os | 操作系统(linux/macos/windows) |
| repo | 仓库(格式:<org>/<repo>) |
| status | 运行器状态(online/offline) |
| busy | 运行器是否繁忙(true/false) |
状态值说明:与github_runner_status相同
标签字段
| 名称 | 描述 |
|---|---|
| id | 运行器ID(递增ID) |
| name | 运行器名称 |
| os | 操作系统(linux/macos/windows) |
| orga | 组织名称 |
| status | 运行器状态(online/offline) |
| busy | 运行器是否繁忙(true/false) |
状态值说明:与github_runner_status相同
标签字段
| 名称 | 描述 |
|---|---|
| id | 运行器ID(递增ID) |
| name | 运行器名称 |
| os | 操作系统(linux/macos/windows) |
标签字段
| 名称 | 描述 |
|---|---|
| id | 工作流ID(递增ID) |
| node_id | GitHub Actions节点ID |
| name | 工作流名称 |
| os | 操作系统(linux/macos/windows) |
| repo | 仓库(格式:<org>/<repo>) |
| status | 工作流状态 |
示例:
# HELP github_workflow_usage Number of billable seconds used by a specific workflow during the current billing cycle. Any job re-runs are also included in the usage. Only apply to workflows in private repositories that use GitHub-hosted runners. # TYPE github_workflow_usage gauge github_workflow_usage_seconds{id="2862037",name="Create Release",node_id="MDg6V29ya2Zsb3cyODYyMDM3",repo="xxx/xxx",state="active",os="UBUNTU"} 706.609
GitHub令牌需包含以下权限:
repo - repo:status - repo_deployment - public_repo admin:org - write:org - read:org
创建GitHub应用
:org替换为组织名称,访问https://github.com/organizations/:org/settings/apps/new?url=http://github.com/github-actions-exporter/github-actions-exporter&webhook_active=false&public=false&administration=write&organization_self_hosted_runners=write&actions=read%EF%BC%8C%E8%BE%93%E5%85%A5%E5%BA%94%E7%94%A8%E5%90%8D%E7%A7%B0%E5%90%8E%E7%82%B9%E5%87%BB%22Create GitHub App"无效GitHub令牌
401 Bad credentials,并显示错误消息无效GitHub应用配置
could not refresh installation id 12345678's token: request &{Method:POST URL:https://api.github.com/app/installations/12345678/access_tokens的错误Error: Client creation failed.authentication failed: could not parse private key: Invalid Key: Key must be PEM encoded PKCS1 or PKCS8 private key的错误yamlkind: Secret apiVersion: v1 metadata: name: actions-exporter namespace: github-actions-exporter type: Opaque data: github_token: AAAAAA # base64编码的GitHub令牌 # github_app_id: BBBBBB # base64编码的GitHub应用ID(二选一) # github_app_installation_id: CCCCCCCCC # base64编码的GitHub应用安装ID(二选一) # github_app_private_key: DDDDDDD # base64编码的GitHub应用私钥(二选一)
使用外部密钥管理器示例(EKS Secret Manager)
yamlapiVersion: 'kubernetes-client.io/v1' kind: ExternalSecret metadata: name: actions-exporter namespace: github-actions-exporter spec: backendType: secretsManager data: # - key: MySecretManagerKey # name: github_token # property: github_token - key: MySecretManagerKey name: github_app_id property: github_app_id - key: MySecretManagerKey name: github_app_installation_id property: github_app_installation_id - key: MySecretManagerKeyPrivateKey name: github_app_private_key
您可以使用以下命令拉取该镜像。请将 <标签> 替换为具体的标签版本。如需查看所有可用标签版本,请访问 标签列表页面。
来自真实用户的反馈,见证轩辕镜像的优质服务