--- title: GCP Monitor tags: gcp, grafana --- # Grafana * [grafana provisioning](https://grafana.com/docs/grafana/latest/administration/provisioning/) * [grafana configure](https://grafana.com/docs/grafana/latest/setup-grafana/configure-grafana/) # Datasources ```yaml= apiVersion: 1 deleteDatasources: - name: Google Cloud Monitoring - name: Prometheus datasources: - name: Google Cloud Monitoring type: stackdriver access: proxy jsonData: authenticationType: gce - name: Prometheus type: prometheus access: proxy url: https://prometheus-xxxxxx-as.a.run.app ``` # Dashboard ```yaml= apiVersion: 1 providers: - name: 'Cloud SQL Monitoring' options: path: conf/dashboards/Cloud SQL Monitoring.json - name: 'Cloud SQL(MySQL) Monitoring' options: path: conf/dashboards/Cloud SQL(MySQL) Monitoring.json - name: 'GCP Load Balancer Monitoring' options: path: conf/dashboards/GCP Load Balancer Monitoring.json - name: 'LB Backend Services' options: path: conf/dashboards/LB Backend Services.json - name: 'NodeJS Application Dashboard' options: path: 'conf/dashboards/NodeJS Application Dashboard.json' - name: 'Prometheus 2.0 Overview' options: path: 'conf/dashboards/Prometheus 2.0 Overview.json' - name: 'Prometheus Stats' options: path: 'conf/dashboards/Prometheus Stats.json' ``` # Grafana 環境變數 * GF_PATHS_PROVISIONING=conf/provisioning * GF_AUTH_GOOGLE_ENABLED=true * GF_SERVER_ROOT_URL=https://grafana.xxx.com * GF_AUTH_GOOGLE_CLIENT_ID=${CLIENT_ID} * GF_AUTH_GOOGLE_CLIENT_SECRET=${SECRET} * GF_AUTH_GOOGLE_ALLOWED_DOMAINS=xxx.com yyy.com * GF_AUTH_DISABLE_LOGIN_FORM=true # CloudRun權限 * Cloud Run Service Agent * Monitoring Metric Writer