Send feedback
Module query (2.27.2) Stay organized with collections
Save and categorize content based on your preferences.
Version latest keyboard_arrow_down
Classes
Query
(
client
,
project
,
metric_type
=
"compute.googleapis.com/instance/cpu/utilization"
,
end_time
=
None
,
days
=
0
,
hours
=
0
,
minutes
=
0
,
)
Query object for retrieving metric data.
client
:class: google.cloud.monitoring_v3.gapic. metric_service_client.MetricServiceClient
The client to use.
project
str
The project ID or number.
metric_type
str
The metric type name. The default value is :data: Query.DEFAULT_METRIC_TYPE <google.cloud.monitoring.query.Query.DEFAULT_METRIC_TYPE>
, but please note that this default value is provided only for demonstration purposes and is subject to change. See the supported metrics
_.
end_time
datetime.datetime
(Optional) The end time (inclusive) of the time interval for which results should be returned, as a datetime object. The default is the start of the current minute. The start time (exclusive) is determined by combining the values of days
, hours
, and minutes
, and subtracting the resulting duration from the end time. It is also allowed to omit the end time and duration here, in which case select_interval
must be called before the query is executed.
days
int
The number of days in the time interval.
hours
int
The number of hours in the time interval.
minutes
int
The number of minutes in the time interval.
`ValueError
if end_time
is specified but days
, hours
, and minutes
are all zero. If you really want to specify a point in time, use select_interval
. .. _supported metrics: https://cloud.google.com/monitoring/api/metrics
Send feedback
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License
, and code samples are licensed under the Apache 2.0 License
. For details, see the Google Developers Site Policies
. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-09-04 UTC.
Need to tell us more?
[[["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,["# Module query (2.27.2)\n\nVersion latestkeyboard_arrow_down\n\n- [2.27.2 (latest)](/python/docs/reference/monitoring/latest/google.cloud.monitoring_v3.query)\n- [2.27.0](/python/docs/reference/monitoring/2.27.0/google.cloud.monitoring_v3.query)\n- [2.26.0](/python/docs/reference/monitoring/2.26.0/google.cloud.monitoring_v3.query)\n- [2.25.0](/python/docs/reference/monitoring/2.25.0/google.cloud.monitoring_v3.query)\n- [2.24.0](/python/docs/reference/monitoring/2.24.0/google.cloud.monitoring_v3.query)\n- [2.23.1](/python/docs/reference/monitoring/2.23.1/google.cloud.monitoring_v3.query)\n- [2.22.2](/python/docs/reference/monitoring/2.22.2/google.cloud.monitoring_v3.query)\n- [2.21.0](/python/docs/reference/monitoring/2.21.0/google.cloud.monitoring_v3.query)\n- [2.20.0](/python/docs/reference/monitoring/2.20.0/google.cloud.monitoring_v3.query)\n- [2.19.4](/python/docs/reference/monitoring/2.19.4/google.cloud.monitoring_v3.query)\n- [2.18.0](/python/docs/reference/monitoring/2.18.0/google.cloud.monitoring_v3.query)\n- [2.17.0](/python/docs/reference/monitoring/2.17.0/google.cloud.monitoring_v3.query)\n- [2.16.0](/python/docs/reference/monitoring/2.16.0/google.cloud.monitoring_v3.query)\n- [2.15.1](/python/docs/reference/monitoring/2.15.1/google.cloud.monitoring_v3.query)\n- [2.14.2](/python/docs/reference/monitoring/2.14.2/google.cloud.monitoring_v3.query)\n- [2.13.0](/python/docs/reference/monitoring/2.13.0/google.cloud.monitoring_v3.query)\n- [2.12.0](/python/docs/reference/monitoring/2.12.0/google.cloud.monitoring_v3.query)\n- [2.11.3](/python/docs/reference/monitoring/2.11.3/google.cloud.monitoring_v3.query)\n- [2.10.1](/python/docs/reference/monitoring/2.10.1/google.cloud.monitoring_v3.query)\n- [2.9.2](/python/docs/reference/monitoring/2.9.2/google.cloud.monitoring_v3.query)\n- [2.8.0](/python/docs/reference/monitoring/2.8.0/google.cloud.monitoring_v3.query)\n- [2.7.0](/python/docs/reference/monitoring/2.7.0/google.cloud.monitoring_v3.query)\n- [2.6.0](/python/docs/reference/monitoring/2.6.0/google.cloud.monitoring_v3.query)\n- [2.5.2](/python/docs/reference/monitoring/2.5.2/google.cloud.monitoring_v3.query)\n- [2.4.2](/python/docs/reference/monitoring/2.4.2/google.cloud.monitoring_v3.query)\n- [2.3.0](/python/docs/reference/monitoring/2.3.0/google.cloud.monitoring_v3.query)\n- [2.2.1](/python/docs/reference/monitoring/2.2.1/google.cloud.monitoring_v3.query)\n- [2.1.0](/python/docs/reference/monitoring/2.1.0/google.cloud.monitoring_v3.query)\n- [2.0.1](/python/docs/reference/monitoring/2.0.1/google.cloud.monitoring_v3.query)\n- [1.1.2](/python/docs/reference/monitoring/1.1.2/google.cloud.monitoring_v3.query)\n- [1.0.0](/python/docs/reference/monitoring/1.0.0/google.cloud.monitoring_v3.query)\n- [0.36.2](/python/docs/reference/monitoring/0.36.2/google.cloud.monitoring_v3.query)\n- [0.35.0](/python/docs/reference/monitoring/0.35.0/google.cloud.monitoring_v3.query)\n- [0.34.0](/python/docs/reference/monitoring/0.34.0/google.cloud.monitoring_v3.query)\n- [0.33.0](/python/docs/reference/monitoring/0.33.0/google.cloud.monitoring_v3.query)\n- [0.32.0](/python/docs/reference/monitoring/0.32.0/google.cloud.monitoring_v3.query) \nTime series query for the `Google Stackdriver Monitoring API (V3)`_.\n\n.. _Google Stackdriver Monitoring API (V3):\n\u003chttps://cloud.google.com/monitoring/api/ref_v3/rest/v3/\u003e projects.timeSeries/list\n\nClasses\n-------\n\n### [Query](/python/docs/reference/monitoring/latest/google.cloud.monitoring_v3.query.Query)\n\n Query(\n client,\n project,\n metric_type=\"compute.googleapis.com/instance/cpu/utilization\",\n end_time=None,\n days=0,\n hours=0,\n minutes=0,\n )\n\nQuery object for retrieving metric data."]]