
如果你使用 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 无法访问外链,可 打开说明文档 复制全文粘贴。文档会随站点更新,复制内容可能过期,建议定期检查。
xunit-metrics-exporter是一个用于将xunit XML测试报告文件转换为Prometheus可采集指标的工具。它能够扫描指定目录下的xunit XML文件,解析测试结果(如成功、失败、跳过的测试用例数量)和持续时间,并以Prometheus兼容的格式暴露指标,方便集成到监控系统中。
需要准备规则文件(默认路径为./rules.json,可通过环境变量RULES_FILE_PATH指定其他路径),用于定义xunit文件扫描规则。
规则文件为JSON数组,每个元素包含以下字段:
glob:字符串,指定xunit XML文件的路径模式(支持通配符)filePathReplacers:数组,每个元素为包含两个字符串的数组,用于替换文件路径中的特定字符串(格式:[["需要替换的字符串", "替换后的字符串"]])示例规则文件:
json[ { "glob": "./results/*.xml", "filePathReplacers": [["cypress/integration/", ""]] } ]
使用docker-compose部署
创建docker-compose.yml文件:
yamlversion: "2.0" services: xunit-metrics-exporter: image: dracoblue/xunit-metrics-exporter environment: - "RULES_FILE_PATH=/usr/src/app/rules.json" # 指定规则文件路径 volumes: - ./results:/usr/src/app/results # 挂载包含xunit XML文件的目录 - ./rules.json:/usr/src/app/rules.json # 挂载规则文件 ports: - "9442:9442" # 暴露指标端口
准备测试文件
results文件夹,并添加测试XML文件(如results/test.xml),内容示例:xml<?xml version="1.0" encoding="UTF-8"?> <testsuites name="Mocha Tests" time="1.6930" tests="6" failures="1"> <testsuite name="Root Suite" timestamp="2021-08-18T11:06:04" tests="0" file="cypress/integration/1-getting-started/todo.spec.js" time="0.0000" failures="0"> </testsuite> <testsuite name="example to-do app" timestamp="2021-08-18T11:06:04" tests="3" time="0.7480" failures="1"> <testcase name="example to-do app displays two todo items by default" time="0.0000" classname="displays two todo items by default"> <failure message="Timed out retrying after 4000ms: expected '<li>' to have text 'Walk the dog2', but the text was 'Walk the dog'" type="AssertionError"><![CDATA[AssertionError: Timed out retrying after 4000ms: expected '<li>' to have text 'Walk the dog2', but the text was 'Walk the dog' at Context.eval (https://example.cypress.io/__cypress/tests?p=cypress/integration/1-getting-started/todo.spec.js:128:36)]]></failure> </testcase> <testcase name="example to-do app can add new todo items" time="0.4830" classname="can add new todo items"> </testcase> <testcase name="example to-do app can check off an item as completed" time="0.2650" classname="can check off an item as completed"> </testcase> </testsuite> <testsuite name="with a checked task" timestamp="2021-08-18T11:06:12" tests="3" time="0.9450" failures="0"> <testcase name="example to-do app with a checked task can filter for uncompleted tasks" time="0.3060" classname="can filter for uncompleted tasks"> </testcase> <testcase name="example to-do app with a checked task can filter for completed tasks" time="0.3420" classname="can filter for completed tasks"> </testcase> <testcase name="example to-do app with a checked task can delete all completed tasks" time="0.2970" classname="can delete all completed tasks"> </testcase> </testsuite> </testsuites>
rules.json文件,内容示例:json[ { "glob": "/usr/src/app/results/*.xml", "filePathReplacers": [["cypress/integration/", ""]] } ]
启动服务
执行以下命令启动服务:
bashdocker-compose up -d
访问指标
Prometheus指标可通过http://localhost:9442访问,示例输出:
text# HELP xunit_suite xunit result # TYPE xunit_suite gauge # HELP xunit_duration_seconds xunit duration # TYPE xunit_duration_seconds gauge xunit_suite{name="example to-do app",file_name="todo.spec.js",folder_name="1-getting-started",result="failure"} 1 xunit_duration_seconds{name="example to-do app",file_name="todo.spec.js",folder_name="1-getting-started",result="failure"} 0.748 xunit_suite{name="with a checked task",file_name="todo.spec.js",folder_name="1-getting-started",result="success"} 0 xunit_duration_seconds{name="with a checked task",file_name="todo.spec.js",folder_name="1-getting-started",result="success"} 0.945 # HELP xunit_failed_total xunit failed tests # TYPE xunit_failed_total gauge xunit_failed_total 1 # HELP xunit_successful_total xunit successful tests # TYPE xunit_successful_total gauge xunit_successful_total 5 # HELP xunit_skipped_total xunit skipped tests # TYPE xunit_skipped_total gauge xunit_skipped_total 0 # HELP xunit_duration_seconds_total xunit total duration # TYPE xunit_duration_seconds_total gauge xunit_duration_seconds_total 1.693
本项目由DracoBlue([***]
您可以使用以下命令拉取该镜像。请将 <标签> 替换为具体的标签版本。如需查看所有可用标签版本,请访问 标签列表页面。



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