
如果你使用 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 无法访问外链,可 打开说明文档 复制全文粘贴。文档会随站点更新,复制内容可能过期,建议定期检查。
A lightweight HTTP-layer fault injection proxy. Intercepts traffic and injects configurable faults based on rules — useful for testing service resilience in development and CI/CD.
Key differentiator from Toxiproxy: operates at HTTP layer — understands URLs, methods, headers, and response bodies. Not TCP-level.
bashdocker run -p 8080:8080 -p 8081:8081 \ -e UPSTREAM_URL=http://my-service:3000 \ yourname/saboteur
Open http://localhost:8081 in your browser to use the web UI.
bashdocker run -p 8080:8080 -p 8081:8081 \ -v $(pwd)/config/example.yaml:/etc/saboteur/config.yaml \ yourname/saboteur --config /etc/saboteur/config.yaml
bashdocker compose up
Uses docker-compose.yml in the repo root. Spins up saboteur + a mock upstream (hashicorp/http-echo).
All settings can be provided via YAML file or environment variables.
| YAML key | Env var | Default | Description |
|---|---|---|---|
proxy.upstream_url | UPSTREAM_URL | (required) | URL to proxy traffic to |
proxy.port | PROXY_PORT | 8080 | Proxy listener port |
proxy.timeout_ms | — | 30000 | Upstream request timeout |
proxy.max_idle_conns | — | 100 | Max idle upstream connections |
control.port | CONTROL_PORT | 8081 | Control API + UI port |
control.bind | CONTROL_BIND | 0.0.0.0 | Control bind address |
control.api_key | API_KEY | (none) | If set, require X-API-Key header on control API |
traffic_log.max_entries | TRAFFIC_LOG_SIZE | 1000 | Ring-buffer size |
log_level | LOG_LEVEL | info | debug / info / warn / error |
log_format | LOG_FORMAT | json | json / text |
Add delay before forwarding or returning.
yamlfault: type: latency mode: fixed # fixed | uniform | normal fixed_ms: 500 apply_to: request # request | response
Return a specific status without hitting upstream.
yamlfault: type: error status_code: 503 body: '{"error":"down"}' headers: Retry-After: "30"
Drop the connection after N bytes.
yamlfault: type: abort after_bytes: 0 # 0 = drop immediately
Accept connection, forward to upstream, never respond.
yamlfault: type: timeout
Replace the upstream response body.
yamlfault: type: body_corrupt mode: json_invalid # empty | random_bytes | json_invalid | truncate truncate_bytes: 100 # for truncate mode
Add or override headers on request or response.
yamlfault: type: header_inject apply_to: response # request | response headers: X-Injected: "true"
Rate-limit response streaming.
yamlfault: type: throttle bytes_per_second: 1024
Rules are evaluated in priority order (lower number = higher priority). A request matches the first rule where all matcher conditions are satisfied.
yamlrules: - id: "payment-errors" enabled: true priority: 10 description: "503 on 20% of EU payment POSTs" match: path_prefix: "/api/payment" methods: [POST] headers: X-Region: "EU" percentage: 20 # 0-100; fraction of matching requests that get the fault fault: type: error status_code: 503 body: '{"error":"unavailable"}'
| Field | Description |
|---|---|
path | Exact URL path |
path_prefix | URL path prefix |
path_regex | RE2 regex on URL path |
methods | HTTP methods (empty = all) |
headers | All listed headers must match |
query_params | All listed query params must match |
Base URL: http://localhost:8081
| Method | Path | Description |
|---|---|---|
| GET | /health | Health check |
| GET | /metrics | Prometheus metrics |
| GET | /api/rules | List all rules |
| POST | /api/rules | Create rule |
| GET | /api/rules/{id} | Get rule |
| PUT | /api/rules/{id} | Replace rule |
| PATCH | /api/rules/{id} | Update fields (enabled, priority, percentage) |
| DELETE | /api/rules/{id} | Delete rule |
| POST | /api/rules/reset | Delete all runtime rules (preserves config-file rules) |
| GET | /api/traffic | Traffic log (?limit=100&path_filter=&fault_only=true) |
| DELETE | /api/traffic | Clear traffic log |
| GET | /api/traffic/stream | SSE stream of live traffic |
| GET | /api/config | Current effective configuration |
Full spec: openapi.yaml
bashcurl -H "X-API-Key: mysecret" http://localhost:8081/api/rules
bash# Add an error rule curl -X POST http://localhost:8081/api/rules \ -H "Content-Type: application/json" \ -d '{"id":"test-error","enabled":true,"priority":1,"percentage":100,"match":{},"fault":{"type":"error","status_code":503}}' # Toggle a rule off curl -X PATCH http://localhost:8081/api/rules/test-error \ -H "Content-Type: application/json" \ -d '{"enabled":false}' # View recent traffic (faults only) curl "http://localhost:8081/api/traffic?limit=10&fault_only=true" # Delete a rule curl -X DELETE http://localhost:8081/api/rules/test-error # Reset all runtime rules curl -X POST http://localhost:8081/api/rules/reset
Send SIGHUP to reload the config file without restarting:
bashkill -HUP $(pgrep saboteur)
Config-file rules are replaced atomically. Runtime rules (created via API) are preserved.
Available at http://localhost:8081/metrics.
| Metric | Labels | Description |
|---|---|---|
fault_proxy_requests_total | method, path_pattern, status_code, fault_type | Total proxied requests |
fault_proxy_faults_total | rule_id, fault_type | Requests where a fault was injected |
fault_proxy_request_duration_ms | quantile | End-to-end latency (includes injected latency) |
fault_proxy_upstream_duration_ms | quantile | Upstream-only latency |
fault_proxy_rules_active | — | Number of enabled rules |
fault_proxy_upstream_healthy | — | 1 = reachable, 0 = unreachable |
bashgo build -o saboteur ./cmd/saboteur UPSTREAM_URL=http://localhost:3000 ./saboteur
bashgo test ./... go test -race ./...
bashdocker build -f docker/Dockerfile -t saboteur .
Multi-arch:
bashdocker buildx build --platform linux/amd64,linux/arm64 \ -f docker/Dockerfile -t yourname/saboteur:latest --push .
您可以使用以下命令拉取该镜像。请将 <标签> 替换为具体的标签版本。如需查看所有可用标签版本,请访问 标签列表页面。
来自真实用户的反馈,见证轩辕镜像的优质服务