Download di un report costi
Scaricare un report sui costi in Billing and Cost Management.
Un report costi è un file memorizzato come oggetto in un bucket. Per informazioni generali sul download di un oggetto, vedere Download di un oggetto di storage degli oggetti.
Per informazioni sull'elenco dei rapporti sui costi, vedere Elenco dei rapporti sui costi.
- Nella pagina di elenco Report costi e uso, trovare il report costi che si desidera scaricare. Per assistenza nella ricerca della pagina di elenco o del rapporto sui costi, vedere Elenco dei rapporti sui costi.
- Nel per il report sui costi, selezionare Scarica report.
- Nota
I report sui costi vengono memorizzati nell'area di origine della tenancy. Lo spazio di nomi dello storage degli oggetti utilizzato per i report èbling
. Il nome del bucket è l'OCID della tenancy.Utilizzare il comando oci os object get e i parametri necessari per scaricare i report sui costi nella tenancy:
oci os object get --bucket-name bucket-name --name object-name --file file-name
Esempio (fare riferimento all'esempio di codice SDK Python mostrato nell'attività API):
oci os object get --namespace-name bling --bucket-name {customer_tenancy_ocid} --name reports/usage-csv/{report_name}.csv.gz --file {local_report_name}.csv.gz
Per un elenco completo dei parametri e dei valori per i comandi CLI, consultare il manuale CLI Command Reference.
- Nota
I report sui costi vengono memorizzati nell'area di origine della tenancy. Lo spazio di nomi dello storage degli oggetti utilizzato per i report èbling
. Il nome del bucket è l'OCID della tenancy.Eseguire l'operazione GetObject per scaricare un report sui costi.
L'esempio seguente mostra come scaricare un report dei costi utilizzando uno script Python:
Nota
In questo esempio è disponibile un OCID tenancy specifico, poiché i report vengono memorizzati in un bucket di storage degli oggetti di proprietà di Oracle ospitato da Oracle Cloud Infrastructure e non nella tenancy di un cliente.import oci import os # This script downloads all of the cost, usage, (or both) reports for a tenancy (specified in the config file). # # Pre-requisites: Create an IAM policy to endorse users in your tenancy to read cost reports from the OCI tenancy. # # Example policy: # define tenancy reporting as ocid1.tenancy.oc1..aaaaaaaaned4fkpkisbwjlr56u7cj63lf3wffbilvqknstgtvzub7vhqkggq # endorse group <group_name> to read objects in tenancy reporting # # Note - The only value you need to change is the <group_name> with your own value. Do not change the OCID in the first statement. reporting_namespace = 'bling' # Download all usage and cost files. You can comment out based on the specific need: prefix_file = "" # For cost and usage files # prefix_file = "reports/cost-csv" # For cost # prefix_file_focus = "FOCUS Reports" # For FOCUS reports # Update these values destintation_path = 'downloaded_reports' # Make a directory to receive reports if not os.path.exists(destintation_path): os.mkdir(destintation_path) # Get the list of reports config = oci.config.from_file(oci.config.DEFAULT_LOCATION, oci.config.DEFAULT_PROFILE) reporting_bucket = config['tenancy'] object_storage = oci.object_storage.ObjectStorageClient(config) report_bucket_objects = oci.pagination.list_call_get_all_results(object_storage.list_objects, reporting_namespace, reporting_bucket, prefix=prefix_file) for o in report_bucket_objects.data.objects: print('Found file ' + o.name) object_details = object_storage.get_object(reporting_namespace, reporting_bucket, o.name) filename = o.name.rsplit('/', 1)[-1] with open(destintation_path + '/' + filename, 'wb') as f: for chunk in object_details.data.raw.stream(1024 * 1024, decode_content=False): f.write(chunk) print('----> File ' + o.name + ' Downloaded')