UPDATE 6/22/2020 - The Requests by credential graph is now available in the Google Maps > Metrics page in Cloud Console. The data supporting this graph can be downloaded in csv format for the last 30 days. This graph (and data) should replace the need to follow the process outlined below.
We often recommend segmenting a portfolio of applications and systems by API key. In addition to helping separate traffic, the API key includes security features. Despite all the benefits API keys bring, there is one drawback - reporting. Currently Cloud Console doesn't provide a way to view billing reports by API key, which is a common ask. There is, however, a way to view usage by API key as described here. The metrics produced by that method result in a rate with units of requests/second. Most people want to convert from a rate to a count, i.e., from requests/second to requests. Here's how to do that.
The below steps will guide you through calculating your usage from the cloud console
to show daily usage by Credential and API for the past 30 days. See the Cloud Console Metrics Guide for more details. CAVEAT: Usage exported from developer console metrics is at the API call level so this should not be used as a substitute for API Billing metrics.
Make a copy of this Google Sheets template and rename.
Export traffic by credential from Cloud Console
- Go to the Google Maps > Metrics page.
- Click dropdown under Select Graphs and choose Traffic by Credential.
- Have only 1 of 14 APIs selected under Filters.
- Export Traffic by Credential.csv
- From downloads save Traffic by Credential.csv as google sheets.
Run the script
- Paste values from Traffic by Credential into the sheet named Input.
- Select custom menu Calculate Usage then 30 Days. Alternatively, to run from Script editor, select Run then Run Function and choose calculate30Days.
The first time you run Calculate Usage, you will be prompted to grant permissions. After granting permission, run Calculate Usage again.
- Replace YOUR_API_NAME with the API name on these worksheets:
- View the results in the Consolidated Report and Chart sheets.
Note, the chart only displays the first two API keys from the Pivot Report (columns B and C). If you need to display additional API keys, add series to the chart.