[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["難以理解","hardToUnderstand","thumb-down"],["資訊或程式碼範例有誤","incorrectInformationOrSampleCode","thumb-down"],["缺少我需要的資訊/範例","missingTheInformationSamplesINeed","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-09-04 (世界標準時間)。"],[],[],null,["# Optimize with Recommender\n\nRecommender is a service that\nautomatically provides recommendations and insights for using resources on\nGoogle Cloud, based on heuristic methods, machine learning, and current\nresource usage. Each recommendation includes a link you can click to put the\nrecommendation into effect for your service.\n\nThis guide shows how to use [Recommender](/recommender)\nto optimize Cloud Run services for security and costs.\n\nOptimize cost\n-------------\n\nRecommender optimizes costs for billing.\n\n### Optimize billing\n\nRecommender automatically looks at traffic received by your\nCloud Run service over the past month, and will recommend switching\nfrom *request-based billing* to *instance-based billing* , if this is cheaper.\nFor more details, see [billing settings](/run/docs/configuring/billing-settings).\n\nOptimize security\n-----------------\n\nRecommender increases security by optimizing:\n\n- Service accounts for a Cloud Run service so the service account has the minimal set of required permissions.\n- Security of the following items in environment variables:\n\n - Passwords\n - API keys\n - Google Application Credentials\n\nGoogle *does not* examine the values contained in those environment variables.\nRather, we do a *case insensitive* check on the variable **key names**, as shown in the following patterns:\n\n- The environment variable key is a case insensitive variant of `API KEY`, such as `API_KEY`, `api_key`, `APIKEY`, or `apikey`\n- The environment variable ends in a case insensitive variant of `PASSWORD`, such as `PASSWORD` or `password`\n- The environment variable is `GOOGLE_APPLICATION_CREDENTIALS`\n\n### Security issues addressed by Recommender\n\nThe following table shows what Recommender detects and helps you address:\n\nRecommendation availability after deployment\n--------------------------------------------\n\nRecommender automatically provides recommendations for a service after\nit has been deployed, after a period of time has elapsed, typically one day.\nAfter this period of time, recommendations for the service are displayed with\nthe service in the [Cloud Run service list](/run/docs/managing/services)\nin the Google Cloud console and in the\n[Recommendation Hub](/recommender/docs/recommendation-hub/identify-configuration-problems).\n\nAlternate ways of using recommendations\n---------------------------------------\n\nIn addition to the use of recommendations covered on this page inside the\nCloud Run UI, recommendations are also available through the following:\n\n- [Recommender API](/recommender/docs/using-api)\n- [BigQuery export](/recommender/docs/bq-export/export-recommendations-to-bq)\n- [Recommender Logs](/recommender/docs/viewing-logs)\n\nView and accept recommendations for Cloud Run\n---------------------------------------------\n\nTo view and accept a recommendation in the Cloud Run user interface:\n\n1. [Go to Cloud Run](https://console.cloud.google.com/run)\n\n2. Locate services in the list that have something in the *Recommendations*\n column.\n\n3. Click the **Security** icon for your service under the column heading\n *Recommendations*, to display the recommendation pane for your service.\n\n4. In the pane, read the insight about your service and the recommendation.\n\n5. If you accept the recommendation, click the button at the bottom of the pane\n to make the changes suggested by the recommendation.\n\n6. Follow the instructions and documentation to change your Cloud Run\n service as needed.\n\nView recommendations in Recommendation Hub\n------------------------------------------\n\nTo view recommendations in Recommendation Hub:\n\n[Go to Recommendation Hub](https://console.cloud.google.com/home/recommendations)\n\nFor more information, see the Recommendation Hub\n[Getting started](/recommender/docs/recommendation-hub/identify-configuration-problems) page.\n\nDismissing a recommendation\n---------------------------\n\nClick **Dismiss** if you want to dismiss the recommendation without applying it.\nThis prevents the recommendation for that function from appearing again for\n30 days.\n\nOptimize Cloud Run apps with Gemini assistance\n----------------------------------------------\n\n\u003cbr /\u003e\n\nYou can get AI-powered help from\n[Gemini Cloud Assist](/gemini/docs/cloud-assist/overview) chat to\nenhance performance and security. With Gemini Cloud Assist, you\ncan proactively address potential issues and vulnerabilities in your cloud\ninfrastructure, ensuring a robust and stable environment for your applications\nand services.\n\nTo use Gemini Cloud Assist from the Google Cloud console, do\nthe following:\n\n1. [Ensure that Gemini Cloud Assist is set up for your Google Cloud user account and project](/gemini/docs/cloud-assist/set-up-gemini).\n\n2. [Set up your Cloud Run development environment](/run/docs/setup)\n in your Google Cloud project and ensure you have the appropriate\n [deployment permissions](/run/docs/reference/iam/roles#additional-configuration).\n\n3. Go to the Cloud Run page in the Google Cloud console.\n\n [Go to Cloud Run](https://console.cloud.google.com/run)\n4. In the console toolbar, select a Google Cloud project. Use a project\n associated with a project ID you submitted after you were granted access to\n Gemini Cloud Assist.\n\n5. Click spark\n **Open or close Gemini AI chat**.\n\n The Gemini panel opens.\n6. If necessary, click **Accept** if you agree to the terms.\n\n7. If you have a question about a specific application, provide context by\n going to the page that shows your resource before asking your question. When\n generating a response, Gemini includes information about the\n current console page and project.\n\n8. Enter a prompt in the **Gemini** panel.\n\n The following table provide some example prompts for using\n Gemini Cloud Assist with Cloud Run.\n\nFor more details, see the following resources:\n\n- Learn how to [write better prompts](/gemini/docs/discover/write-prompts).\n- Learn how to use the [Gemini Cloud Assist panel](/gemini/docs/cloud-assist-panel).\n- Read [Use Gemini for AI assistance and development](/gemini/docs/overview).\n- Learn [how Gemini for Google Cloud uses your data](/gemini/docs/discover/data-governance)."]]