ייצוא המלצות ל-BigQuery
סקירה כללית
עם BigQuery Export, אתם יכולים לראות תמונות מצב יומיות של המלצות לארגון שלכם. הפעולה הזו מתבצעת באמצעות שירות העברת הנתונים ל-BigQuery. במאמר שירותי המלצות תוכלו לראות אילו שירותי המלצות נכללים כיום בייצוא ל-BigQuery.
BigQuery Export תומך באפשרויות הבאות:
ייצוא של המלצות ותובנות לכל הפרויקטים, התיקיות והחשבונות לחיוב של ארגון (כולל המלצות ותובנות ברמת הארגון)
ייצוא של מחירים מוסכמים במקום מחירים רגילים להמלצות לחיסכון בעלויות.
לפני שמתחילים
לפני שיוצרים העברת נתונים של המלצות, צריך לבצע את הפעולות הבאות:
- נותנים לשירות העברת הנתונים ל-BigQuery הרשאה לנהל את העברת הנתונים. אם אתם משתמשים בממשק המשתמש של BigQuery באינטרנט כדי ליצור את ההעברה, אתם צריכים לאפשר חלונות קופצים מ-
console.cloud.google.comבדפדפן כדי שתוכלו לראות את ההרשאות. פרטים נוספים זמינים במאמר הפעלת שירות העברת הנתונים ל-BigQuery. - יוצרים מערך נתונים ב-BigQuery כדי לאחסן נתונים.
- העברת הנתונים מתבצעת באותו אזור שבו נוצר מערך הנתונים. אי אפשר לשנות את המיקום אחרי שיוצרים את מערך הנתונים ואת ההעברה.
- מערך הנתונים יכיל תובנות והמלצות מכל האזורים בעולם. לכן, הפעולה הזו תצבור את כל הנתונים האלה באזור גלובלי במהלך התהליך. אם יש לכם שאלות לגבי מיקום אחסון הנתונים, אתם יכולים לפנות ל-Google Cloud Customer Care.
- אם המיקום של מערך הנתונים הושק לאחרונה, יכול להיות שיהיה עיכוב בזמינות של נתוני הייצוא הראשוניים.
תמחור
כל הלקוחות של שירות ההמלצות יכולים לייצא המלצות ל-BigQuery, בהתאם לרמת התמחור של שירות ההמלצות.
ההרשאות הנדרשות
כשמגדירים את העברת הנתונים, צריך את ההרשאות הבאות ברמת הפרויקט שבו יוצרים את העברת הנתונים:
-
bigquery.transfers.update– מאפשרת ליצור את ההעברה -
bigquery.datasets.update– מאפשרת לעדכן פעולות בקבוצת הנתונים של היעד resourcemanager.projects.update– מאפשר לבחור פרויקט שבו רוצים לאחסן את הנתונים שמייצאים-
pubsub.topics.list– מאפשר לבחור נושא ב-Pub/Sub כדי לקבל התראות לגבי הייצוא
ההרשאה הבאה נדרשת ברמת הארגון. הארגון הזה תואם לארגון שעבורו מוגדר הייצוא.
-
recommender.resources.export– מאפשר לייצא המלצות ל-BigQuery.
כדי לייצא את המחירים המוסכמים להמלצות לחיסכון בעלויות, צריך את ההרשאות הבאות:
-
billing.resourceCosts.get at project level– מאפשר לייצא מחירים מוסכמים להמלצות ברמת הפרויקט -
billing.accounts.getSpendingInformation at billing account level– מאפשרת לייצא מחירים מוסכמים להמלצות ברמת החשבון לחיוב
בלי ההרשאות האלה, ההמלצות לחיסכון בעלויות ייוצאו עם מחירים רגילים במקום עם מחירים שסוכמו.
מתן הרשאות
צריך להקצות את התפקידים הבאים בפרויקט שבו יוצרים את העברת הנתונים:
- התפקיד אדמין ב-BigQuery –
roles/bigquery.admin - תפקיד Project Owner –
roles/owner - תפקיד Project Owner –
roles/owner - התפקיד "צפייה בפרויקט" –
roles/viewer - תפקיד עריכת פרויקטים –
roles/editor - התפקיד Billing Account Administrator –
roles/billing.admin - התפקיד ניהול עלויות בחשבון לחיוב –
roles/billing.costsManager - התפקיד Billing Account Viewer –
roles/billing.viewer
כדי לאפשר לכם ליצור העברה ולעדכן פעולות בקבוצת הנתונים של היעד, אתם צריכים להקצות את התפקיד הבא:
יש כמה תפקידים שכוללים הרשאות לבחירת פרויקט לאחסון נתוני הייצוא, ולבחירת נושא Pub/Sub לקבלת התראות. כדי ששתי ההרשאות האלה יהיו זמינות, אתם יכולים להקצות את התפקיד הבא:
יש כמה תפקידים שכוללים את ההרשאה billing.resourceCosts.get כדי לייצא את המחירים המוסכמים להמלצות ברמת הפרויקט לחיסכון בעלויות. אתם יכולים להקצות כל אחד מהם:
יש כמה תפקידים שכוללים את ההרשאה billing.accounts.getSpendingInformation, שמאפשרת לייצא את המחירים המוסכמים כדי לקבל המלצות לחיסכון בעלויות ברמת החשבון לחיוב. אתם יכולים להקצות כל אחד מהם:
צריך להקצות את התפקיד הבא ברמת הארגון:
- התפקיד ייצוא המלצות (
roles/recommender.exporter) במסוף Google Cloud .
אפשר גם ליצור תפקידים בהתאמה אישית שמכילים את ההרשאות הנדרשות.
יצירת העברת נתונים להמלצות
נכנסים לטופס הייצוא ל-BigQuery של Active Assist.
בוחרים את פרויקט היעד שבו רוצים לאחסן את נתוני ההמלצות.
לוחצים על הבא.
לוחצים על הפעלת ממשקי API כדי להפעיל את ממשקי ה-API של BigQuery לצורך הייצוא. הפעולה הזו עשויה להימשך כמה שניות. בסיום, לוחצים על המשך.
בטופס Configure Transfer, ממלאים את הפרטים הבאים:
בקטע Transfer config name, מזינים שם להעברה בשדה Display name. שם ההעברה יכול להיות כל ערך שמאפשר לכם לזהות בקלות את ההעברה, אם תצטרכו לשנות אותה מאוחר יותר.
בקטע Schedule options, בשדה Schedule, משאירים את ערך ברירת המחדל (Start now) או לוחצים על Start at a set time.
בקטע Repeats, בוחרים באיזו תדירות להפעיל את ההעברה.
- מדי יום (ברירת מחדל)
- שבועי
- כל חודש
- בהתאמה אישית
- על פי דרישה
בשדה Start date and run time, מזינים את התאריך והשעה שבהם רוצים להתחיל את ההעברה. אם בוחרים באפשרות התחלה מיידית, האפשרות הזו מושבתת.
בקטע Destination settings, בשדה Destination dataset בוחרים את מזהה מערך הנתונים שיצרתם כדי לאחסן את הנתונים.
בקטע פרטי מקור הנתונים:
ערך ברירת המחדל של organization_id הוא הארגון שאתם צופים בהמלצות שלו. אם רוצים לייצא המלצות לארגון אחר, אפשר לשנות את הארגון בחלק העליון של המסוף, ב-Organization Viewer.
(אופציונלי) בקטע אפשרויות להתראות:
- לוחצים על המתג כדי להפעיל את ההתראות באימייל. כשמפעילים את האפשרות הזו, האדמין של ההעברה מקבל התראה באימייל אם הרצת ההעברה נכשלת.
- בקטע Select a Pub/Sub topic, בוחרים את שם הנושא או לוחצים על Create a topic. האפשרות הזו מגדירה התראות על הפעלת Pub/Sub להעברה.
לוחצים על Create כדי ליצור את ההעברה.
לוחצים על אישור בחלון הקופץ של ההסכמה.
אחרי שיוצרים את ההעברה, המערכת מפנה אתכם בחזרה אל Active Assist. אפשר ללחוץ על הקישור כדי לגשת לפרטי הגדרות ההעברה. אפשר גם לגשת להעברות בדרך הבאה:
נכנסים לדף BigQuery במסוף Google Cloud .
לוחצים על העברות נתונים. אתם יכולים לראות את כל העברות הנתונים הזמינות.
איך רואים את היסטוריית ההרצות של העברה
כדי לראות את היסטוריית ההרצות של העברה:
נכנסים לדף BigQuery במסוף Google Cloud .
לוחצים על העברות נתונים. אתם יכולים לראות את כל העברות הנתונים הזמינות.
לוחצים על ההעברה לבעלות המתאימה ברשימה.
ברשימת ההעברות שמוצגת בכרטיסייה RUN HISTORY, בוחרים את ההעברה שרוצים לראות את הפרטים שלה.
החלונית Run details מוצגת להרצת ההעברה הספציפית שבחרתם. אלה חלק מהפרטים האפשריים שמוצגים לגבי ההרצה:
- ההעברה נדחתה כי נתוני המקור לא זמינים.
- משימה שמציינת את מספר השורות שיוצאו לטבלה
- חסרות הרשאות למקור נתונים שצריך להעניק, ואחר כך לתזמן מילוי חוסרים.
מתי הנתונים מיוצאים?
כשיוצרים העברת נתונים, הייצוא הראשון מתרחש תוך יומיים. אחרי הייצוא הראשון, משימות הייצוא פועלות בתדירות שביקשתם בזמן ההגדרה. התנאים הבאים חלים:
משימת הייצוא של יום ספציפי (D) מייצאת את הנתונים של סוף היום (D) למערך הנתונים ב-BigQuery, ובדרך כלל מסתיימת עד סוף היום הבא (D+1). משימת הייצוא פועלת באזור הזמן PST, ויכול להיות שבאזורי זמן אחרים ייראה כאילו יש עיכוב נוסף.
משימת הייצוא היומית לא פועלת עד שכל הנתונים לייצוא זמינים. כתוצאה מכך, יכולים להיות שינויים, ולפעמים עיכובים, ביום ובשעה שבהם קבוצת הנתונים מתעדכנת. לכן, מומלץ להשתמש בתמונת המצב העדכנית ביותר של הנתונים, במקום להסתמך על טבלאות עם תאריכים ספציפיים.
משימת הייצוא מעבירה את הנתונים הזמינים העדכניים ביותר לכל אזור – כלומר, יכול להיות הבדל בתאריך האחרון שבו ההמלצות לאזורים שונים זמינות.
הודעות סטטוס נפוצות לגבי ייצוא
מידע ולמידה על הודעות סטטוס נפוצות שאתם יכולים לראות כשאתם מייצאים המלצות ל-BigQuery.
למשתמש אין את ההרשאה הנדרשת
ההודעה הבאה מופיעה כשאין למשתמש את ההרשאה הנדרשת recommender.resources.export. תוצג ההודעה הבאה:
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
כדי לפתור את הבעיה, צריך להקצות את תפקיד ה-IAM roles/recommender.exporter ל-user/service account שמגדיר את הייצוא ברמת הארגון, לארגון שעבורו הוגדר הייצוא. אפשר לתת את ההרשאה באמצעות הפקודות הבאות ב-gcloud:
במקרה של משתמש:
gcloud organizations add-iam-policy-binding *<organization_id>* --member='user:*<user_name>*' --role='roles/recommender.exporter'במקרה של חשבון שירות:
gcloud organizations add-iam-policy-binding *<organization_id>* --member='serviceAccount:*<service_acct_name>*' --role='roles/recommender.exporter'
ההעברה נדחתה כי נתוני המקור לא זמינים
ההודעה הבאה מופיעה כשההעברה מתוזמנת מחדש כי נתוני המקור עדיין לא זמינים. זו לא שגיאה. זה אומר שצינורות עיבוד הנתונים של הייצוא עדיין לא סיימו את העבודה לאותו יום. ההעברה תופעל מחדש במועד החדש שנקבע, ותסתיים בהצלחה אחרי שצינורות עיבוד הנתונים של הייצוא יסיימו לפעול. תוצג ההודעה הבאה:
Transfer deferred due to source data not being available
לא נמצאו נתוני מקור
ההודעה הבאה מופיעה כשצינורות עיבוד הנתונים של הייצוא הסתיימו, אבל לא נמצאו המלצות או תובנות לארגון שהייצוא הוגדר בשבילו. תוצג ההודעה הבאה:
Source data not found for 'recommendations_export$<date>'insights_export$<date>
ההודעה הזו מופיעה מהסיבות הבאות:
- המשתמש הגדיר את הייצוא לפני פחות מיומיים. במדריך ללקוחות מצוין שהייצוא יהיה זמין בעיכוב של יום.
- אין המלצות או תובנות זמינות לארגון שלהם ביום הספציפי. יכול להיות שזה המצב בפועל, או שהצינורות הופעלו לפני שכל ההמלצות או התובנות היו זמינות לאותו יום.
הצגת הטבלאות של העברה
כשמייצאים המלצות ל-BigQuery, מערך הנתונים מכיל שתי טבלאות שמחולקות למחיצות לפי תאריך:
- recommendations_export
- insight_export
לפרטים נוספים על טבלאות וסכימות, קראו את המאמרים יצירה של טבלאות ושימוש בהן והגדרת סכימה.
כדי לראות את הטבלאות של העברת נתונים:
נכנסים לדף BigQuery במסוף Google Cloud . כניסה לדף BigQuery
לוחצים על העברות נתונים. אתם יכולים לראות את כל העברות הנתונים הזמינות.
לוחצים על ההעברה לבעלות המתאימה ברשימה.
לוחצים על הכרטיסייה CONFIGURATION ואז על מערך הנתונים.
בחלונית Explorer, מרחיבים את הפרויקט ובוחרים מערך נתונים. התיאור והפרטים מופיעים בחלונית הפרטים. הטבלאות של מערך הנתונים מופיעות עם שם מערך הנתונים בחלונית Explorer.
תזמון מילוי חוסרים
כדי לייצא המלצות לתאריך שכבר עבר (תאריך שמאוחר יותר מהתאריך שבו הארגון הצטרף לייצוא), אפשר לתזמן מילוי חוסרים (backfill). כדי לתזמן מילוי חוסרים:
נכנסים לדף BigQuery במסוף Google Cloud .
לוחצים על העברות נתונים.
בדף Transfers, לוחצים על העברה לבעלות המתאימה ברשימה.
לוחצים על Schedule backfill.
בתיבת הדו-שיח Schedule backfill, בוחרים את תאריך ההתחלה ואת תאריך הסיום.
מידע נוסף על עבודה עם העברות זמין במאמר עבודה עם העברות.
ייצוא סכימה
טבלת ייצוא ההמלצות:
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.
טבלת ייצוא התובנות:
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.
שאילתות לדוגמה
אתם יכולים להשתמש בשאילתות לדוגמה הבאות כדי לנתח את הנתונים שיוצאו.
הצגת החיסכון בעלויות של המלצות שמשך הזמן שלהן מוצג בימים
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"
הצגת רשימת התפקידים ב-IAM שלא נמצאים בשימוש
SELECT *
FROM `<project>.<dataset>.recommendations_export`
WHERE DATE(_PARTITIONTIME) = "<date>"
and recommender = "google.iam.policy.Recommender"
and recommender_subtype = "REMOVE_ROLE"
הצגת רשימה של תפקידים שניתנו וצריך להחליף אותם בתפקידים קטנים יותר
SELECT *
FROM `<project>.<dataset>.recommendations_export`
WHERE DATE(_PARTITIONTIME) = "<date>"
and recommender = "google.iam.policy.Recommender"
and recommender_subtype = "REPLACE_ROLE"
הצגת תובנות לגבי המלצה
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)
הצגת המלצות לפרויקטים ששייכים לתיקייה ספציפית
השאילתה הזו מחזירה תיקיות הורה עד חמש רמות מהפרויקט.
SELECT *
FROM `<project>.<dataset>.recommendations_export`
WHERE DATE(_PARTITIONTIME) = "<date>"
and "<folder_id>" in unnest(ancestors.folder_ids)
הצגת ההמלצות לתאריך הזמין האחרון שיוצא עד עכשיו
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
שימוש ב-Sheets כדי לחקור נתונים ב-BigQuery
במקום להריץ שאילתות ב-BigQuery, אתם יכולים לגשת למיליארדי שורות של נתוני BigQuery מתוך הגיליון האלקטרוני, לנתח ולהציג אותם באמצעים חזותיים וגם לשתף אותם באמצעות "גיליונות מקושרים" – מחבר נתוני BigQuery החדש. מידע נוסף זמין במאמר איך מתחילים לעבוד עם נתוני BigQuery ב-Google Sheets.
הגדרת הייצוא באמצעות שורת הפקודה של BigQuery ו-API בארכיטקטורת REST
-
אתם יכולים לקבל את ההרשאות הנדרשות לניהול הזהויות והרשאות הגישה דרך מסוףGoogle Cloud או שורת הפקודה.
- שורת הפקודה לחשבונות שירות
- שורת פקודה למשתמשים:
לדוגמה, כדי להשתמש בשורת הפקודה כדי לקבל את ההרשאה recommender.resources.export ברמת הארגון לחשבון השירות:
gcloud organizations add-iam-policy-binding *<organization_id>* --member=serviceAccount:*<service_acct_name>*' --role='roles/recommender.exporter' רישום פרויקט למקור נתונים ב-BigQuery
Datasource to use: 6063d10f-0000-2c12-a706-f403045e6250יוצרים את הייצוא:
שימוש בשורת הפקודה של 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
כאשר:
- project_id הוא מזהה הפרויקט.
- dataset הוא המזהה של מערך הנתונים שאליו רוצים להעביר את הנתונים.
- name הוא השם המוצג של הגדרת ההעברה. שם ההעברה יכול להיות כל ערך שמאפשר לכם לזהות בקלות את ההעברה אם תצטרכו לשנות אותה מאוחר יותר.
- parameters מכיל את הפרמטרים של הגדרת ההעברה שנוצרה בפורמט JSON. כדי לייצא המלצות ותובנות ל-BigQuery Export, צריך לציין את מזהה הארגון (organization_id) שממנו רוצים לייצא את ההמלצות והתובנות. פורמט הפרמטרים: '{"organization_id":"<org id>"}'
- data_source מקור הנתונים שבו צריך להשתמש: "6063d10f-0000-2c12-a706-f403045e6250"
- service_account_name הוא השם של חשבון השירות שמשמש לאימות הייצוא. חשבון השירות צריך להיות בבעלות של אותו
project_idשמשמש ליצירת ההעברה, וצריכות להיות לו כל ההרשאות הנדרשות שמפורטות למעלה.
ניהול של ייצוא קיים דרך ממשק המשתמש או שורת הפקודה של BigQuery:
הערה: הייצוא פועל כמשתמש שהגדיר את החשבון, בלי קשר למי שיעדכן את הגדרות הייצוא בעתיד. לדוגמה, אם הייצוא מוגדר באמצעות חשבון שירות, ובהמשך משתמש אנושי מעדכן את הגדרות הייצוא דרך ממשק המשתמש של שירות העברת הנתונים ל-BigQuery, הייצוא ימשיך לפעול כחשבון השירות. במקרה הזה, בדיקת ההרשאה recommender.resources.export מתבצעת בחשבון השירות בכל פעם שהייצוא פועל.