Configure charts and alerts

Stay organized with collections Save and categorize content based on your preferences.

This page explains how to create and manage logs-based metrics in Cloud Monitoring charts and alerting policies using the Google Cloud console.

To create an alerting policy using the Cloud Monitoring API, see Managing alerting policies by API. To use the Google Cloud CLI commands, see gcloud alpha monitoring policies.

For a general discussion of logs-based metrics, see Overview of logs-based metrics.

View logs-based metrics charts

The fastest way to look at a graph of your logs-based metrics is to use Metrics Explorer:

  1. Go to Logs-based metrics in the Google Cloud console:

    Go to Logs-based Metrics

  2. Find the metric you want to view, and then select View in Metrics Explorer from the metric's More menu.

    The following screenshot illustrates the data displayed by Metrics Explorer. In this case, the log bytes for a Compute Engine VM instance are displayed:

    Metrics explorer displaying Compute Engine VM Instance log bytes.

Specify logs-based metrics

If you wish to further refine the charted data, the Metric tab of the Metrics Explorer lets you build your query and dynamically displays your results. You can specify the following fields:

  • Find resource type and metric: The metric and the resource type are set for you. Adjust these values if you wish.

    If there is no data available for the metric, then the resource type can't be set. For details, see Troubleshooting.

  • Filter (optional): Select metric labels to filter on.

  • Group by (optional): Select metric labels by which to divide the time series.

  • Aggregator (optional): Select an aggregation function to be used to combine multiple time series.

  • Advanced options (optional): You can further specify your aggregation or customize your chart's legend.

  • Add metric: Once you have built your first query, you can build additional queries to display more metrics in the charting area.

Tip: If you don't see any data in the graph, try setting one of the aggregation options.

Create a logs-based metric chart

Create a chart in a Monitoring dashboard showing a logs-based metric. You can use either a counter metric or a distribution metric. Do the following:

  1. Go to Cloud Monitoring:

    Go to Monitoring

  2. Select Dashboards > Create Dashboard in the left-side navigation list. You see a blank dashboard with a button to add a chart.

    Alternatively, select Dashboards > [DASHBOARD_NAME] to add a chart to an existing dashboard.

  3. Click Add Chart on the Charts page. Fill out the form:

    • Chart title: Type in a name for the chart.
    • Resource type: Select Metric type.
    • Metric: Select the logs-based metric that you wish to display.
    • Chart type: For distribution metrics, there is an option to generate a heatmap:

      Heatmap chart creation

    • Click Save.

The Charts page contains other options for refining the charted data. For example, you can filter data by metric and resource labels.

Charts for distribution metrics

In addition to the features shared by all charts, charts that are based on distribution logs-based metrics have the following features:

  • They can be visualized as heatmaps where the intensity of the color in a given bucket range in the y-axis corresponds to the number of data samples in that bucket. For more information about charts for distribution metrics, see Charting distribution metrics.
  • They can be displayed as percentile lines by choosing an alignment option for the 5th, 50th, 95th, or 99th percentile values. For information about how these aligners work with distribution metrics, see Percentiles and distribution metrics.

If there is data available in a Monitoring chart, then there is a View Logs option in its More menu. Selecting this option takes you to the Logs Explorer for the time period seen in the chart.

View Logs isn't only for logs-based metrics, but rather lets you look at log entries that are relevant to whatever metrics are being displayed in the chart.

Create an alerting policy on a counter metric

An alerting policy describes a set of conditions that you want to monitor. When you create an alerting policy, you must also specify its conditions: what is monitored and when to trigger an alert.

To create an alerting policy on a logs-based counter metric, do the following:

  1. Go to Logs-based metrics in the Google Cloud console:

    Go to Logs-based Metrics

  2. Find the metric you want to explore and select Create alert from metric in the metric's More menu.

    The Conditions pane opens, with the logs-based metric you chose pre-populated in the Target dialog.

  3. In the Configuration dialog, fill in the Threshold value.

  4. Click Save, which displays the Create new alerting policy panel with your completed condition.

  5. Optional: Fill in the Notifications section. If you complete this section, then a notification is sent to each notification channel when an incident is created. This notification includes links to the incident and to Logs Explorer:

    Display of the view logs button on an alert notification.

  6. Optional: Fill in the Documentation section. The documentation you specify is included in notifications. Typically, the content includes information on how to respond to the alert notification.

  7. In the Name this policy section, enter a name for the alerting policy.

  8. Click Save.

For more information on alerting policies, see Introduction to alerting.

For a policy that monitors Cloud Logging and Cloud Monitoring usage and alerts you when you approach the threshold for billing, see Alerting on usage.


If you encounter issues, see Troubleshooting.

What's next

For deeper information on charting and alerting, read these Monitoring resources: