以编程方式监视 Google API 使用情况?
Monitor Google API usage programmatically?
https://console.cloud.google.com/apis/dashboard
如果我们打开 google 控制台,我们会看到每个服务完成了多少请求。有没有办法导出这些计数器?我找不到任何负责这些计数器的 API。
Detect Google Maps Javascript API limit for map loads
很多年过去了,仍然没有办法为 API 使用情况设置警报?如果没有编程访问,可能有一些方法可以在 API 使用量超过阈值时设置警报?
如第一个答案所述,没有这样的 API 来监控这些使用情况,但有几种方法可以监控您的使用情况,它们是:
设置Budget Alerts,如果您在一个月内达到指定预算的特定金额,这将触发通知,但请注意,这只会通知您,实际上不会达到指定数量后停止使用。
如果您想监控或了解您的日常使用情况,您可以在 BigQuery Export 的帮助下实现我们所说的 channels
。这将为您提供日常使用情况的细分报告。您可以使用 BigQuery 导出来检索此类报告的标准 SQL 代码是:
SELECT Date(usage_start_time, "America/Los_Angeles") AS billing_day,
invoice.month AS invoice_month,
service.description AS service,
sku.description AS sku,
(
SELECT l.value
FROM Unnest(labels) AS l
WHERE l.KEY = 'goog-maps-channel' ) AS goog_maps_channel,
Round(Sum(usage.amount), 2) AS usage_amount,
usage.unit AS usage_unit,
Round(Sum(cost), 2) AS cost,
cost_type,
currency
FROM `PROJECT_ID.DATASET_NAME.gcp_billing_export_v1_BILLING_ACCOUNT_ID`
WHERE invoice.month = '201906' -- Change the invoice month with the same format as the example.
GROUP BY billing_day,
invoice_month,
service,
sku,
goog_maps_channel,
usage_unit,
cost_type,
currency
ORDER BY billing_day,
service,
sku
您可以详细了解如何设置 BigQuery 导出 here。
- 如果您想将每天的使用量限制在一定数量,您还可以实施 Capping of API usage,其中它只允许 API 每天调用特定数量的请求.
如果您需要帮助正确计算每个 API 每天的请求以达到一定的预算,您可以联系 Google 地图平台的支持团队 APIs here.
https://console.cloud.google.com/apis/dashboard 如果我们打开 google 控制台,我们会看到每个服务完成了多少请求。有没有办法导出这些计数器?我找不到任何负责这些计数器的 API。
很多年过去了,仍然没有办法为 API 使用情况设置警报?如果没有编程访问,可能有一些方法可以在 API 使用量超过阈值时设置警报?
如第一个答案所述,没有这样的 API 来监控这些使用情况,但有几种方法可以监控您的使用情况,它们是:
设置Budget Alerts,如果您在一个月内达到指定预算的特定金额,这将触发通知,但请注意,这只会通知您,实际上不会达到指定数量后停止使用。
如果您想监控或了解您的日常使用情况,您可以在 BigQuery Export 的帮助下实现我们所说的
channels
。这将为您提供日常使用情况的细分报告。您可以使用 BigQuery 导出来检索此类报告的标准 SQL 代码是:
SELECT Date(usage_start_time, "America/Los_Angeles") AS billing_day, invoice.month AS invoice_month, service.description AS service, sku.description AS sku, ( SELECT l.value FROM Unnest(labels) AS l WHERE l.KEY = 'goog-maps-channel' ) AS goog_maps_channel, Round(Sum(usage.amount), 2) AS usage_amount, usage.unit AS usage_unit, Round(Sum(cost), 2) AS cost, cost_type, currency FROM `PROJECT_ID.DATASET_NAME.gcp_billing_export_v1_BILLING_ACCOUNT_ID` WHERE invoice.month = '201906' -- Change the invoice month with the same format as the example. GROUP BY billing_day, invoice_month, service, sku, goog_maps_channel, usage_unit, cost_type, currency ORDER BY billing_day, service, sku
您可以详细了解如何设置 BigQuery 导出 here。
- 如果您想将每天的使用量限制在一定数量,您还可以实施 Capping of API usage,其中它只允许 API 每天调用特定数量的请求.
如果您需要帮助正确计算每个 API 每天的请求以达到一定的预算,您可以联系 Google 地图平台的支持团队 APIs here.