MetricServiceClient(
transport=None,
channel=None,
credentials=None,
client_config=None,
client_info=None,
client_options=None,
)
Manages metric descriptors, monitored resource descriptors, and time series data.
Methods
MetricServiceClient
MetricServiceClient(
transport=None,
channel=None,
credentials=None,
client_config=None,
client_info=None,
client_options=None,
)
Constructor.
Parameters | |
---|---|
Name | Description |
channel |
grpc.Channel
DEPRECATED. A |
credentials |
google.auth.credentials.Credentials
The authorization credentials to attach to requests. These credentials identify this application to the service. If none are specified, the client will attempt to ascertain the credentials from the environment. This argument is mutually exclusive with providing a transport instance to |
client_config |
dict
DEPRECATED. A dictionary of call options for each method. If not specified, the default configuration is used. |
client_info |
google.api_core.gapic_v1.client_info.ClientInfo
The client info used to send a user-agent string along with API requests. If |
client_options |
Union[dict, google.api_core.client_options.ClientOptions]
Client options used to set user options on the client. API Endpoint should be set through client_options. |
create_metric_descriptor
create_metric_descriptor(name, metric_descriptor, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)
Creates a new metric descriptor. User-created metric descriptors define
custom metrics <https://cloud.google.com/monitoring/custom-metrics>
__.
.. rubric:: Example
from google.cloud import monitoring_v3
client = monitoring_v3.MetricServiceClient()
name = client.project_path('[PROJECT]')
TODO: Initialize
metric_descriptor
:metric_descriptor = {}
response = client.create_metric_descriptor(name, metric_descriptor)
Parameters | |
---|---|
Name | Description |
name |
str
The project on which to execute the request. The format is |
metric_descriptor |
Union[dict, MetricDescriptor]
The new |
retry |
Optional[google.api_core.retry.Retry]
A retry object used to retry requests. If |
timeout |
Optional[float]
The amount of time, in seconds, to wait for the request to complete. Note that if |
metadata |
Optional[Sequence[Tuple[str, str]]]
Additional metadata that is provided to the method. |
Exceptions | |
---|---|
Type | Description |
google.api_core.exceptions.GoogleAPICallError | If the request failed for any reason. |
google.api_core.exceptions.RetryError | If the request failed due to a retryable error and retry attempts failed. |
ValueError | If the parameters are invalid. |
create_time_series
create_time_series(name, time_series, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)
Creates or adds data to one or more time series. The response is empty if all time series in the request were written. If any time series could not be written, a corresponding failure message is included in the error response.
.. rubric:: Example
from google.cloud import monitoring_v3
client = monitoring_v3.MetricServiceClient()
name = client.project_path('[PROJECT]')
TODO: Initialize
time_series
:time_series = []
client.create_time_series(name, time_series)
Parameters | |
---|---|
Name | Description |
name |
str
The project on which to execute the request. The format is |
time_series |
list[Union[dict, TimeSeries]]
The new data to be added to a list of time series. Adds at most one data point to each of several time series. The new data point must be more recent than any other point in its time series. Each |
retry |
Optional[google.api_core.retry.Retry]
A retry object used to retry requests. If |
timeout |
Optional[float]
The amount of time, in seconds, to wait for the request to complete. Note that if |
metadata |
Optional[Sequence[Tuple[str, str]]]
Additional metadata that is provided to the method. |
Exceptions | |
---|---|
Type | Description |
google.api_core.exceptions.GoogleAPICallError | If the request failed for any reason. |
google.api_core.exceptions.RetryError | If the request failed due to a retryable error and retry attempts failed. |
ValueError | If the parameters are invalid. |
delete_metric_descriptor
delete_metric_descriptor(name, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)
Deletes a metric descriptor. Only user-created custom
metrics <https://cloud.google.com/monitoring/custom-metrics>
__ can be
deleted.
.. rubric:: Example
from google.cloud import monitoring_v3
client = monitoring_v3.MetricServiceClient()
name = client.metric_descriptor_path('[PROJECT]', '[METRIC_DESCRIPTOR]')
client.delete_metric_descriptor(name)
Parameters | |
---|---|
Name | Description |
name |
str
The metric descriptor on which to execute the request. The format is |
retry |
Optional[google.api_core.retry.Retry]
A retry object used to retry requests. If |
timeout |
Optional[float]
The amount of time, in seconds, to wait for the request to complete. Note that if |
metadata |
Optional[Sequence[Tuple[str, str]]]
Additional metadata that is provided to the method. |
Exceptions | |
---|---|
Type | Description |
google.api_core.exceptions.GoogleAPICallError | If the request failed for any reason. |
google.api_core.exceptions.RetryError | If the request failed due to a retryable error and retry attempts failed. |
ValueError | If the parameters are invalid. |
from_service_account_file
from_service_account_file(filename, *args, **kwargs)
Creates an instance of this client using the provided credentials file.
Parameter | |
---|---|
Name | Description |
filename |
str
The path to the service account private key json file. |
Returns | |
---|---|
Type | Description |
MetricServiceClient | The constructed client. |
from_service_account_json
from_service_account_json(filename, *args, **kwargs)
Creates an instance of this client using the provided credentials file.
Parameter | |
---|---|
Name | Description |
filename |
str
The path to the service account private key json file. |
Returns | |
---|---|
Type | Description |
MetricServiceClient | The constructed client. |
get_metric_descriptor
get_metric_descriptor(name, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)
Gets a single metric descriptor. This method does not require a Stackdriver account.
.. rubric:: Example
from google.cloud import monitoring_v3
client = monitoring_v3.MetricServiceClient()
name = client.metric_descriptor_path('[PROJECT]', '[METRIC_DESCRIPTOR]')
response = client.get_metric_descriptor(name)
Parameters | |
---|---|
Name | Description |
name |
str
The metric descriptor on which to execute the request. The format is |
retry |
Optional[google.api_core.retry.Retry]
A retry object used to retry requests. If |
timeout |
Optional[float]
The amount of time, in seconds, to wait for the request to complete. Note that if |
metadata |
Optional[Sequence[Tuple[str, str]]]
Additional metadata that is provided to the method. |
Exceptions | |
---|---|
Type | Description |
google.api_core.exceptions.GoogleAPICallError | If the request failed for any reason. |
google.api_core.exceptions.RetryError | If the request failed due to a retryable error and retry attempts failed. |
ValueError | If the parameters are invalid. |
get_monitored_resource_descriptor
get_monitored_resource_descriptor(name, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)
Gets a single monitored resource descriptor. This method does not require a Stackdriver account.
.. rubric:: Example
from google.cloud import monitoring_v3
client = monitoring_v3.MetricServiceClient()
name = client.monitored_resource_descriptor_path('[PROJECT]', '[MONITORED_RESOURCE_DESCRIPTOR]')
response = client.get_monitored_resource_descriptor(name)
Parameters | |
---|---|
Name | Description |
name |
str
The monitored resource descriptor to get. The format is |
retry |
Optional[google.api_core.retry.Retry]
A retry object used to retry requests. If |
timeout |
Optional[float]
The amount of time, in seconds, to wait for the request to complete. Note that if |
metadata |
Optional[Sequence[Tuple[str, str]]]
Additional metadata that is provided to the method. |
Exceptions | |
---|---|
Type | Description |
google.api_core.exceptions.GoogleAPICallError | If the request failed for any reason. |
google.api_core.exceptions.RetryError | If the request failed due to a retryable error and retry attempts failed. |
ValueError | If the parameters are invalid. |
list_metric_descriptors
list_metric_descriptors(name, filter_=None, page_size=None, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)
Lists metric descriptors that match a filter. This method does not require a Stackdriver account.
.. rubric:: Example
from google.cloud import monitoring_v3
client = monitoring_v3.MetricServiceClient()
name = client.project_path('[PROJECT]')
Iterate over all results
for element in client.list_metric_descriptors(name): ... # process element ... pass
Alternatively:
Iterate over results one page at a time
for page in client.list_metric_descriptors(name).pages: ... for element in page: ... # process element ... pass
Parameters | |
---|---|
Name | Description |
name |
str
The project on which to execute the request. The format is |
filter_ |
str
If this field is empty, all custom and system-defined metric descriptors are returned. Otherwise, the |
page_size |
int
The maximum number of resources contained in the underlying API response. If page streaming is performed per- resource, this parameter does not affect the return value. If page streaming is performed per-page, this determines the maximum number of resources in a page. |
retry |
Optional[google.api_core.retry.Retry]
A retry object used to retry requests. If |
timeout |
Optional[float]
The amount of time, in seconds, to wait for the request to complete. Note that if |
metadata |
Optional[Sequence[Tuple[str, str]]]
Additional metadata that is provided to the method. |
Exceptions | |
---|---|
Type | Description |
google.api_core.exceptions.GoogleAPICallError | If the request failed for any reason. |
google.api_core.exceptions.RetryError | If the request failed due to a retryable error and retry attempts failed. |
ValueError | If the parameters are invalid. |
list_monitored_resource_descriptors
list_monitored_resource_descriptors(name, filter_=None, page_size=None, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)
Lists monitored resource descriptors that match a filter. This method does not require a Stackdriver account.
.. rubric:: Example
from google.cloud import monitoring_v3
client = monitoring_v3.MetricServiceClient()
name = client.project_path('[PROJECT]')
Iterate over all results
for element in client.list_monitored_resource_descriptors(name): ... # process element ... pass
Alternatively:
Iterate over results one page at a time
for page in client.list_monitored_resource_descriptors(name).pages: ... for element in page: ... # process element ... pass
Parameters | |
---|---|
Name | Description |
name |
str
The project on which to execute the request. The format is |
filter_ |
str
An optional |
page_size |
int
The maximum number of resources contained in the underlying API response. If page streaming is performed per- resource, this parameter does not affect the return value. If page streaming is performed per-page, this determines the maximum number of resources in a page. |
retry |
Optional[google.api_core.retry.Retry]
A retry object used to retry requests. If |
timeout |
Optional[float]
The amount of time, in seconds, to wait for the request to complete. Note that if |
metadata |
Optional[Sequence[Tuple[str, str]]]
Additional metadata that is provided to the method. |
Exceptions | |
---|---|
Type | Description |
google.api_core.exceptions.GoogleAPICallError | If the request failed for any reason. |
google.api_core.exceptions.RetryError | If the request failed due to a retryable error and retry attempts failed. |
ValueError | If the parameters are invalid. |
list_time_series
list_time_series(name, filter_, interval, view, aggregation=None, order_by=None, page_size=None, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)
Lists time series that match a filter. This method does not require a Stackdriver account.
.. rubric:: Example
from google.cloud import monitoring_v3 from google.cloud.monitoring_v3 import enums
client = monitoring_v3.MetricServiceClient()
name = client.project_path('[PROJECT]')
TODO: Initialize
filter_
:filter_ = ''
TODO: Initialize
interval
:interval = {}
TODO: Initialize
view
:view = enums.ListTimeSeriesRequest.TimeSeriesView.FULL
Iterate over all results
for element in client.list_time_series(name, filter_, interval, view): ... # process element ... pass
Alternatively:
Iterate over results one page at a time
for page in client.list_time_series(name, filter_, interval, view).pages: ... for element in page: ... # process element ... pass
Parameters | |
---|---|
Name | Description |
name |
str
The project on which to execute the request. The format is "projects/{project_id_or_number}". |
filter_ |
str
A |
interval |
Union[dict, TimeInterval]
The time interval for which results should be returned. Only time series that contain data points in the specified interval are included in the response. If a dict is provided, it must be of the same form as the protobuf message TimeInterval |
view |
TimeSeriesView
Specifies which information is returned about the time series. |
aggregation |
Union[dict, Aggregation]
By default, the raw time series data is returned. Use this field to combine multiple time series for different views of the data. If a dict is provided, it must be of the same form as the protobuf message Aggregation |
order_by |
str
Unsupported: must be left blank. The points in each time series are returned in reverse time order. |
page_size |
int
The maximum number of resources contained in the underlying API response. If page streaming is performed per- resource, this parameter does not affect the return value. If page streaming is performed per-page, this determines the maximum number of resources in a page. |
retry |
Optional[google.api_core.retry.Retry]
A retry object used to retry requests. If |
timeout |
Optional[float]
The amount of time, in seconds, to wait for the request to complete. Note that if |
metadata |
Optional[Sequence[Tuple[str, str]]]
Additional metadata that is provided to the method. |
Exceptions | |
---|---|
Type | Description |
google.api_core.exceptions.GoogleAPICallError | If the request failed for any reason. |
google.api_core.exceptions.RetryError | If the request failed due to a retryable error and retry attempts failed. |
ValueError | If the parameters are invalid. |
metric_descriptor_path
metric_descriptor_path(project, metric_descriptor)
Return a fully-qualified metric_descriptor string.
monitored_resource_descriptor_path
monitored_resource_descriptor_path(project, monitored_resource_descriptor)
Return a fully-qualified monitored_resource_descriptor string.
project_path
project_path(project)
Return a fully-qualified project string.