Get job metrics (async)

Demonstrates how to get a collection of metrics describing the detailed progress of a job.

Code sample

Node.js

/**
 * TODO(developer): Uncomment these variables before running the sample.
 */
/**
 *  A project id.
 */
// const projectId = 'abc123'
/**
 *  The job to get metrics for.
 */
// const jobId = 'abc123'
/**
 *  Return only metric data that has changed since this time.
 *  Default is to return all information about all metrics for the job.
 */
// const startTime = {}
/**
 *  The regional endpoint 
 *  (https://cloud.google.com/dataflow/docs/concepts/regional-endpoints) that
 *  contains the job specified by job_id.
 */
// const location = 'abc123'

// Imports the Dataflow library
const {MetricsV1Beta3Client} = require('@google-cloud/dataflow').v1beta3;

// Instantiates a client
const dataflowClient = new MetricsV1Beta3Client();

async function callGetJobMetrics() {
  // Construct request
  const request = {
  };

  // Run request
  const response = await dataflowClient.getJobMetrics(request);
  console.log(response);
}

callGetJobMetrics();

Python

from google.cloud import dataflow_v1beta3


async def sample_get_job_metrics():
    # Create a client
    client = dataflow_v1beta3.MetricsV1Beta3AsyncClient()

    # Initialize request argument(s)
    request = dataflow_v1beta3.GetJobMetricsRequest(
    )

    # Make the request
    response = await client.get_job_metrics(request=request)

    # Handle the response
    print(response)

What's next

To search and filter code samples for other Google Cloud products, see the Google Cloud sample browser.