Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Halaman ini menjelaskan cara menggunakan log audit Cloud Monitoring dan Spanner untuk memantau dan menganalisis penggunaan Spanner Data Boost.
Cloud Monitoring memberikan kemampuan untuk melacak total penggunaan dari waktu ke waktu dan mengelompokkan penggunaan tersebut menurut pengguna. Log audit Spanner memungkinkan analisis penggunaan yang lebih fleksibel, termasuk menyediakan metrik menurut pengguna atau menurut ID tugas BigQuery.
Menggunakan Cloud Monitoring untuk melacak penggunaan Data Boost
Ikuti langkah-langkah berikut untuk melacak penggunaan Peningkatan Data secara keseluruhan:
Jika Metrics Explorer ditampilkan di menu navigasi, pilih.
Atau, klik Resources, lalu pilih Metrics Explorer.
Di bagian atas halaman, pilih interval waktu.
Di menu drop-down Metrik, di kolom Filter menurut nama metrik atau resource, masukkan spanner, lalu tekan Enter untuk mempersempit penelusuran.
Di daftar Metric, pilih Cloud Spanner Instance > Instance >
Processing unit second, lalu klik Apply.
Tindakan ini akan membuat diagram garis penggunaan Data Boost gabungan di semua instance Spanner.
Untuk melihat penggunaan instance tertentu, ikuti langkah-langkah berikut:
Gunakan kolom Filter untuk menambahkan filter, seperti ID instance.
Klik + untuk menambahkan atribut lainnya.
Untuk melihat perincian penggunaan menurut semua instance, ikuti langkah-langkah berikut:
Hapus semua filter dengan mengklik ikon X di samping kolom filter.
Di menu drop-down operator Aggregation, pilih Sum, lalu
pilih menurut instance_id.
Untuk mengelompokkan penggunaan menurut principal, di menu drop-down operator Aggregation, pilih Sum, lalu pilih menurut credential_id.
Menggunakan log audit untuk menganalisis penggunaan Data Boost
Log audit Spanner memungkinkan analisis penggunaan Data Boost yang lebih fleksibel. Selain kemampuan untuk mengelompokkan penggunaan dari waktu ke waktu menurut instance atau pokok seperti pada Cloud Monitoring, log audit Spanner, jika diaktifkan dan tersedia, memungkinkan pengelompokan penggunaan dari waktu ke waktu menurut database atau ID tugas BigQuery.
Anda harus mengaktifkan log audit akses data untuk Spanner sebelum dapat mengumpulkan data penggunaan untuk Data Boost. Untuk melakukannya, ikuti langkah-langkah berikut:
Untuk menampilkan penggunaan menurut pengguna dan database selama 7 hari terakhir, jalankan kueri berikut. Untuk mengubah rentang waktu penggunaan yang ditampilkan, ubah ekspresi
timestamp dalam klausa WHERE.
Contoh berikut menunjukkan penggunaan dalam unit pemrosesan untuk 4 prinsipal.
Melihat penggunaan menurut ID tugas BigQuery
Untuk membuat kueri log audit guna melihat penggunaan Peningkatan Data yang dikelompokkan menurut database, pengguna, dan ID tugas BigQuery, ikuti langkah-langkah berikut:
SELECTSUM(CAST(JSON_VALUE(labels.data_boost_usage)ASINT64))ASusage,REGEXP_EXTRACT(proto_payload.audit_log.resource_name,'projects/[^/]+/instances/[^/]+/databases/[^/]+')ASdatabase,proto_payload.audit_log.authentication_info.principal_emailASprincipal_email,IFNULL(JSON_VALUE(labels.data_boost_workload_id),'not from BQ')ASjob_idFROM`PROJECT_NAME.global._Default._AllLogs`WHEREtimestamp > TIMESTAMP_SUB(CURRENT_TIMESTAMP(),INTERVAL7DAY)ANDresource.type='spanner_instance'ANDoperation.lastISNULLANDJSON_VALUE(labels.data_boost_usage)!=''GROUPBYdatabase,principal_email,job_id;
Ganti PROJECT_NAME dengan nama project Anda.
Contoh berikut menunjukkan penggunaan menurut ID tugas BigQuery.
Melihat penggunaan menurut teks SQL BigQuery
Untuk melihat penggunaan Peningkatan Data untuk beberapa tugas BigQuery yang dikelompokkan menurut teks SQL tugas tersebut, ikuti langkah-langkah berikut:
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Sulit dipahami","hardToUnderstand","thumb-down"],["Informasi atau kode contoh salah","incorrectInformationOrSampleCode","thumb-down"],["Informasi/contoh yang saya butuhkan tidak ada","missingTheInformationSamplesINeed","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2025-08-11 UTC."],[],[],null,["# Monitor Data Boost usage\n\n\u003cbr /\u003e\n\nThis page describes how to use Cloud Monitoring and Spanner audit\nlogs to monitor and analyze Spanner Data Boost usage.\n\nCloud Monitoring provides the ability to track total usage over time and to\nbreak down that usage by user. Spanner audit logs allow more\nflexible usage analysis, including providing metrics by user or by\nBigQuery job ID.\n\nUse Cloud Monitoring to track Data Boost usage\n----------------------------------------------\n\nFollow these steps to track overall Data Boost usage:\n\n1. In the Google Cloud console, go to **Monitoring** . \n [Go to Monitoring](https://console.cloud.google.com/monitoring)\n2. If **Metrics Explorer** is shown in the navigation menu, select it. Otherwise, click **Resources** , and then select **Metrics Explorer**.\n3. At the top of the page, select a time interval.\n4. In the **Metric** drop-down list, in the **Filter by resource or metric\n name** field, enter `spanner` and press `Enter` to narrow the search.\n5. In the **Metric** list, select **Cloud Spanner Instance \\\u003e Instance \\\u003e\n Processing unit second** , and then click **Apply**.\n\n This creates a line chart of aggregate Data Boost usage across\n all Spanner instances.\n6. To view usage for a particular instance, follow these steps:\n\n 1. Use the **Filter** field to add filters, such as the instance ID.\n 2. Click **+** to add other attributes.\n7. To view a breakdown of usage by all instances, follow these steps:\n\n 1. Clear any filters by clicking the **X** icon next to the filter fields.\n 2. In the **Aggregation** operator drop-down list, select **Sum** , and then select by **instance_id**.\n8. To break down usage by principal, in the **Aggregation** operator drop-down,\n select **Sum** , and then select by **credential_id**.\n\nUse audit logs to analyze Data Boost usage\n------------------------------------------\n\nSpanner audit logs allow more flexible analysis of\nData Boost usage. In addition to the ability to break down usage\nover time by instance or principal as with Cloud Monitoring,\nSpanner audit logs, if enabled and available, allow breaking down\nusage over time by database or BigQuery job ID.\n\nEnabling audit logs can incur extra charges. For information about\nLogging pricing, see\n[Google Cloud Observability pricing: Cloud Logging](https://cloud.google.com/stackdriver/pricing#logging-costs).\n\n### Enable Data Boost usage audit logs\n\nYou must enable data access audit logs for Spanner before you can\ncollect usage data for Data Boost. To do so, follow these steps:\n\n1. Follow the instructions in [Configure Data Access audit logs with the Google Cloud console](/logging/docs/audit/configure-data-access#config-console).\n2. Enable the **Data Read** log type for the **Spanner API** service.\n3. To obtain Data Boost usage by BigQuery job SQL text, ensure that that the audit logs for BigQuery are enabled as well.\n\n### View usage by principal\n\nTo query the audit logs to view Data Boost usage by user, follow\nthese steps:\n\n1. Go to the Logs Explorer in the Google Cloud console.\n\n [Go to Logs Explorer](https://console.cloud.google.com/logs)\n2. In the navigation menu, click **Log Analytics**.\n\n3. To show usage by user and database over the past 7 days, run the following\n query. To change the timespan for which usage is shown, modify the\n `timestamp` expression in the `WHERE` clause.\n\n SELECT\n SUM(CAST(JSON_VALUE(labels.data_boost_usage) AS INT64)) AS usage,\n REGEXP_EXTRACT(\n proto_payload.audit_log.resource_name,\n 'projects/[^/]+/instances/[^/]+/databases/[^/]+') AS database,\n proto_payload.audit_log.authentication_info.principal_email AS principal_email\n FROM `\u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-n\"\u003ePROJECT_NAME\u003c/span\u003e\u003c/var\u003e.global._Default._AllLogs`\n WHERE\n timestamp \u003e TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 7 DAY)\n AND resource.type = 'spanner_instance' AND operation.last IS NULL\n AND JSON_VALUE(labels.data_boost_usage) != ''\n GROUP BY database, principal_email;\n\n Replace \u003cvar translate=\"no\"\u003ePROJECT_NAME\u003c/var\u003e with your project name.\n\nThe following example shows usage in processing units for 4 principals.\n\n### View usage by BigQuery job ID\n\nTo query the audit logs to view Data Boost usage broken down by\ndatabase, user, and BigQuery job ID, follow these steps:\n\n1. Go to the Logs Explorer in the Google Cloud console.\n\n [Go to Logs Explorer](https://console.cloud.google.com/logs)\n2. In the navigation menu, click **Log Analytics**.\n\n3. Run the following query:\n\n SELECT\n SUM(CAST(JSON_VALUE(labels.data_boost_usage) AS INT64)) AS usage,\n REGEXP_EXTRACT(\n proto_payload.audit_log.resource_name,\n 'projects/[^/]+/instances/[^/]+/databases/[^/]+') AS database,\n proto_payload.audit_log.authentication_info.principal_email AS principal_email,\n IFNULL(JSON_VALUE(labels.data_boost_workload_id), 'not from BQ') AS job_id\n FROM `\u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-n\"\u003ePROJECT_NAME\u003c/span\u003e\u003c/var\u003e.global._Default._AllLogs`\n WHERE\n timestamp \u003e TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 7 DAY)\n AND resource.type = 'spanner_instance' AND operation.last IS NULL\n AND JSON_VALUE(labels.data_boost_usage) != ''\n GROUP BY database, principal_email, job_id;\n\n Replace \u003cvar translate=\"no\"\u003ePROJECT_NAME\u003c/var\u003e with your project name.\n\nThe following example shows usage by BigQuery job ID.\n\n### View usage by BigQuery SQL text\n\nTo view Data Boost usage for multiple BigQuery jobs\naggregated by the SQL text of those jobs, follow these steps:\n\n1. Go to the Logs Explorer in the Google Cloud console.\n\n [Go to Logs Explorer](https://console.cloud.google.com/logs)\n2. In the navigation menu, click **Log Analytics**.\n\n3. Run the following query:\n\n SELECT\n SUM(\n CAST(\n JSON_VALUE(db.labels.data_boost_usage)\n AS INT64)) AS usage,\n JSON_VALUE(\n bq.proto_payload.audit_log.metadata.jobInsertion.job.jobConfig.queryConfig.query)\n AS bq_query\n FROM\n `\u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-n\"\u003ePROJECT_NAME\u003c/span\u003e\u003c/var\u003e.global._Default._AllLogs` db,\n `\u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-n\"\u003ePROJECT_NAME\u003c/span\u003e\u003c/var\u003e.global._Default._AllLogs` bq\n WHERE\n db.timestamp \u003e TIMESTAMP_SUB(\n CURRENT_TIMESTAMP(), INTERVAL 7 DAY)\n AND db.resource.type = 'spanner_instance'\n AND JSON_VALUE(db.labels.data_boost_usage) != ''\n AND db.operation.last IS NULL\n AND bq.timestamp \u003e TIMESTAMP_SUB(\n CURRENT_TIMESTAMP(), INTERVAL 7 DAY)\n AND bq.proto_payload.audit_log.method_name\n = 'google.cloud.bigquery.v2.JobService.InsertJob'\n AND bq.resource.type = 'bigquery_project'\n AND JSON_VALUE(\n bq.proto_payload.audit_log.metadata.jobInsertion.job.jobConfig.queryConfig.query)\n IS NOT NULL\n AND JSON_VALUE(db.labels.data_boost_workload_id)\n = REGEXP_EXTRACT(bq.proto_payload.audit_log.resource_name, '[^/]*$')\n GROUP BY bq_query\n ORDER BY usage DESC\n\n Replace \u003cvar translate=\"no\"\u003ePROJECT_NAME\u003c/var\u003e with your project name.\n\nThe following example shows Data Boost usage by SQL text.\n\nCreate a Data Boost alert\n-------------------------\n\nTo create an alert that is issued when Data Boost usage exceeds\na predefined threshold, see\n[Set an alert for Data Boost usage](/spanner/docs/databoost/databoost-quotas#databoost-alert).\n\nWhat's next\n-----------\n\n- Learn about Data Boost in [Data Boost overview](/spanner/docs/databoost/databoost-overview)."]]