ibm-cloud - 有没有办法在一次 api 调用中获得整合的 IBM Cloud 计费
问题描述
我需要获得基于组织或资源组的综合账单。就像是:
org1 $100
org2 $200
rg1 $150
有没有一种方法可以在一个 api 调用中得到这个?我可以使用以下 cli 命令获得详细的账单:
ibmcloud billing account-usage
解决方案
@VidyasagarMachupalli 和@data_henrik 的答案是合适的。虽然没有单一的 API 调用,但ibmcloud billing resource-instances-usage
它提供了最接近的解决方案,因为它根据组织、空间和资源组对数据进行分段。
您可以使用电子表格(即数据透视表)进行最后一步,并对整个组织或资源组的数据求和。提到的教程(本节)使用 IBM Cloud CLI、jq 和 json2csv 完全采用这种方法。
ibmcloud billing resource-instances-usage --output json | jq '.[] | {month,resource_name,resource_group_name,organization_name,space_name,metric: .usage[].metric,cost : .usage[].cost}' | json2csv -f month,resource_name,resource_group_name,organization_name,space_name,metric,cost -p
┌───────────────┬──────────────────────────────┬──────────────────────────────────────────┬──────────────────────────────────────┬────────────────────────┬────────────────┬───────────────┐
│ "month" │ "resource_name" │ "resource_group_name" │ "organization_name" │ "space_name" │ "metric" │ "cost" │
├───────────────┼──────────────────────────────┼──────────────────────────────────────────┼──────────────────────────────────────┼────────────────────────┼────────────────┼───────────────┤
│ │ │ │ │ │ "AUTHORIZED_US │ │
│ "2018-11" │ "Continuous Delivery" │ "default" │ "" │ "" │ ERS_PER_MONTH" │ 0 │
├───────────────┼──────────────────────────────┼──────────────────────────────────────────┼──────────────────────────────────────┼────────────────────────┼────────────────┼───────────────┤
│ │ │ │ │ │ "AUTHORIZED_US │ │
│ "2018-11" │ "Continuous Delivery" │ "default" │ "" │ "" │ ERS_PER_MONTH" │ 0 │
├───────────────┼──────────────────────────────┼──────────────────────────────────────────┼──────────────────────────────────────┼────────────────────────┼────────────────┼───────────────┤
│ │ │ │ │ │ "JOB_EXECUTION │ │
│ "2018-11" │ "Continuous Delivery" │ "default" │ "" │ "" │ S_PER_MONTH" │ 0 │
├───────────────┼──────────────────────────────┼──────────────────────────────────────────┼──────────────────────────────────────┼────────────────────────┼────────────────┼───────────────┤
│ │ │ │ │ │ "JOB_EXECUTION │ │
│ "2018-11" │ "Continuous Delivery" │ "default" │ "" │ "" │ S_PER_MONTH" │ 0 │
├───────────────┼──────────────────────────────┼──────────────────────────────────────────┼──────────────────────────────────────┼────────────────────────┼────────────────┼───────────────┤
│ │ │ │ │ │ "DEVOPS_INSIGH │ │
│ "2018-11" │ "DevOps Insights" │ "default" │ "" │ "" │ TS_ITEMS" │ 0 │
├───────────────┼──────────────────────────────┼──────────────────────────────────────────┼──────────────────────────────────────┼────────────────────────┼────────────────┼───────────────┤
│ │ │ │ │ │ "instance_hour │ │
│ "2018-11" │ "Kubernetes Service" │ "default" │ "" │ "" │ s" │ 0 │
├───────────────┼──────────────────────────────┼──────────────────────────────────────────┼──────────────────────────────────────┼────────────────────────┼────────────────┼───────────────┤
│ │ │ │ │ │ "DATA_POINTS_P │ │
│ "2018-11" │ "Monitoring" │ "" │ "van_org" │ "dev" │ ER_MONTH" │ 0 │
├───────────────┼──────────────────────────────┼──────────────────────────────────────────┼──────────────────────────────────────┼────────────────────────┼────────────────┼───────────────┤
│ │ "IBM Bluemix Platform Runtim │ │ │ │ "GB_HOURS_PER_ │ │
│ "2018-11" │ e" │ "" │ "van_org" │ "dev" │ MONTH" │ 0.00035 │
├───────────────┼──────────────────────────────┼──────────────────────────────────────────┼──────────────────────────────────────┼────────────────────────┼────────────────┼───────────────┤
│ │ │ │ │ │ "GB_HOURS_PER_ │ 3.51056366597 │
│ "2018-11" │ "IBM Bluemix Node.js" │ "" │ "van_org" │ "dev" │ MONTH" │ 2222 │
推荐阅读
- json - Flutter:将未来转换为流
- python - python中的图像分类得到不准确的预测
- flutter - Flutter 使用 BloC 模式从 API 结果中获取列表元素
- javascript - 在基于类的组件 ReactJS 中的渲染中编写 Javascript 代码
- authentication - 如何去除离子应用中的白屏
- javascript - 如何匹配不完全是数字的字符串(实际上更复杂)?
- python - 带有两个y轴的python 3d绘图
- uipath - UiPath 中的 IF 条件
- git - 如何从远程仓库拉到远程分支
- android - Android 资源链接失败 - Android Studio