Menu
Grafana Cloud

GCP Metrics integration for Grafana Cloud

Google Cloud Platform (GCP), offered by Google, is a suite of cloud computing services that runs on the same infrastructure that Google uses internally for its end-user products, such as Google Search, Gmail, Google Drive, and YouTube. Alongside a set of management tools, it provides a series of modular cloud services including computing, data storage, data analytics and machine learning.

The GCP Metrics integration enables you to send metrics from your GCP projects to Grafana Cloud.

This integration includes 1 pre-built dashboard to help monitor and visualize GCP Metrics metrics.

Before you begin

To export metrics from GCP, the Google Stackdriver Exporter is used. That exporter uses the Google Golang Client Library, which offers a variety of ways to provide credentials.

Please refer to the Google Application Default Credentials documentation to see how the credentials can be provided.

If you are using IAM roles, the roles/monitoring.viewer IAM role contains the required permissions. See the Access Control Guide for more information.

If you are still using the legacy Access scopes, the https://www.googleapis.com/auth/monitoring.read scope is required.

Install GCP Metrics integration for Grafana Cloud

  1. In your Grafana Cloud stack, click Connections in the left-hand menu.
  2. Find GCP Metrics and click its tile to open the integration.
  3. Review the prerequisites in the Configuration Details tab and set up Grafana Agent to send GCP Metrics metrics to your Grafana Cloud instance.
  4. Click Install to add this integration’s pre-built dashboard to your Grafana Cloud instance, and you can start monitoring your GCP Metrics setup.

Configuration snippets for Grafana Alloy

Advanced mode

The following snippets provide examples to guide you through the configuration process.

To instruct Grafana Alloy to scrape resource metrics within your GCP projects, manually copy and append the snippets to your alloy configuration file, then follow subsequent instructions.

Advanced integrations snippets

alloy
prometheus.exporter.gcp "integrations_gcp" {
        project_ids = [
                "<your-project>",
        ]

        metrics_prefixes = [
                "run.googleapis.com/",
                "cloudfunctions.googleapis.com/",
                "compute.googleapis.com/nat",
                "logging.googleapis.com/billing",
                "logging.googleapis.com/exports",
                "serviceruntime.googleapis.com/quota/",
                "storage.googleapis.com/",
                "pubsub.googleapis.com/subscription",
        ]
}

prometheus.scrape "integrations_gcp" {
    targets    = prometheus.exporter.gcp.integrations_gcp.targets
    forward_to = prometheus.remote_write.metrics_service.receiver
    job_name   = "integrations/gcp"
}

This integration is configured to work with the GCP metrics exporter, which is embedded in the Grafana Agent. Enable the integration by adding the code block in the above section to your agent configuration.

For a full list of configuration values, refer to the component documentation.

Below are the most common arguments:

project_ids

Google Cloud project ID from where we want to scrape metrics from.

metrics_prefixes

Google Monitoring Metric Type prefixes. In configuration, you must specify the prefixes you want to scrape metrics from, each prefix represents a specific GCP resource, potentially followed by the metric types you want to scrape. These can be as targeted or loose as needed. As an example with pubsub metrics:

All metrics:

  • pubsub.googleapis.com/

All snapshot specific metrics:

  • pubsub.googleapis.com/snapshot

All snapshot specific metrics and a few subscription metrics:

  • pubsub.googleapis.com/snapshot
  • pubsub.googleapis.com/subscription/num_undelivered_messages
  • pubsub.googleapis.com/subscription/oldest_unacked_message_age

extra_filters

Additional filters you can put on top of the metrics described above, to further refine the resources you would like to collect metrics from. The structure for these filters is <targeted_metric_prefix>:<filter_query>. The targeted_metric_prefix is used to ensure the filter is only applied to the metric_prefix(es) where it makes sense.

As an example with pubsub metrics:

metrics_prefixes: pubsub.googleapis.com/snapshot, pubsub.googleapis.com/subscription/num_undelivered_messages

targeted_metric_prefix options would be:

  • pubsub.googleapis.com (apply to all defined prefixes)
  • pubsub.googleapis.com/snapshot (apply to only snapshot metrics)
  • pubsub.googleapis.com/subscription (apply to only subscription metrics)

request_interval

The time range used when querying for metrics. Defaults to 5m when not set.

ingest_delay

Offset for the Google Monitoring Metrics interval into the past by the ingest delay from the metric metadata. When enabled this automatically adjusts the time range used when querying for metrics backwards based on the metadata GCP has published for how long the data can take to be ingested. Defaults to false when not set.

request_offset

Offset for the Google Monitoring Metrics interval into the past. Defaults to 0s when not set.

drop_delegated_projects

Drop metrics from attached projects and fetch project_id only. Defaults to false when not set.

gcp_client_timeout

How long should the collector wait for a result from the API. Defaults to 15s when not set.

Grafana Agent static configuration (deprecated)

The following section shows configuration for running Grafana Agent in static mode which is deprecated. You should use Grafana Alloy for all new deployments.

Dashboards

The GCP Metrics integration installs the following dashboards in your Grafana Cloud instance to help monitor your system.

  • GCP Metrics Overview

Overview

Overview

Changelog

md
# 0.0.1 - April 2023

* Initial release

Cost

By connecting your GCP Metrics instance to Grafana Cloud, you might incur charges. To view information on the number of active series that your Grafana Cloud account uses for metrics included in each Cloud tier, see Active series and dpm usage and Cloud tier pricing.