
# CLOUDBILL
### 多云成本报告、异常检测与 FOCUS 导出

[](https://pypi.org/project/cognis-cloudbill/) [](https://github.com/cognis-digital/cloudbill/actions) [](LICENSE) [](https://github.com/cognis-digital)
*DevOps 与可观测性 — 状态、可用性合成监控、告警及云成本。*
```
pip install cognis-cloudbill
cloudbill scan . # → prioritized findings in seconds
```
## 使用说明 — 逐步指南
1. **安装:**
pip install -e .
2. **汇总成本**:使用 `report` 子命令从 CSV/JSON 成本导出文件中进行汇总。`input` 参数接受文件名或使用 `-` 代表标准输入;通过 `--group-by` (`service`, `provider`, `account`, `region`) 选择分组维度:
cloudbill report costs.csv --group-by service
3. **检测每日支出激增**:使用 `anomalies` 子命令 —— `--threshold` 设置 z-score 截断值(默认 2.5),`--min-history` 设置触发告警前的最小历史天数(默认 3):
cloudbill anomalies costs.csv --threshold 3 --min-history 5
4. **读取 / 导出输出。** 使用全局 `--format json` 标志(置于子命令之前)以便于通过管道传输。`report` 表格显示各分组的成本及百分比;`anomalies` 显示分组/日期/成本/基准/z-score/严重程度。使用 `focus` 子命令导出符合 FOCUS 规范的行数据:
cloudbill --format json focus costs.csv > focus.json
5. **在自动化中使用** —— 在每次新的账单生成时运行异常检查,并在出现激增时发出告警:
cloudbill --format json anomalies costs.csv | jq -e '.count == 0' \
|| echo "检测到云支出异常"
## 目录
- [为什么选择 cloudbill?](#why) · [功能](#features) · [快速开始](#quick-start) · [示例](#example) · [架构](#architecture) · [AI 技术栈](#ai-stack) · [对比分析](#how-it-compares) · [集成](#integrations) · [随处安装](#install-anywhere) · [相关项目](#related) · [贡献](#contributing)
## 为什么选择 cloudbill?
FinOps
`cloudbill` 是单一用途、可脚本化且支持自托管的:将其指向目标,以你的工作流已支持的格式(表格 · JSON · SARIF)获取优先级排序的结果,将其作为 CI 的门禁,并允许 agent 通过 MCP 驱动它。
## 功能
- ✅ 加载记录
- ✅ 汇总数据
- ✅ 检测异常
- ✅ 转换为 FOCUS
- ✅ 支持 Linux/macOS/Windows · Docker · devcontainer 运行
- ✅ 提供 Python、JavaScript、Go 和 Rust 多语言版本 (`ports/`)
## 快速开始
```
pip install cognis-cloudbill
cloudbill --version
cloudbill scan . # scan current project
cloudbill scan . --format json # machine-readable
cloudbill scan . --fail-on high # CI gate (non-zero exit)
```
## 示例
```
$ cloudbill scan .
[HIGH ] CLO-001 example finding (./src/app.py)
[MEDIUM ] CLO-002 another signal (./config.yaml)
2 findings · risk score 5 · 38ms
```
## 架构
```
flowchart LR
IN[target / manifest] --> P[cloudbill
checks + rules]
P --> OUT[findings (JSON / SARIF)]
```
## 从任何 AI 技术栈中使用
`cloudbill` 可与所有主流的 AI 使用方式互操作:
- **MCP server** — `cloudbill mcp` (Claude Desktop, Cursor, Cognis.Studio, [uncensored-fleet](https://github.com/cognis-digital/uncensored-fleet))
- **兼容 OpenAI / JSON** — 将 `cloudbill scan . --format json` 通过管道传输给任何 agent 或 LLM
- **LangChain · CrewAI · AutoGen · LlamaIndex** — 一行代码即可将 CLI/JSON 封装为工具
- **CI / 脚本** — 为非 AI pipeline 提供 exit code + SARIF
## 对比分析
| | **Cognis cloudbill** | OptScale + FOCUS |
|---|:---:|:---:|
| 支持自托管,无需账号 | ✅ | 视情况而定 |
| 单一命令,零配置 | ✅ | ⚠️ |
| 适用于 CI 的 JSON + SARIF | ✅ | 视情况而定 |
| MCP 原生 (AI agent) | ✅ | ❌ |
| 多语言端口 (JS/Go/Rust) | ✅ | ❌ |
| 开源协议 | ✅ COCL | 视情况而定 |
*秉承 **OptScale + FOCUS** 的精神,以 Cognis 的方式重新构建。漏掉了你的致谢?提交一个 PR 吧。*
## 集成
可融入你的技术栈:用于代码扫描的 **SARIF**、用于任何场景的 **JSON**、用于 AI agent 的 **MCP server** (`cloudbill mcp`),以及用于 SIEM/Slack/Jira 的 webhook 转发器。请参阅 [`docs/INTEGRATIONS.md`](docs/INTEGRATIONS.md)。
## 安装 — 全平台的各种方式
```
pip install "git+https://github.com/cognis-digital/cloudbill.git" # pip (works today)
pipx install "git+https://github.com/cognis-digital/cloudbill.git" # isolated CLI
uv tool install "git+https://github.com/cognis-digital/cloudbill.git" # uv
pip install cognis-cloudbill # PyPI (when published)
docker run --rm ghcr.io/cognis-digital/cloudbill:latest --help # Docker
brew install cognis-digital/tap/cloudbill # Homebrew tap
curl -fsSL https://raw.githubusercontent.com/cognis-digital/cloudbill/main/install.sh | sh
```
| Linux | macOS | Windows | Docker | 云平台 |
|---|---|---|---|---|
| `scripts/setup-linux.sh` | `scripts/setup-macos.sh` | `scripts/setup-windows.ps1` | `docker run ghcr.io/cognis-digital/cloudbill` | [DEPLOY.md](docs/DEPLOY.md) (AWS/Azure/GCP/k8s) |
## 相关 Cognis 工具
- [`statuskit`](https://github.com/cognis-digital/statuskit) — 具有事件时间线和订阅者功能的自托管状态页面
- [`probesite`](https://github.com/cognis-digital/probesite) — 合成可用性与 Playwright 检查,并导出到 Prometheus
- [`alertmux`](https://github.com/cognis-digital/alertmux) — 位于 Grafana / PagerDuty 前端的告警去重、关联和路由工具
- [`k8scost`](https://github.com/cognis-digital/k8scost) — 无需 Prometheus 依赖的 Kubernetes 成本与配置优化顾问
- [`otelbox`](
) — 一条命令搞定的 OpenTelemetry collector + 仪表盘套件
**探索套件 →** [🗂️ 全部 170+ 工具](https://github.com/cognis-digital/cognis-neural-suite) · [⭐ awesome-cognis](https://github.com/cognis-digital/awesome-cognis) · [🔗 cognis-sources](https://github.com/cognis-digital/cognis-sources) · [🤖 uncensored-fleet](https://github.com/cognis-digital/uncensored-fleet) · [🧠 engram](https://github.com/cognis-digital/engram)
## 互操作性
`{}` 与包含 300+ 工具的 Cognis 套件无缝组合 —— JSON 输入/输出以及共享的兼容 OpenAI 的 `/v1` 主干网络。请参阅 **[INTEROP.md](INTEROP.md)** 了解套件图谱、组合模式及参考技术栈。
## 开源协议
源码可见,基于 **Cognis Open Collaboration License (COCL) v1.0** —— 可免费用于个人、内部评估、研究和教育用途;**商业 / 生产环境使用需要授权** (licensing@cognis.digital)。请参阅 [LICENSE](LICENSE)。
Cognis Digital · Cognis Neural Suite 中 170+ 工具之一 · Making Tomorrow Better Today