Mengekspor rekomendasi ke BigQuery
Ringkasan
Dengan BigQuery Export, Anda dapat melihat snapshot harian rekomendasi untuk organisasi Anda. Hal ini dilakukan menggunakan BigQuery Data Transfer Service. Lihat Pemberi rekomendasi untuk melihat pemberi rekomendasi mana yang disertakan dalam BigQuery Export saat ini.
BigQuery Export mendukung hal berikut:
Mengekspor rekomendasi dan insight untuk semua project, folder, dan akun penagihan untuk organisasi (termasuk rekomendasi dan insight tingkat organisasi)
Mengekspor harga yang dinegosiasikan, bukan harga standar untuk rekomendasi penghematan biaya.
Sebelum memulai
Selesaikan langkah-langkah berikut sebelum Anda membuat transfer data untuk rekomendasi:
- Izinkan BigQuery Data Transfer Service mengelola transfer data Anda. Jika
Anda menggunakan UI web BigQuery untuk membuat transfer, Anda harus mengizinkan
pop-up dari
console.cloud.google.comdi browser agar dapat melihat izin. Untuk mengetahui detail selengkapnya, lihat mengaktifkan BigQuery Data Transfer Service. - Buat
set data BigQuery untuk menyimpan data.
- Transfer data menggunakan region yang sama dengan tempat set data dibuat. Lokasi tidak dapat diubah setelah set data dan transfer dibuat.
- Set data akan berisi insight dan rekomendasi dari semua wilayah di seluruh dunia. Dengan demikian, operasi ini akan menggabungkan semua data tersebut ke dalam region global selama proses berlangsung. Lihat Google Cloud Customer Care jika ada masalah terkait residensi data.
- Jika lokasi set data baru diluncurkan, mungkin ada keterlambatan dalam ketersediaan data ekspor awal.
Harga
Mengekspor rekomendasi ke BigQuery tersedia untuk semua pelanggan Pemberi Rekomendasi berdasarkan tingkat harga Pemberi Rekomendasi mereka.
Izin yang diperlukan
Saat menyiapkan transfer data, Anda memerlukan izin berikut di tingkat project tempat Anda membuat transfer data:
bigquery.transfers.update- Memungkinkan Anda membuat transferbigquery.datasets.update- Memungkinkan Anda memperbarui tindakan pada set data targetresourcemanager.projects.update- Memungkinkan Anda memilih project tempat Anda ingin menyimpan data eksporpubsub.topics.list- Memungkinkan Anda memilih topik Pub/Sub untuk menerima notifikasi tentang ekspor Anda
Izin berikut diperlukan di level organisasi. Organisasi ini sesuai dengan organisasi yang disiapkan untuk ekspor.
recommender.resources.export- Memungkinkan Anda mengekspor rekomendasi ke BigQuery
Izin berikut diperlukan untuk mengekspor harga yang dinegosiasikan untuk rekomendasi penghematan biaya:
billing.resourceCosts.get at project level- Memungkinkan ekspor harga yang dinegosiasikan untuk rekomendasi level projectbilling.accounts.getSpendingInformation at billing account level- Memungkinkan ekspor harga yang dinegosiasikan untuk rekomendasi tingkat akun penagihan
Tanpa izin ini, rekomendasi penghematan biaya akan diekspor dengan harga standar, bukan harga yang dinegosiasikan.
Memberikan izin
Peran berikut harus diberikan pada project tempat Anda membuat transfer data:
- Peran BigQuery admin -
roles/bigquery.admin - Peran Project owner -
roles/owner - Peran Project Owner -
roles/owner - Peran Project Viewer -
roles/viewer - Peran Project Editor -
roles/editor - Peran Billing Account Administrator -
roles/billing.admin - Peran Billing Account Costs Manager -
roles/billing.costsManager - Peran Billing Account Viewer -
roles/billing.viewer
Agar Anda dapat membuat transfer dan memperbarui tindakan pada set data target, Anda harus memberikan peran berikut:
Ada beberapa peran yang berisi izin untuk memilih project guna menyimpan data ekspor Anda dan untuk memilih topik Pub/Sub guna menerima notifikasi. Agar kedua izin ini tersedia, Anda dapat memberikan peran berikut:
Ada beberapa peran yang berisi izin billing.resourceCosts.get untuk mengekspor harga yang dinegosiasikan untuk rekomendasi tingkat project penghematan biaya - Anda dapat memberikan salah satunya:
Ada beberapa peran yang berisi izin billing.accounts.getSpendingInformation untuk mengekspor harga yang dinegosiasikan untuk rekomendasi tingkat akun penagihan penghematan biaya - Anda dapat memberikan salah satunya:
Anda harus memberikan peran berikut di level organisasi:
- Peran Recommendations Exporter (
roles/recommender.exporter) di konsol Google Cloud .
Anda juga dapat membuat peran Kustom yang berisi izin yang diperlukan.
Membuat transfer data untuk rekomendasi
Buka formulir ekspor BigQuery untuk Active Assist.
Pilih Project Tujuan untuk menyimpan data rekomendasi.
Klik Berikutnya.
Klik Enable APIs guna mengaktifkan BigQuery API untuk ekspor. Proses ini dapat memerlukan waktu beberapa detik. Setelah selesai, klik Continue.
Pada formulir Configure Transfer, berikan detail berikut:
Di bagian Transfer config name, untuk Nama tampilan, masukkan nama untuk transfer. Nama transfer dapat berupa nilai apa pun yang memungkinkan Anda mengidentifikasi transfer dengan mudah jika Anda perlu mengubahnya nanti.
Di bagian Schedule options, untuk Schedule, biarkan nilai defaultnya (Start now) atau klik Start at a set time.
Untuk Repeats, pilih opsi seberapa sering transfer dijalankan.
- Harian (default)
- Mingguan
- Bulanan
- Khusus
- Sesuai permintaan
Untuk Tanggal mulai dan waktu proses, masukkan tanggal dan waktu untuk memulai transfer. Jika Anda memilih Mulai sekarang, opsi ini akan dinonaktifkan.
Di bagian Destination settings, untuk Destination dataset, pilih ID set data yang Anda buat untuk menyimpan data.
Di bagian Data source details:
Nilai default untuk organization_id adalah organisasi yang saat ini Anda lihat rekomendasinya. Jika ingin mengekspor rekomendasi ke organisasi lain, Anda dapat mengubahnya di bagian atas konsol di penampil organisasi.
(Opsional) Di bagian Notification options:
- Klik tombol untuk mengaktifkan notifikasi email. Saat Anda mengaktifkan opsi ini, administrator transfer akan menerima notifikasi email saat proses transfer gagal.
- Untuk Select a Pub/Sub topic, pilih nama topik atau klik Create a topic. Opsi ini mengonfigurasi notifikasi operasi Pub/Sub untuk transfer Anda.
Klik Create untuk membuat transfer.
Klik Allow pada pop-up izin.
Setelah transfer dibuat, Anda akan diarahkan kembali ke Active Assist. Anda dapat mengklik link untuk mengakses detail konfigurasi transfer. Atau, Anda dapat mengakses transfer dengan melakukan hal berikut:
Buka halaman BigQuery di konsol Google Cloud .
Klik Transfer Data. Anda dapat melihat semua transfer data yang tersedia.
Melihat histori operasi untuk transfer
Untuk melihat histori operasi transfer, lakukan hal berikut:
Buka halaman BigQuery di konsol Google Cloud .
Klik Transfer Data. Anda dapat melihat semua transfer data yang tersedia.
Klik transfer yang sesuai dalam daftar.
Dalam daftar transfer yang dijalankan yang ditampilkan di tab RUN HISTORY, pilih transfer yang ingin Anda lihat detailnya.
Panel Run details akan ditampilkan untuk setiap operasi transfer yang Anda pilih. Beberapa kemungkinan detail operasi yang ditampilkan adalah:
- Transfer ditangguhkan karena data sumber tidak tersedia.
- Tugas yang menunjukkan jumlah baris yang diekspor ke tabel
- Izin tidak ada untuk sumber data yang harus Anda berikan dan jadwalkan pengisian ulang nanti.
Kapan data Anda diekspor?
Saat Anda membuat transfer data, ekspor pertama akan dilakukan dalam dua hari. Setelah ekspor pertama, tugas ekspor akan berjalan sesuai frekuensi yang Anda minta pada waktu penyiapan. Kondisi berikut berlaku:
Tugas ekspor untuk hari tertentu (H) mengekspor data akhir hari (H) ke set data BigQuery Anda, yang biasanya selesai pada akhir hari berikutnya (H+1). Tugas ekspor berjalan dalam zona waktu PST dan mungkin tampak memiliki penundaan tambahan untuk zona waktu lain.
Tugas ekspor harian tidak akan berjalan hingga semua data untuk ekspor tersedia. Hal ini dapat menyebabkan variasi, dan terkadang penundaan, pada hari dan waktu set data Anda diperbarui. Oleh karena itu, sebaiknya gunakan snapshot data terbaru yang tersedia, daripada memiliki dependensi yang sensitif terhadap waktu pada tabel bertanggal tertentu.
Tugas ekspor mentransfer data terbaru yang tersedia per region - artinya, mungkin ada perbedaan pada tanggal terbaru ketersediaan rekomendasi untuk berbagai region.
Pesan status umum pada ekspor
Pelajari pesan status umum yang dapat Anda lihat saat mengekspor rekomendasi ke BigQuery.
Pengguna tidak memiliki izin yang diperlukan
Pesan berikut muncul saat pengguna tidak memiliki izin yang diperlukan recommender.resources.export. Anda akan melihat pesan berikut:
User does not have required permission "recommender.resources.export". Please, obtain the required permissions for the datasource and try again by triggering a backfill for this date
Untuk mengatasi masalah ini, berikan peran IAM roles/recommender.exporter kepada user/service account yang menyiapkan ekspor di tingkat organisasi untuk organisasi yang ekspornya disiapkan. Izin ini dapat diberikan melalui perintah gcloud di bawah:
Jika Pengguna:
gcloud organizations add-iam-policy-binding *<organization_id>* --member='user:*<user_name>*' --role='roles/recommender.exporter'Jika menggunakan Akun Layanan:
gcloud organizations add-iam-policy-binding *<organization_id>* --member='serviceAccount:*<service_acct_name>*' --role='roles/recommender.exporter'
Transfer ditangguhkan karena data sumber tidak tersedia
Pesan berikut muncul saat transfer dijadwalkan ulang karena data sumber belum tersedia. Ini bukan error. Artinya, pipeline ekspor belum selesai untuk hari tersebut. Transfer akan dijalankan ulang pada waktu baru yang dijadwalkan dan akan berhasil setelah pipeline ekspor selesai. Anda akan melihat pesan berikut:
Transfer deferred due to source data not being available
Data sumber tidak ditemukan
Pesan berikut muncul saat pipeline ekspor telah selesai, tetapi tidak ada rekomendasi atau insight yang ditemukan untuk organisasi yang disiapkan untuk ekspor. Anda akan melihat pesan berikut:
Source data not found for 'recommendations_export$<date>'insights_export$<date>
Pesan ini muncul karena alasan berikut:
- Pengguna menyiapkan ekspor kurang dari 2 hari yang lalu. Panduan pelanggan memberi tahu pelanggan bahwa ada penundaan satu hari sebelum ekspor mereka tersedia.
- Tidak ada rekomendasi atau insight yang tersedia untuk organisasi mereka pada hari tertentu. Hal ini mungkin merupakan kasus yang sebenarnya atau pipeline mungkin telah berjalan sebelum semua rekomendasi atau insight tersedia untuk hari tersebut.
Melihat tabel untuk transfer
Saat Anda mengekspor rekomendasi ke BigQuery, set data akan berisi dua tabel yang dipartisi berdasarkan tanggal:
- recommendations_export
- insight_export
Untuk mengetahui detail selengkapnya tentang tabel dan skema, lihat Membuat dan menggunakan tabel serta Menentukan skema.
Untuk melihat tabel transfer data, lakukan hal berikut:
Buka halaman BigQuery di konsol Google Cloud . Buka halaman BigQuery
Klik Transfer Data. Anda dapat melihat semua transfer data yang tersedia.
Klik transfer yang sesuai dalam daftar.
Klik tab CONFIGURATION, lalu klik set data.
Di panel Explorer, luaskan project Anda dan pilih set data. Deskripsi dan detail akan muncul di panel detail. Tabel untuk set data tercantum dengan nama set data di panel Explorer.
Menjadwalkan pengisian ulang
Rekomendasi untuk tanggal yang sudah lewat (tanggal ini lebih lambat dari tanggal saat organisasi memilih ikut serta dalam ekspor) dapat diekspor dengan menjadwalkan pengisian ulang. Untuk menjadwalkan pengisian ulang, lakukan hal berikut:
Buka halaman BigQuery di konsol Google Cloud .
Klik Transfer Data.
Di halaman Transfers, klik transfer yang sesuai dalam daftar.
Klik Schedule backfill.
Dalam dialog Jadwalkan pengisian ulang, pilih Tanggal mulai dan Tanggal akhir.
Untuk mengetahui informasi selengkapnya tentang cara menggunakan transfer, lihat Menggunakan transfer.
Skema ekspor
Tabel Ekspor Rekomendasi:
schema:
fields:
- name: cloud_entity_type
type: STRING
description: |
Represents what cloud entity type the recommendation was generated for - eg: project number, billing account
- name: cloud_entity_id
type: STRING
description: |
Value of the project number or billing account id
- name: name
type: STRING
description: |
Name of recommendation. A project recommendation is represented as
projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/recommendations/[RECOMMENDATION_ID]
- name: location
type: STRING
description: |
Location for which this recommendation is generated
- name: recommender
type: STRING
description: |
Recommender ID of the recommender that has produced this recommendation
- name: recommender_subtype
type: STRING
description: |
Contains an identifier for a subtype of recommendations produced for the
same recommender. Subtype is a function of content and impact, meaning a
new subtype will be added when either content or primary impact category
changes.
Examples:
For recommender = "google.iam.policy.Recommender",
recommender_subtype can be one of "REMOVE_ROLE"/"REPLACE_ROLE"
- name: target_resources
type: STRING
mode: REPEATED
description: |
Contains the fully qualified resource names for resources changed by the
operations in this recommendation. This field is always populated. ex:
[//cloudresourcemanager.googleapis.com/projects/foo].
- name: description
type: STRING
description: |
Required. Free-form human readable summary in English.
The maximum length is 500 characters.
- name: last_refresh_time
type: TIMESTAMP
description: |
Output only. Last time this recommendation was refreshed by the system that created it in the first place.
- name: primary_impact
type: RECORD
description: |
Required. The primary impact that this recommendation can have while trying to optimize
for one category.
schema:
fields:
- name: category
type: STRING
description: |
Category that is being targeted.
Values can be the following:
CATEGORY_UNSPECIFIED:
Default unspecified category. Do not use directly.
COST:
Indicates a potential increase or decrease in cost.
SECURITY:
Indicates a potential increase or decrease in security.
PERFORMANCE:
Indicates a potential increase or decrease in performance.
RELIABILITY:
Indicates a potential increase or decrease in reliability.
- name: cost_projection
type: RECORD
description: Optional. Use with CategoryType.COST
schema:
fields:
- name: cost
type: RECORD
description: |
An approximate projection on amount saved or amount incurred.
Negative cost units indicate cost savings and positive cost units indicate
increase. See google.type.Money documentation for positive/negative units.
schema:
fields:
- name: currency_code
type: STRING
description: The 3-letter currency code defined in ISO 4217.
- name: units
type: INTEGER
description: |
The whole units of the amount. For example if `currencyCode` is `"USD"`,
then 1 unit is one US dollar.
- name: nanos
type: INTEGER
description: |
Number of nano (10^-9) units of the amount.
The value must be between -999,999,999 and +999,999,999 inclusive.
If `units` is positive, `nanos` must be positive or zero.
If `units` is zero, `nanos` can be positive, zero, or negative.
If `units` is negative, `nanos` must be negative or zero.
For example $-1.75 is represented as `units`=-1 and `nanos`=-750,000,000.
- name: cost_in_local_currency
type: RECORD
description: |
An approximate projection on amount saved or amount incurred in the local currency.
Negative cost units indicate cost savings and positive cost units indicate
increase. See google.type.Money documentation for positive/negative units.
schema:
fields:
- name: currency_code
type: STRING
description: The 3-letter currency code defined in ISO 4217.
- name: units
type: INTEGER
description: |
The whole units of the amount. For example if `currencyCode` is `"USD"`,
then 1 unit is one US dollar.
- name: nanos
type: INTEGER
description: |
Number of nano (10^-9) units of the amount.
The value must be between -999,999,999 and +999,999,999 inclusive.
If `units` is positive, `nanos` must be positive or zero.
If `units` is zero, `nanos` can be positive, zero, or negative.
If `units` is negative, `nanos` must be negative or zero.
For example $-1.75 is represented as `units`=-1 and `nanos`=-750,000,000.
- name: duration
type: RECORD
description: Duration for which this cost applies.
schema:
fields:
- name: seconds
type: INTEGER
description: |
Signed seconds of the span of time. Must be from -315,576,000,000
to +315,576,000,000 inclusive. Note: these bounds are computed from:
60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years
- name: nanos
type: INTEGER
description: |
Signed fractions of a second at nanosecond resolution of the span
of time. Durations less than one second are represented with a 0
`seconds` field and a positive or negative `nanos` field. For durations
of one second or more, a non-zero value for the `nanos` field must be
of the same sign as the `seconds` field. Must be from -999,999,999
to +999,999,999 inclusive.
- name: pricing_type_name
type: STRING
description: |
A pricing type can either be based on the price listed on GCP (LIST) or a custom
price based on past usage (CUSTOM).
- name: reliability_projection
type: RECORD
description: Optional. Use with CategoryType.RELIABILITY
schema:
fields:
- name: risk_types
type: STRING
mode: REPEATED
description: |
The risk associated with the reliability issue.
RISK_TYPE_UNSPECIFIED:
Default unspecified risk. Do not use directly.
SERVICE_DISRUPTION:
Potential service downtime.
DATA_LOSS:
Potential data loss.
ACCESS_DENY:
Potential access denial. The service is still up but some or all clients
can not access it.
- name: details_json
type: STRING
description: |
Additional reliability impact details that is provided by the recommender in JSON
format.
- name: state
type: STRING
description: |
Output only. The state of the recommendation:
STATE_UNSPECIFIED:
Default state. Do not use directly.
ACTIVE:
Recommendation is active and can be applied. Recommendations content can
be updated by Google.
ACTIVE recommendations can be marked as CLAIMED, SUCCEEDED, or FAILED.
CLAIMED:
Recommendation is in claimed state. Recommendations content is
immutable and cannot be updated by Google.
CLAIMED recommendations can be marked as CLAIMED, SUCCEEDED, or FAILED.
SUCCEEDED:
Recommendation is in succeeded state. Recommendations content is
immutable and cannot be updated by Google.
SUCCEEDED recommendations can be marked as SUCCEEDED, or FAILED.
FAILED:
Recommendation is in failed state. Recommendations content is immutable
and cannot be updated by Google.
FAILED recommendations can be marked as SUCCEEDED, or FAILED.
DISMISSED:
Recommendation is in dismissed state.
DISMISSED recommendations can be marked as ACTIVE.
- name: ancestors
type: RECORD
description: |
Ancestry for the recommendation entity
schema:
fields:
- name: organization_id
type: STRING
description: |
Organization to which the recommendation project
- name: folder_ids
type: STRING
mode: REPEATED
description: |
Up to 5 levels of parent folders for the recommendation project
- name: associated_insights
type: STRING
mode: REPEATED
description: |
Insights associated with this recommendation. A project insight is represented as
projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/insights/[insight_id]
- name: recommendation_details
type: STRING
description: |
Additional details about the recommendation in JSON format.
schema:
- name: overview
type: RECORD
description: Overview of the recommendation in JSON format
- name: operation_groups
type: OperationGroup
mode: REPEATED
description: Operations to one or more Google Cloud resources grouped in such a way
that, all operations within one group are expected to be performed
atomically and in an order. More here: https://cloud.google.com/recommender/docs/key-concepts#operation_groups
- name: operations
type: Operation
description: An Operation is the individual action that must be performed as one of the atomic steps in a suggested recommendation. More here: https://cloud.google.com/recommender/docs/key-concepts?#operation
- name: state_metadata
type: map with key: STRING, value: STRING
description: A map of STRING key, STRING value of metadata for the state, provided by user or automations systems.
- name: additional_impact
type: Impact
mode: REPEATED
description: Optional set of additional impact that this recommendation may have when
trying to optimize for the primary category. These may be positive
or negative. More here: https://cloud.google.com/recommender/docs/key-concepts?#recommender_impact
- name: priority
type: STRING
description: |
Priority of the recommendation:
PRIORITY_UNSPECIFIED:
Default unspecified priority. Do not use directly.
P4:
Lowest priority.
P3:
Second lowest priority.
P2:
Second highest priority.
P1:
Highest priority.
Tabel Ekspor Insight:
schema:
- fields:
- name: cloud_entity_type
type: STRING
description: |
Represents what cloud entity type the recommendation was generated for - eg: project number, billing account
- name: cloud_entity_id
type: STRING
description: |
Value of the project number or billing account id
- name: name
type: STRING
description: |
Name of recommendation. A project recommendation is represented as
projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/recommendations/[RECOMMENDATION_ID]
- name: location
type: STRING
description: |
Location for which this recommendation is generated
- name: insight_type
type: STRING
description: |
Recommender ID of the recommender that has produced this recommendation
- name: insight_subtype
type: STRING
description: |
Contains an identifier for a subtype of recommendations produced for the
same recommender. Subtype is a function of content and impact, meaning a
new subtype will be added when either content or primary impact category
changes.
Examples:
For recommender = "google.iam.policy.Recommender",
recommender_subtype can be one of "REMOVE_ROLE"/"REPLACE_ROLE"
- name: target_resources
type: STRING
mode: REPEATED
description: |
Contains the fully qualified resource names for resources changed by the
operations in this recommendation. This field is always populated. ex:
[//cloudresourcemanager.googleapis.com/projects/foo].
- name: description
type: STRING
description: |
Required. Free-form human readable summary in English.
The maximum length is 500 characters.
- name: last_refresh_time
type: TIMESTAMP
description: |
Output only. Last time this recommendation was refreshed by the system that created it in the first place.
- name: category
type: STRING
description: |
Category being targeted by the insight. Can be one of:
Unspecified category.
CATEGORY_UNSPECIFIED = Unspecified category.
COST = The insight is related to cost.
SECURITY = The insight is related to security.
PERFORMANCE = The insight is related to performance.
MANAGEABILITY = The insight is related to manageability.
RELIABILITY = The insight is related to reliability.;
- name: state
type: STRING
description: |
Output only. The state of the recommendation:
STATE_UNSPECIFIED:
Default state. Do not use directly.
ACTIVE:
Recommendation is active and can be applied. Recommendations content can
be updated by Google.
ACTIVE recommendations can be marked as CLAIMED, SUCCEEDED, or FAILED.
CLAIMED:
Recommendation is in claimed state. Recommendations content is
immutable and cannot be updated by Google.
CLAIMED recommendations can be marked as CLAIMED, SUCCEEDED, or FAILED.
SUCCEEDED:
Recommendation is in succeeded state. Recommendations content is
immutable and cannot be updated by Google.
SUCCEEDED recommendations can be marked as SUCCEEDED, or FAILED.
FAILED:
Recommendation is in failed state. Recommendations content is immutable
and cannot be updated by Google.
FAILED recommendations can be marked as SUCCEEDED, or FAILED.
DISMISSED:
Recommendation is in dismissed state.
DISMISSED recommendations can be marked as ACTIVE.
- name: ancestors
type: RECORD
description: |
Ancestry for the recommendation entity
schema:
fields:
- name: organization_id
type: STRING
description: |
Organization to which the recommendation project
- name: folder_ids
type: STRING
mode: REPEATED
description: |
Up to 5 levels of parent folders for the recommendation project
- name: associated_recommendations
type: STRING
mode: REPEATED
description: |
Insights associated with this recommendation. A project insight is represented as
projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/insights/[insight_id]
- name: insight_details
type: STRING
description: |
Additional details about the insight in JSON format
schema:
fields:
- name: content
type: STRING
description: |
A struct of custom fields to explain the insight.
Example: "grantedPermissionsCount": "1000"
- name: observation_period
type: TIMESTAMP
description: |
Observation period that led to the insight. The source data used to
generate the insight ends at last_refresh_time and begins at
(last_refresh_time - observation_period).
- name: state_metadata
type: STRING
description: |
A map of metadata for the state, provided by user or automations systems.
- name: severity
type: STRING
description: |
Severity of the insight:
SEVERITY_UNSPECIFIED:
Default unspecified severity. Do not use directly.
LOW:
Lowest severity.
MEDIUM:
Second lowest severity.
HIGH:
Second highest severity.
CRITICAL:
Highest severity.
Contoh kueri
Anda dapat menggunakan contoh kueri berikut untuk menganalisis data yang diekspor.
Melihat penghematan biaya untuk rekomendasi yang durasi rekomendasinya ditampilkan dalam hari
SELECT name, recommender, target_resources,
case primary_impact.cost_projection.cost.units is null
when true then round(primary_impact.cost_projection.cost.nanos * power(10,-9),2)
else
round( primary_impact.cost_projection.cost.units +
(primary_impact.cost_projection.cost.nanos * power(10,-9)), 2)
end
as dollar_amt,
primary_impact.cost_projection.duration.seconds/(60*60*24) as duration_in_days
FROM `<project>.<dataset>.recommendations_export`
WHERE DATE(_PARTITIONTIME) = "<date>"
and primary_impact.category = "COST"
Melihat daftar peran IAM yang tidak digunakan
SELECT *
FROM `<project>.<dataset>.recommendations_export`
WHERE DATE(_PARTITIONTIME) = "<date>"
and recommender = "google.iam.policy.Recommender"
and recommender_subtype = "REMOVE_ROLE"
Melihat daftar peran yang diberikan yang harus diganti dengan peran yang lebih kecil
SELECT *
FROM `<project>.<dataset>.recommendations_export`
WHERE DATE(_PARTITIONTIME) = "<date>"
and recommender = "google.iam.policy.Recommender"
and recommender_subtype = "REPLACE_ROLE"
Melihat insight untuk rekomendasi
SELECT recommendations.name as recommendation_name,
insights.name as insight_name,
recommendations.cloud_entity_id,
recommendations.cloud_entity_type,
recommendations.recommender,
recommendations.recommender_subtype,
recommendations.description,
recommendations.target_resources,
recommendations.recommendation_details,
recommendations.state,
recommendations.last_refresh_time as recommendation_last_refresh_time,
insights.insight_type,
insights.insight_subtype,
insights.category,
insights.description,
insights.insight_details,
insights.state,
insights.last_refresh_time as insight_last_refresh_time
FROM `<project>.<dataset>.recommendations_export` as recommendations,
`<project>.<dataset>.insights_export` as insights
WHERE DATE(recommendations._PARTITIONTIME) = "<date>"
and DATE(insights._PARTITIONTIME) = "<date>"
and insights.name in unnest(recommendations.associated_insights)
Melihat rekomendasi untuk project yang termasuk dalam folder tertentu
Kueri ini menampilkan folder induk hingga lima level dari project.
SELECT *
FROM `<project>.<dataset>.recommendations_export`
WHERE DATE(_PARTITIONTIME) = "<date>"
and "<folder_id>" in unnest(ancestors.folder_ids)
Melihat rekomendasi untuk tanggal tersedia terbaru yang diekspor sejauh ini
DECLARE max_date TIMESTAMP;
SET max_date = (
SELECT MAX(_PARTITIONTIME) FROM
`<project>.<dataset>.recommendations_export`
);
SELECT *
FROM `<project>.<dataset>.recommendations_export`
WHERE _PARTITIONTIME = max_date
Menggunakan Spreadsheet untuk menjelajahi data BigQuery
Sebagai alternatif untuk menjalankan kueri di BigQuery, Anda dapat mengakses, menganalisis, memvisualisasikan, dan membagikan miliaran baris data BigQuery dari spreadsheet dengan Sheet yang Terhubung, konektor data BigQuery yang baru. Untuk mengetahui informasi selengkapnya, lihat Mulai menggunakan data BigQuery di Google Spreadsheet.
Menyiapkan Ekspor Menggunakan BigQuery Command Line & REST API
Mendapatkan izin yang diperlukan:
Anda bisa mendapatkan izin Identity and Access Management yang diperlukan melalui konsolGoogle Cloud atau command line.
- Command Line untuk Akun Layanan
- Command Line untuk Pengguna:
Misalnya, untuk menggunakan Command Line guna mendapatkan izin recommender.resources.export level organisasi untuk akun layanan:
gcloud organizations add-iam-policy-binding *<organization_id>* --member=serviceAccount:*<service_acct_name>*' --role='roles/recommender.exporter'Mendaftarkan project di sumber data BigQuery
Datasource to use: 6063d10f-0000-2c12-a706-f403045e6250Buat ekspor:
Menggunakan Command Line BigQuery:
bq mk \ --transfer_config \ --project_id=project_id \ --target_dataset=dataset_id \ --display_name=name \ --params='parameters' \ --data_source=data_source \ --service_account_name=service_account_name
Dengan:
- project_id adalah project ID Anda.
- dataset adalah ID set data target untuk konfigurasi transfer.
- name adalah nama tampilan untuk konfigurasi transfer. Nama transfer dapat berupa nilai apa pun yang memudahkan Anda mengidentifikasi transfer jika perlu mengubahnya nanti.
- parameters berisi parameter untuk konfigurasi transfer yang dibuat dalam format JSON. Untuk BigQuery Export Rekomendasi dan Insight, Anda harus memberikan organization_id yang rekomendasi dan insight-nya perlu diekspor. Format parameter: '{"organization_id":"<org id>"}'
- data_source Sumber data yang akan digunakan: '6063d10f-0000-2c12-a706-f403045e6250'
- service_account_name adalah nama akun layanan yang digunakan untuk
mengautentikasi ekspor Anda. Akun layanan harus dimiliki oleh
project_idyang sama yang digunakan untuk membuat transfer dan harus memiliki semua izin yang diperlukan yang tercantum di atas.
Mengelola ekspor yang ada melalui UI atau BigQuery Command Line:
Catatan - ekspor berjalan sebagai pengguna yang menyiapkan akun, terlepas dari siapa yang memperbarui konfigurasi ekspor di masa mendatang. Misalnya, jika ekspor disiapkan menggunakan akun layanan, dan kemudian pengguna manusia memperbarui konfigurasi ekspor melalui UI BigQuery Data Transfer Service, ekspor akan terus berjalan sebagai akun layanan. Dalam hal ini, pemeriksaan izin untuk 'recommender.resources.export' dilakukan untuk akun layanan setiap kali ekspor dijalankan.