Metrics: search

Requires authorization

Search the metrics that match the given terms. Large number of metrics will be paginated, use the nextPageToken returned in the response to request subsequent pages of results by setting the pageToken query parameter to the value of the nextPageToken. Try it now or see an example.


HTTP request



Parameter name Value Description
Path parameters
project string The project id. The value can be the numeric project ID or string-based project name.
Optional query parameters
count integer Maximum number of metrics per page. Used for pagination. If not specified, count = 100. Acceptable values are 1 to 1000, inclusive. (Default: 100)
pageToken string The pagination token, which is used to page through large result sets. Set this value to the value of the nextPageToken to retrieve the next page of results.
term string The regular expression terms that used to match the metric. Multiple terms are joined by Boolean And.


This request requires authorization with the following scope (read more about authentication and authorization).


Request body

Do not supply a request body with this method.


If successful, this method returns a response body with the following structure:

  "kind": "cloudmonitoring#searchMetricResponse",
  "metric": [
    metrics Resource
  "totalResults": long,
  "nextPageToken": string
Property name Value Description Notes
kind string Identifies what kind of resource this is. Value: the fixed string "cloudmonitoring#searchMetricResponse".
metric[] list The returned metrics.
totalResults long Total number of metrics found by this search. Since results are paginated, some metrics might not be included in this response page.
nextPageToken string Pagination token. If present, indicates that additional results are available for retrieval. To access the results past the pagination limit, set this value to the pageToken query parameter.


Note: The code examples available for this method do not represent all supported programming languages (see the client libraries page for a list of supported languages).


Uses the Java client library.



// ...

public class MyClass {

  // ...

   * Search for Timeseries metrics by name.
   * @param service Client Monitoring API service instance.
   * @param projectName The name of the project to get monitoring data about.
   * @param searchTerm The regular expression terms to use in the search. Multiple terms are joined with the Boolean "And"
  private static void searchMetrics(Clientmonitoring service, String projectName,
      String searchTerm) {
    Metrics metrics = new Metrics();

    try {
    } catch (IOException e) {

  // ...



Uses the Python client library.

body = {
    'project': projectName,
    'term': searchTerm
    return service.metrics().search(body=body).execute()
  except errors.HttpError, error:
    print 'An error occurred: %s' % error


Uses the Ruby client library.

# Search for Timeseries metrics by name.
# @param [Google::APIClient] client
#   Authorized client instance.
# @param [String] project_name
#   The name of the project to get monitoring data about.
# @param [String] search_term
#   The regular expression terms to use in the search. Multiple terms are joined with the Boolean "And"
def search_metrics(client, project_name, search_term)
  cloudmonitoring = client.discovered_api('cloudmonitoring', 'v2beta1')
  result = client.execute(
    :api_method =>,
    :body_object => { 'project' => project_name, 'term' => search_term })
  if result.error?
    puts "An error occurred: #{['error']['message']}"


Uses the JavaScript client library.

gapi.client.load('cloudmonitoring', 'v2beta1', function() {
  var request ={
    'project': projectName,
    'term': searchTerm
  request.execute(function(resp){ });

Try it!

Use the APIs Explorer below to call this method on live data and see the response. Alternatively, try the standalone Explorer.

Monitor your resources on the go

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

Send feedback about...

Stackdriver Monitoring