Ce contenu n'est pas disponible dans la langue sélectionnée.
Chapter 3. Resources for filtered integrations
3.1. Using example code snippets to automatically create and send reports Copier lienLien copié sur presse-papiers!
After you create a filtered Google Cloud integration, you can automate creating and sending reports. The main tasks involve querying your data, formatting and exporting a CSV file, and sending the data to cost management. The following examples provide code snippets to guide you, but you should adapt the process to reflect your unique environments. If you follow the documentation exactly as written without customizations, the automation might not work for your specific setup.
The following code writes CSV files to your Google Cloud bucket from the query data:
The following code adds batching to restrict the CSV file size:
The following code authenticates and sends reports to cost management for processing by fetching and using your service account access token:
3.1.1. Additional resources Copier lienLien copié sur presse-papiers!
For reference only, this python script provides additional logic such as restricting CSV file sizes and using variables for client secrets.
For additional help with automation, see Google’s documentation:
3.2. Troubleshooting a Google Cloud integration Copier lienLien copié sur presse-papiers!
3.2.1. Incorrect data is displayed Copier lienLien copié sur presse-papiers!
If your data is displaying incorrectly in cost management, first download your CSV files and validate the data that you sent. If that does not solve the issue, review the following common scenarios:
- If you upload data for the same day multiple times, the most recent upload is what is displayed. Send the data again in the correct order.
- Google Cloud uses a method called crossover data. For each day, Google Cloud continues to add billing data 72 hours after it had accrued. To ensure that you are capturing the correct billing data, consider a rolling window to capture these additions. For example, you can maintain a five day rolling window, or never query current day data and instead always query n-5.
- At the start of a new month, Google Cloud finishes billing for the previous month. To ensure that there are no gaps in your billing data, send the data for the previous month up to three days into the following month.
-
If your custom table does not have partitions by day (
_PARTITIONTIME
), useusage_start_time
as the partition date.