Quickstart for using Monitoring Query Language

This Quickstart shows you how to use Monitoring Query Language (MQL) to explore metrics and create charts:

  1. Create a Compute Engine instance.

  2. Navigate to the Query Editor.

  3. Perform a query and create a chart.

Before you begin

To use MQL, you need to create a Google Cloud project and enable billing.

  1. Sign in to your Google Account.

    If you don't already have one, sign up for a new account.

  2. In the Cloud Console, on the project selector page, select or create a Cloud project.

    Go to the project selector page

  3. Make sure that billing is enabled for your Google Cloud project. Learn how to confirm billing is enabled for your project.

Create a Compute Engine instance

To have a Google Cloud resource to collect metrics from, create a Compute Engine instance by completing the following steps:

  1. From the Cloud Console menu, select Compute Engine.

    User interface for selecting a compute instance.

  2. Select Create instance, and then click Create.

Navigate to the Query Editor

To begin using MQL, do the following:

  1. From the Cloud Console menu, select Monitoring.

    The first time you access Monitoring in the Google Cloud Console, a Workspace must be created. If you've never used Monitoring, or if you've never created a multi-project Workspace, a Workspace is created automatically. Otherwise, a dialog appears and you can select between creating a Workspace and adding your project to an existing Workspace.

  2. From the Monitoring menu, select Metrics Explorer.

  3. Click Query Editor on the Build Your Query pane.

    User interface for selecting the Query Editor.

    The interface changes to the MQL Query Editor:

    User interface for Query Editor.

Use the Query Editor to construct, test, and run MQL queries.

Perform a simple query and create a chart

Create a simple query that charts the CPU utilization of your instance:

  1. Enter the following query and then click Run Query:

    fetch gce_instance::compute.googleapis.com/instance/cpu/utilization
    

    User interface for entering a query into the Query Editor.

    A chart appears displaying your instance's CPU utilization.

  2. To save the chart, click Save Chart. Give the chart a name and add it to either an existing dashboard or a new one. Then click Save.

    User interface for saving a chart.

The chart can be accessed by going to the Monitoring overview page, or if you saved it to a dashboard, by going to that dashboard's page.

Clean up

To avoid incurring charges to your Google Cloud account for the resources used in this quickstart, follow these steps.

  1. Go to the Identity and Access Management page in the Google Cloud Console:

    Go to project settings

  2. Click Shut down and follow the instructions.

What's next