14个不稳定版本 (4个重大变更)

0.5.3 2024年2月16日
0.4.2 2024年1月4日
0.4.1 2023年11月30日
0.3.2 2023年7月27日
0.2.0 2023年3月28日

#4 in #estimation

每月23次下载

BSD-3-Clause

180KB
4K SLoC

osc-cost

Project Sandbox

osc-cost 允许Outscale用户估算他们的云成本。

免责声明

此程序仅提供当前账户状态的成本估算。只有Outscale提供的官方账单才代表您的消费。请阅读许可证以获取更多详情。

特性

  • 数据源
  • 支持的资源
    • 虚拟机(tina类型、aws兼容类型、许可证)
    • 公网IP
    • 快照(🚨 警告:已知快照计算价格过高。)
    • 专用VM
    • 负载均衡器
    • 灵活GPU
    • VPN连接
    • Outscale对象存储(🚨 警告:Oos计算可能需要很长时间,使用 --skip-resource Oos 禁用此计算。)
    • Nat服务
  • 输出格式
    • 每小时当前成本
    • 每月当前成本
    • 每年当前成本
    • Json(行分隔的JSON文档)
    • 人类可读
    • Open Document Spreadsheet (Ods)
    • Prometheus

安装

转到发布页面并下载最新二进制文件。

配置

您需要在您的主目录中有一个 .osc/config.json 文件。如果没有指定,osc-cost 将使用 default 配置文件。以下是一个 config.json 的示例

{
  "default": {
    "access_key": "YoUrAcCeSsKeY",
    "secret_key": "YoUrSeCrEtKeY",
    "region": "eu-west-2"
  }
}

运行

以下是不同输出格式的几个示例。请注意,json 格式将提供最详细的信息。

osc-cost --format=human # default
Summary:
╭───────────────────────┬──────────────╮
│ Account Id            ┆ 620346218618 │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ Total price per hour  ┆ 2.2062643€   │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ Total price per month ┆ 1610.5729€   │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ Total price per year  ┆ 19326.875€   │
╰───────────────────────┴──────────────╯

Details:
╭───────────────┬───────┬──────────────────────┬───────────────────────┬──────────────────────╮
│ Resource Type ┆ Count ┆ Total price per hour ┆ Total price per month ┆ Total price per year │
╞═══════════════╪═══════╪══════════════════════╪═══════════════════════╪══════════════════════╡
│ Snapshot      ┆ 230.03164384€          ┆ 23.1€                 ┆ 277.2€               │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ Vm            ┆ 91.7939999€           ┆ 1309.6199€            ┆ 15715.438€           │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ LoadBalancer  ┆ 20.06€                ┆ 43.8€                 ┆ 525.6€               │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ NatServices   ┆ 20.1€                 ┆ 73€                   ┆ 876€                 │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ Volume        ┆ 120.20554796€          ┆ 150.04999€            ┆ 1800.5999€           │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ PublicIp      ┆ 70.015€               ┆ 10.95€                ┆ 131.4€               │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ Oos           ┆ 50.00007237231€       ┆ 0.05283179€           ┆ 0.63398147€          │
╰───────────────┴───────┴──────────────────────┴───────────────────────┴──────────────────────╯
osc-cost --format=hour
0.42
osc-cost --format=month
150.91
osc-cost --format=json
{"resource_type":"Vm","osc_cost_version":"0.1.0","account_id":"509075394552","read_date_rfc3339":"2022-11-24T11:15:50.665643413+00:00","region":"eu-west-2","resource_id":"i-e51434a6","price_per_hour":0.044,"price_per_month":32.12,"vm_type":"tinav4.c1r1p2","vm_vcpu_gen":"4","vm_core_performance":"high","vm_image":"ami-bb490c7e","vm_vcpu":1,"vm_ram_gb":1,"price_vcpu_per_hour":0.039,"price_ram_gb_per_hour":0.005,"price_box_per_hour":0.0,"price_product_per_ram_gb_per_hour":0.0,"price_product_per_cpu_per_hour":0.0,"price_product_per_vm_per_hour":0.0}
{"resource_type":"Volume","osc_cost_version":"0.1.0","account_id":"509075394552","read_date_rfc3339":"2022-11-24T11:15:50.665643413+00:00","region":"eu-west-2","resource_id":"vol-9e99bad9","price_per_hour":0.02321918,"price_per_month":16.95,"volume_type":"io1","volume_size":15,"volume_iops":1500,"price_gb_per_month":0.13,"price_iops_per_month":0.01}
{"resource_type":"PublicIp","osc_cost_version":"0.1.0","account_id":"509075394552","read_date_rfc3339":"2022-11-24T11:15:50.665643413+00:00","region":"eu-west-2","resource_id":"eipalloc-2e5f8e4f","price_per_hour":0.0,"price_per_month":0.0,"price_non_attached":null,"price_first_ip":0.0,"price_next_ips":null}
...

注意: 下一个特性仍处于测试阶段

该工具还可以用于查看 osc-cost 估算和实际记录之间的差异。以下是执行此操作的步骤

  • 将 osc-cost 的输出存储为 json
    osc-cost --format json --output account.json
    
  • 冻结账户 一天
  • 第二天
      osc-cost --compute-drift --from-date "$(date "+%Y-%m-%d" --date='-1day') --to-date $(date "+%Y-%m-%d") --input account.json
    

为了以 Prometheus 格式提供默认值,请使用

osc-cost -n --format=prometheus

您将获得漂移的详细信息。

╭───────────────┬──────────┬────────┬───────╮
│ Resource Type ┆ Osc-cost ┆ Digest ┆ Drift │
╞═══════════════╪══════════╪════════╪═══════╡
│ Volume        ┆ 1.181.180%    │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┤
│ Oos           ┆ 0.010.01-5%   │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┤
│ Snapshot      ┆ 1.250.62101%  │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┤
│ Vm            ┆ 34.0134.010%    │
╰───────────────┴──────────┴────────┴───────╯

贡献

请查看 贡献文档

发布

  1. 如有必要,请更新 helm/osccost/Chart.yaml 中的图表版本和在 helm/osccost/values.yaml 中的 osc-cost 版本

  2. 标记发布版本

git tag -a vX.X.X -m "vX.X.X"
  1. 在 Github 上发布

Osc-cost Prometheus 导出器输出

但什么是 Prometheus (Prometheus)

我们创建了一个 Prometheus 导出器 (Prometheus-Exporter)

为了有一个简单易操作的东西,我们创建了一个 serde 用于 Prometheus。(Serde)

如何部署

您可以使用 Helm 图表 (osc-cost) 进行部署

您也可以使用 docker-compose (docker-compose) 进行部署

环境

您需要一个配置文件。

使用拥有多个云对象的账户进行测试。

对于 Prometheus,您可以使用项目中的 docker-compose 文件进行测试。

或者您可以使用 k8s 集群进行测试。

要使用 k8s 集群进行测试,您可以使用 kind,但对我来说,我使用这个项目(osc-k8s-rke-cluster)创建了一个包含一个工作节点和一个主节点的集群

在 eu-west-2/cloud-gouv 或 us-east-2 的 Outscale 账户。如果您想在其他地区使用,请在这些地区创建 omi。

许可证

版权所有 Outscale SAS

BSD-3-Clause

此项目符合 REUSE

依赖项

~70MB
~1M SLoC