{"id":9782,"library":"google-cloud-monitoring-dashboards","title":"Google Cloud Monitoring Dashboards","description":"The `google-cloud-monitoring-dashboards` client library provides Python access to the Google Cloud Monitoring Dashboards API. It allows programmatic creation, management, and listing of custom dashboards for visualizing metrics in Google Cloud Monitoring. Part of the larger `google-cloud-python` monorepo, it receives frequent updates alongside other Google Cloud client libraries.","status":"active","version":"2.21.0","language":"en","source_language":"en","source_url":"https://github.com/googleapis/google-cloud-python/tree/main/packages/google-cloud-monitoring-dashboards","tags":["Google Cloud","Monitoring","Dashboards","observability","metrics","cloud"],"install":[{"cmd":"pip install google-cloud-monitoring-dashboards","lang":"bash","label":"Install stable version"}],"dependencies":[],"imports":[{"note":"Client classes are typically found within a versioned submodule, not directly under the main package.","wrong":"from google.cloud.monitoring_dashboards import DashboardsServiceClient","symbol":"DashboardsServiceClient","correct":"from google.cloud import monitoring_dashboards_v1"}],"quickstart":{"code":"import os\nfrom google.cloud import monitoring_dashboards_v1\n\n# Set your Google Cloud Project ID\nproject_id = os.environ.get(\"GOOGLE_CLOUD_PROJECT_ID\", \"your-gcp-project-id\") \n\ntry:\n    # Initialize the client\n    client = monitoring_dashboards_v1.DashboardsServiceClient()\n    \n    # The parent resource name for listing dashboards\n    parent = f\"projects/{project_id}\"\n\n    print(f\"Listing up to 5 dashboards for project: {project_id}\")\n    \n    # Iterate over and print dashboard display names\n    for dashboard in client.list_dashboards(request={\"parent\": parent}, page_size=5):\n        print(f\"  - {dashboard.display_name} (ID: {dashboard.name.split('/')[-1]})\")\n\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")\n    print(\"\\nEnsure you have authenticated (e.g., `gcloud auth application-default login` or set `GOOGLE_APPLICATION_CREDENTIALS`) and provided a valid project ID.\")","lang":"python","description":"Initializes the Monitoring Dashboards client and lists the first 5 dashboards in a specified Google Cloud project. Requires `GOOGLE_CLOUD_PROJECT_ID` environment variable or direct replacement of 'your-gcp-project-id'."},"warnings":[{"fix":"Authenticate using `gcloud auth application-default login` for local development or set the `GOOGLE_APPLICATION_CREDENTIALS` environment variable to a service account key file path for production/CI.","message":"Google Cloud client libraries expect specific authentication. If not configured, you'll encounter 'PermissionDenied' errors.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always ensure the correct Google Cloud project ID is provided, often in the `parent` argument of requests, and that resource names follow the API's expected format (e.g., `projects/{project_id}/dashboards/{dashboard_id}`).","message":"Many methods require a `project_id` or a fully qualified resource name (e.g., `projects/PROJECT_ID`). Misformed or missing project IDs lead to `NotFound` or `InvalidArgument` errors.","severity":"gotcha","affected_versions":"All versions"},{"fix":"The current version requires Python >=3.9. Upgrade your Python environment to 3.9 or higher if you encounter installation issues or runtime errors related to unsupported Python versions. Check `requires_python` in `setup.py` or PyPI metadata for exact requirements.","message":"Older versions of Google Cloud client libraries might drop support for End-of-Life Python versions. Ensure your environment uses a supported Python version.","severity":"breaking","affected_versions":"<=2.x.x"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Ensure the user or service account has the `Monitoring Editor` (roles/monitoring.editor) or `Monitoring Viewer` (roles/monitoring.viewer) role, or a custom role with `monitoring.dashboards.list` (for listing) and `monitoring.dashboards.create` (for creation) permissions.","cause":"The authenticated principal (user or service account) lacks the necessary IAM permissions to access Monitoring Dashboards in the specified project.","error":"google.api_core.exceptions.PermissionDenied: 403 Permission 'monitoring.dashboards.list' denied on resource '//monitoring.googleapis.com/projects/PROJECT_NUMBER'"},{"fix":"Verify the `project_id` is correct. Check for typos. Ensure the authenticated principal has permission to view the project metadata via IAM.","cause":"The provided `project_id` is incorrect, the project does not exist, or the authenticated principal does not have permission to view it.","error":"google.api_core.exceptions.NotFound: 404 Project 'non-existent-project-123' not found or user does not have permission."},{"fix":"Run `pip install google-cloud-monitoring-dashboards`. Ensure your import statement is `from google.cloud import monitoring_dashboards_v1`.","cause":"The `google-cloud-monitoring-dashboards` library is not installed or the import path is incorrect.","error":"ModuleNotFoundError: No module named 'google.cloud.monitoring_dashboards_v1'"}]}