Skip to content
Last9 named a Gartner Cool Vendor in AI for SRE Observability for 2025! Read more →
Last9

Google Cloud SQL

Monitor Google Cloud SQL database metrics for MySQL, PostgreSQL, and SQL Server using OpenTelemetry collector with Last9

Use OpenTelemetry to collect Google CloudSQL metrics and send telemetry data to Last9.

This integration supports following CloudSQL databases:

  • MySQL
  • PostgreSQL
  • SQL Server

Prerequisites

Before setting up Google Cloud SQL monitoring, ensure you have:

  • Google Cloud account with administrative privileges or CloudSQL Admin privileges
  • Access to a project in Google Cloud Platform (GCP)
  • Google CloudSQL APIs enabled - follow this guide to enable APIs
  • Virtual Machine where you can run OpenTelemetry Collector to collect data from Google CloudSQL and send to Last9
  1. Setting up Service Account for Monitoring

    Create a Service Account:

    • Navigate to Google Cloud Console: https://console.cloud.google.com/
    • Go to “IAM & Admin” > “Service Accounts” in the left sidebar
    • Click “CREATE SERVICE ACCOUNT” at the top
    • Enter a name (e.g., “otel-collector”)
    • Optionally add a description (e.g., “Service account for OpenTelemetry Collector”)
    • Click “CREATE AND CONTINUE”

    Assign Required Roles:

    • Add the following roles:
      • “Monitoring Viewer” (for reading metrics)
      • “Monitoring Metric Reader” (for accessing metric data)
    • Click “CONTINUE” and then “DONE”

    Attach Service Account to VM Instance:

    • Navigate to “Compute Engine” > “VM instances”
    • For an existing VM:
      • Select the instance, click “STOP”
      • Once stopped, click “EDIT”
      • Under “Service account”, select your newly created service account
      • Click “SAVE” and restart the instance
    • For a new VM:
      • When creating the instance, select your service account under the “Identity and API access” section

    Alternative: Using Application Default Credentials:

    • If you cannot change the VM’s service account, you can configure Application Default Credentials
    • In the Service Account page, select your service account
    • Click on “KEYS” tab
    • Click “ADD KEY” > “Create new key”
    • Select JSON format and click “CREATE”
    • Upload the key file to your VM
    • Set the environment variable before starting the collector:
      export GOOGLE_APPLICATION_CREDENTIALS="/path/to/key.json"

    For more detailed information about authentication using service accounts, refer to Google Cloud’s Application Default Credentials documentation.

  2. Install OpenTelemetry Collector

    You can install either rpm or deb package depending on flavor of operating system you are using.

    Note: systemd is required for automatic service configuration.

    Installing rpm package:

    wget https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v0.118.0/otelcol-contrib_0.118.0_linux_amd64.rpm
    sudo rpm -ivh otelcol-contrib_0.118.0_linux_amd64.rpm

    More installation options can be found here.

  3. Configure Collector

    Use the following configuration for Otel Collector:

    receivers:
    googlecloudmonitoring:
    collection_interval: 60s
    project_id: gcp-project-id
    metrics_list:
    # Filter for specific metrics such cloudsql
    - metric_descriptor_filter: 'metric.type = starts_with("cloudsql.googleapis.com")'
    processors:
    batch:
    timeout: 20s
    send_batch_size: 100000
    send_batch_max_size: 100000
    resourcedetection/gcp:
    detectors: ["gcp"]
    exporters:
    otlp/last9:
    endpoint: "{{ .Logs.WriteURL }}"
    headers:
    "Authorization": "{{ .Logs.AuthValue }}"
    debug:
    verbosity: detailed
    service:
    pipelines:
    metrics:
    receivers: [googlecloudmonitoring]
    processors: [batch, resourcedetection/gcp]
    exporters: [otlp/last9]

    Note: Replace gcp-project-id with your actual Google Cloud project ID.

    The complete list of supported metrics for CloudSQL MySQL can be found here.

    The complete list of supported metrics for CloudSQL PostgreSQL can be found here.

    The complete list of supported metrics for CloudSQL SQL Server can be found here.

    Read more about the Google Cloud monitoring receiver configuration options here.

  4. Start Collector

    Run the otel collector using systemctl command:

    sudo systemctl start otelcol-contrib
    sudo systemctl status otelcol-contrib
    sudo systemctl restart otelcol-contrib
  5. Check Collector Logs

    Monitor the collector logs to ensure it’s working correctly:

    sudo journalctl -u otelcol-contrib -f

Verification

To verify the setup is working:

  1. Check that the collector service is running
  2. Review the collector logs for any errors
  3. Log into your Last9 account to confirm CloudSQL metrics are being received

Need Help?

If you encounter any issues or have questions: