Reference documentation and code samples for the Cloud Monitoring V3 API class Google::Cloud::Monitoring::V3::QueryService::Client.
Client for the QueryService service.
The QueryService API is used to manage time series data in Cloud
Monitoring. Time series data is a collection of data points that describes
the time-varying values of a metric.
The configuration is set to the derived mode, meaning that values can be changed,
but structural changes (adding new fields, etc.) are not allowed. Structural changes
should be made on Client.configure.
See Configuration
for a description of the configuration fields.
# Create a client using the default configurationclient=::Google::Cloud::Monitoring::V3::QueryService::Client.new# Create a client using a custom configurationclient=::Google::Cloud::Monitoring::V3::QueryService::Client.newdo|config|config.timeout=10.0end
#logger
deflogger()->Logger
The logger used for request/response debug logging.
Queries time series by using Monitoring Query Language (MQL). We recommend
using PromQL instead of MQL. For more information about the status of MQL,
see the MQL deprecation
notice.
request (::Google::Cloud::Monitoring::V3::QueryTimeSeriesRequest, ::Hash) — A request object representing the call parameters. Required. To specify no
parameters, or to keep all the default parameter values, pass an empty Hash.
options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
Pass arguments to query_time_series via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).
Parameters
name (::String) —
Required. The
project on which
to execute the request. The format is:
projects/[PROJECT_ID_OR_NUMBER]
query (::String) — Required. The query in the Monitoring Query
Language format.
The default time zone is in UTC.
page_size (::Integer) — A positive number that is the maximum number of time_series_data to return.
page_token (::String) — If this field is not empty then it must contain the nextPageToken value
returned by a previous call to this method. Using this field causes the
method to return additional results from the previous method call.
Yields
(response, operation) — Access the result along with the RPC operation
require"google/cloud/monitoring/v3"# Create a client object. The client can be reused for multiple calls.client=Google::Cloud::Monitoring::V3::QueryService::Client.new# Create a request. To set request fields, pass in keyword arguments.request=Google::Cloud::Monitoring::V3::QueryTimeSeriesRequest.new# Call the query_time_series method.result=client.query_time_seriesrequest# The returned object is of type Gapic::PagedEnumerable. You can iterate# over elements, and API calls will be issued to fetch pages as needed.result.eachdo|item|# Each element is of type ::Google::Cloud::Monitoring::V3::TimeSeriesData.pitemend
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[],[],null,["# Cloud Monitoring V3 API - Class Google::Cloud::Monitoring::V3::QueryService::Client (v1.6.1)\n\nVersion latestkeyboard_arrow_down\n\n- [1.6.1 (latest)](/ruby/docs/reference/google-cloud-monitoring-v3/latest/Google-Cloud-Monitoring-V3-QueryService-Client)\n- [1.6.0](/ruby/docs/reference/google-cloud-monitoring-v3/1.6.0/Google-Cloud-Monitoring-V3-QueryService-Client)\n- [1.5.1](/ruby/docs/reference/google-cloud-monitoring-v3/1.5.1/Google-Cloud-Monitoring-V3-QueryService-Client)\n- [1.4.0](/ruby/docs/reference/google-cloud-monitoring-v3/1.4.0/Google-Cloud-Monitoring-V3-QueryService-Client)\n- [1.3.0](/ruby/docs/reference/google-cloud-monitoring-v3/1.3.0/Google-Cloud-Monitoring-V3-QueryService-Client)\n- [1.2.0](/ruby/docs/reference/google-cloud-monitoring-v3/1.2.0/Google-Cloud-Monitoring-V3-QueryService-Client)\n- [1.1.0](/ruby/docs/reference/google-cloud-monitoring-v3/1.1.0/Google-Cloud-Monitoring-V3-QueryService-Client)\n- [1.0.1](/ruby/docs/reference/google-cloud-monitoring-v3/1.0.1/Google-Cloud-Monitoring-V3-QueryService-Client)\n- [0.18.0](/ruby/docs/reference/google-cloud-monitoring-v3/0.18.0/Google-Cloud-Monitoring-V3-QueryService-Client)\n- [0.17.0](/ruby/docs/reference/google-cloud-monitoring-v3/0.17.0/Google-Cloud-Monitoring-V3-QueryService-Client)\n- [0.16.0](/ruby/docs/reference/google-cloud-monitoring-v3/0.16.0/Google-Cloud-Monitoring-V3-QueryService-Client)\n- [0.15.2](/ruby/docs/reference/google-cloud-monitoring-v3/0.15.2/Google-Cloud-Monitoring-V3-QueryService-Client)\n- [0.14.0](/ruby/docs/reference/google-cloud-monitoring-v3/0.14.0/Google-Cloud-Monitoring-V3-QueryService-Client)\n- [0.13.0](/ruby/docs/reference/google-cloud-monitoring-v3/0.13.0/Google-Cloud-Monitoring-V3-QueryService-Client)\n- [0.12.1](/ruby/docs/reference/google-cloud-monitoring-v3/0.12.1/Google-Cloud-Monitoring-V3-QueryService-Client)\n- [0.11.0](/ruby/docs/reference/google-cloud-monitoring-v3/0.11.0/Google-Cloud-Monitoring-V3-QueryService-Client)\n- [0.10.0](/ruby/docs/reference/google-cloud-monitoring-v3/0.10.0/Google-Cloud-Monitoring-V3-QueryService-Client)\n- [0.9.0](/ruby/docs/reference/google-cloud-monitoring-v3/0.9.0/Google-Cloud-Monitoring-V3-QueryService-Client)\n- [0.8.0](/ruby/docs/reference/google-cloud-monitoring-v3/0.8.0/Google-Cloud-Monitoring-V3-QueryService-Client)\n- [0.7.1](/ruby/docs/reference/google-cloud-monitoring-v3/0.7.1/Google-Cloud-Monitoring-V3-QueryService-Client) \nReference documentation and code samples for the Cloud Monitoring V3 API class Google::Cloud::Monitoring::V3::QueryService::Client.\n\nClient for the QueryService service.\n\n\n\u003cbr /\u003e\n\nThe QueryService API is used to manage time series data in Cloud\nMonitoring. Time series data is a collection of data points that describes\nthe time-varying values of a metric. \n\nInherits\n--------\n\n- Object\n\nMethods\n-------\n\n### .configure\n\n def self.configure() { |config| ... } -\u003e Client::Configuration\n\nConfigure the QueryService Client class.\n\n\n\u003cbr /\u003e\n\nSee [Configuration](/ruby/docs/reference/google-cloud-monitoring-v3/latest/Google-Cloud-Monitoring-V3-QueryService-Client-Configuration \"Google::Cloud::Monitoring::V3::QueryService::Client::Configuration (class)\")\nfor a description of the configuration fields. \n**Yields**\n\n- (config) --- Configure the Client client. \n**Yield Parameter**\n\n- **config** ([Client::Configuration](./Google-Cloud-Monitoring-V3-QueryService-Client-Configuration)) \n**Returns**\n\n- ([Client::Configuration](./Google-Cloud-Monitoring-V3-QueryService-Client-Configuration))\n**Example** \n\n```ruby\n# Modify the configuration for all QueryService clients\n::Google::Cloud::Monitoring::V3::QueryService::Client.configure do |config|\n config.timeout = 10.0\nend\n```\n\n### #configure\n\n def configure() { |config| ... } -\u003e Client::Configuration\n\nConfigure the QueryService Client instance.\n\n\nThe configuration is set to the derived mode, meaning that values can be changed,\nbut structural changes (adding new fields, etc.) are not allowed. Structural changes\nshould be made on [Client.configure](/ruby/docs/reference/google-cloud-monitoring-v3/latest/Google-Cloud-Monitoring-V3-QueryService-Client#Google__Cloud__Monitoring__V3__QueryService__Client_configure_class_ \"Google::Cloud::Monitoring::V3::QueryService::Client.configure (method)\").\n\n\u003cbr /\u003e\n\nSee [Configuration](/ruby/docs/reference/google-cloud-monitoring-v3/latest/Google-Cloud-Monitoring-V3-QueryService-Client-Configuration \"Google::Cloud::Monitoring::V3::QueryService::Client::Configuration (class)\")\nfor a description of the configuration fields. \n**Yields**\n\n- (config) --- Configure the Client client. \n**Yield Parameter**\n\n- **config** ([Client::Configuration](./Google-Cloud-Monitoring-V3-QueryService-Client-Configuration)) \n**Returns**\n\n- ([Client::Configuration](./Google-Cloud-Monitoring-V3-QueryService-Client-Configuration))\n\n### #initialize\n\n def initialize() { |config| ... } -\u003e Client\n\nCreate a new QueryService client object. \n**Yields**\n\n- (config) --- Configure the QueryService client. \n**Yield Parameter**\n\n- **config** ([Client::Configuration](./Google-Cloud-Monitoring-V3-QueryService-Client-Configuration)) \n**Returns**\n\n- ([Client](./Google-Cloud-Monitoring-V3-QueryService-Client)) --- a new instance of Client\n**Example** \n\n```ruby\n# Create a client using the default configuration\nclient = ::Google::Cloud::Monitoring::V3::QueryService::Client.new\n\n# Create a client using a custom configuration\nclient = ::Google::Cloud::Monitoring::V3::QueryService::Client.new do |config|\n config.timeout = 10.0\nend\n```\n\n### #logger\n\n def logger() -\u003e Logger\n\nThe logger used for request/response debug logging. \n**Returns**\n\n- (Logger)\n\n### #query_time_series\n\n def query_time_series(request, options = nil) -\u003e ::Gapic::PagedEnumerable\u003c::Google::Cloud::Monitoring::V3::TimeSeriesData\u003e\n def query_time_series(name: nil, query: nil, page_size: nil, page_token: nil) -\u003e ::Gapic::PagedEnumerable\u003c::Google::Cloud::Monitoring::V3::TimeSeriesData\u003e\n\nQueries time series by using Monitoring Query Language (MQL). We recommend\nusing PromQL instead of MQL. For more information about the status of MQL,\nsee the [MQL deprecation\nnotice](https://cloud.google.com/stackdriver/docs/deprecations/mql). \n**Overloads** \n\n def query_time_series(request, options = nil) -\u003e ::Gapic::PagedEnumerable\u003c::Google::Cloud::Monitoring::V3::TimeSeriesData\u003e\n\nPass arguments to `query_time_series` via a request object, either of type [Google::Cloud::Monitoring::V3::QueryTimeSeriesRequest](/ruby/docs/reference/google-cloud-monitoring-v3/latest/Google-Cloud-Monitoring-V3-QueryTimeSeriesRequest \"Google::Cloud::Monitoring::V3::QueryTimeSeriesRequest (class)\") or an equivalent Hash. \n**Parameters**\n\n- **request** ([::Google::Cloud::Monitoring::V3::QueryTimeSeriesRequest](./Google-Cloud-Monitoring-V3-QueryTimeSeriesRequest), ::Hash) --- A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.\n- **options** (::Gapic::CallOptions, ::Hash) --- Overrides the default settings for this call, e.g, timeout, retries, etc. Optional. \n\n def query_time_series(name: nil, query: nil, page_size: nil, page_token: nil) -\u003e ::Gapic::PagedEnumerable\u003c::Google::Cloud::Monitoring::V3::TimeSeriesData\u003e\n\nPass arguments to `query_time_series` via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above). \n**Parameters**\n\n- **name** (::String) ---\n\n Required. The\n [project](https://cloud.google.com/monitoring/api/v3#project_name) on which\n to execute the request. The format is: \n\n projects/[PROJECT_ID_OR_NUMBER]\n\n- **query** (::String) --- Required. The query in the [Monitoring Query\n Language](https://cloud.google.com/monitoring/mql/reference) format. The default time zone is in UTC.\n- **page_size** (::Integer) --- A positive number that is the maximum number of time_series_data to return.\n- **page_token** (::String) --- If this field is not empty then it must contain the `nextPageToken` value returned by a previous call to this method. Using this field causes the method to return additional results from the previous method call. \n**Yields**\n\n- (response, operation) --- Access the result along with the RPC operation \n**Yield Parameters**\n\n- **response** (::Gapic::PagedEnumerable\\\u003c[::Google::Cloud::Monitoring::V3::TimeSeriesData](./Google-Cloud-Monitoring-V3-TimeSeriesData)\\\u003e)\n- **operation** (::GRPC::ActiveCall::Operation) \n**Returns**\n\n- (::Gapic::PagedEnumerable\\\u003c[::Google::Cloud::Monitoring::V3::TimeSeriesData](./Google-Cloud-Monitoring-V3-TimeSeriesData)\\\u003e) \n**Raises**\n\n- (::Google::Cloud::Error) --- if the RPC is aborted.\n**Example**\n\nBasic example \n\n```ruby\nrequire \"google/cloud/monitoring/v3\"\n\n# Create a client object. The client can be reused for multiple calls.\nclient = Google::Cloud::Monitoring::V3::QueryService::Client.new\n\n# Create a request. To set request fields, pass in keyword arguments.\nrequest = Google::Cloud::Monitoring::V3::QueryTimeSeriesRequest.new\n\n# Call the query_time_series method.\nresult = client.query_time_series request\n\n# The returned object is of type Gapic::PagedEnumerable. You can iterate\n# over elements, and API calls will be issued to fetch pages as needed.\nresult.each do |item|\n # Each element is of type ::Google::Cloud::Monitoring::V3::TimeSeriesData.\n p item\nend\n```\n\n### #universe_domain\n\n def universe_domain() -\u003e String\n\nThe effective universe domain \n**Returns**\n\n- (String)"]]