使用谷歌云API获取账单 [英] using google cloud API to get bills

查看:421
本文介绍了使用谷歌云API获取账单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们可以使用任何Google API来提供有关使用Google Cloud Platform花费的总费用的信息吗?我尝试了一些API(代码中显示了详细信息).

can we use any google API which can provide information about the total charges spent using Google Cloud Platform? i have tried few APIs (detail shown in code).

API 1:

var google = require('googleapis');
var cloudbilling = google.cloudbilling('v1');
google.auth.getApplicationDefault(function(err, authClient) {
if (err) {
console.log('Authentication failed because of ', err);
return;
}

if (authClient.createScopedRequired && 
authClient.createScopedRequired()) {
var scopes = ['https://www.googleapis.com/auth/cloud-platform'];
authClient = authClient.createScoped(scopes);
 }
 var request = {
  name: "projects/<your-project-id>", 
// Auth client
  auth: authClient
};
 cloudbilling.projects.getBillingInfo(request, function(err, result) {
  if (err) {
   console.log(err);
}  else {
   console.log(result);
 }
   });
  });

我在json中得到的(关于帐单信息)是:

What i am getting in json (about billing information) is:

data:
   { name: 'projects/<your-project-name>/billingInfo',
     projectId: '<project-Id>',
 billingAccountName: 'billingAccounts/<your-billing-id>',
 billingEnabled: true } 
   }

现在我也尝试了其他API,但是它们也没有提供所花的总费用!有什么方法可以找到我的账单吗?

Now i have tried other APIs too, but they are also not providing the total charges spent!. Is there a way i can find the bills?

推荐答案

但是还有其他选项可用于通过其他路径访问数据:

But there are other options for accessing the data via other paths:

  • you can Export Billing Data to a File (in GCS):

要查看详细的费用明细,您可以导出自己的 每日使用情况和费用估算自动保存为CSV或JSON文件 存储在您指定的 Google云存储存储桶中.那你可以 通过Cloud Storage API,CLI工具或 Google Cloud访问数据 平台控制台.

To access a detailed breakdown of your charges, you can export your daily usage and cost estimates automatically to a CSV or JSON file stored in a Google Cloud Storage bucket you specify. You can then access the data via the Cloud Storage API, CLI tool, or Google Cloud Platform Console.

  • 您可以将帐单数据导出到BigQuery :
    • you can Export Billing Data to BigQuery:
    • 用于监控,分析和优化成本的工具已成为 管理发展的重要部分.结算出口到 BigQuery 可让您导出每日使用量和费用 全天自动估算您的BigQuery数据集 指定.然后,您可以从BigQuery访问帐单数据.

      Tools for monitoring, analyzing and optimizing cost have become an important part of managing development. Billing export to BigQuery enables you to export your daily usage and cost estimates automatically throughout the day to a BigQuery dataset you specify. You can then access your billing data from BigQuery.

      这篇关于使用谷歌云API获取账单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆