Creating charts and alerts

This page explains how to use logs-based metrics in Stackdriver Monitoring charts and alerting policies using the Google Cloud Platform Console.

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

Viewing 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 Platform 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.

Specifying 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 cannot be set. For details, go to 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.

Creating a logs-based metric chart

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

  1. Go to Stackdriver 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.

Tip: If you don't see data in the charting area, try broadening the chart's time period to 1w (one week) or 1m (one month).

Distribution metric charts

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.
  • They can be displayed as percentile lines by choosing an alignment option for the 5th, 50th, 95th, or 99th percentile values.

If there is data available in a Stackdriver Monitoring chart, then there is a View Logs option in its More menu. Selecting this option takes you to the Logs Viewer 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.

Creating 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 Platform 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 and Documentation sections.

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

  7. Click Save.

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

For a policy that monitors Stackdriver usage and alerts you when you approach the threshold for billing, go to Alerting on Stackdriver usage.

Troubleshooting

If you encounter issues, go to Troubleshooting.

What's next

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

Was this page helpful? Let us know how we did:

Send feedback about...

Stackdriver Logging
Need help? Visit our support page.