Viewing Monitored Metrics

Viewing metrics in the console

You can view your Cloud Functions with their execution times and execution counts in the Cloud Platform Console.

Retrieving metrics from the API

This example uses the Stackdriver Monitoring Client Library for Node.js to retrieve recorded metrics for a project's Cloud Functions:


// By default, the client will authenticate using the service account file
// specified by the GOOGLE_APPLICATION_CREDENTIALS environment variable and use
// the project specified by the GCLOUD_PROJECT environment variable. See
const Monitoring = require('@google-cloud/monitoring');

function getMetrics (callback) {
  // Instantiates a client
  const monitoring = Monitoring.v3().metricServiceApi();

  // Create two datestrings, a start and end range
  let oneWeekAgo = new Date();
  oneWeekAgo.setHours(oneWeekAgo.getHours() - (7 * 24));

  const options = {
    name: monitoring.projectPath(process.env.GCLOUD_PROJECT),
    // There is also:
    filter: 'metric.type=""',
    interval: {
      startTime: {
        seconds: oneWeekAgo.getTime() / 1000
      endTime: {
        seconds: / 1000
    view: 1


  let error;

  // Iterate over all elements.
    .on('error', (err) => {
      error = err;
    .on('data', (element) => console.log(element))
    .on('end', () => callback(error));

Monitor your resources on the go

Get the Google Cloud Console app to help you manage your projects.

Send feedback about...

Cloud Functions Documentation