Class ServiceMonitoringServiceClient (0.35.0)

ServiceMonitoringServiceClient(
    transport=None,
    channel=None,
    credentials=None,
    client_config=None,
    client_info=None,
    client_options=None,
)

The Cloud Monitoring Service-Oriented Monitoring API has endpoints for managing and querying aspects of a workspace's services. These include the Service's monitored resources, its Service-Level Objectives, and a taxonomy of categorized Health Metrics.

Methods

ServiceMonitoringServiceClient

ServiceMonitoringServiceClient(
    transport=None,
    channel=None,
    credentials=None,
    client_config=None,
    client_info=None,
    client_options=None,
)

Constructor.

Parameters
NameDescription
channel grpc.Channel

DEPRECATED. A Channel instance through which to make calls. This argument is mutually exclusive with credentials; providing both will raise an exception.

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 transport; doing so will raise an exception.

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 None, then default info will be used. Generally, you only need to set this if you're developing your own client library.

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_service

create_service(parent, service, service_id=None, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)

Create a Service.

.. rubric:: Example

from google.cloud import monitoring_v3

client = monitoring_v3.ServiceMonitoringServiceClient()

parent = client.project_path('[PROJECT]')

TODO: Initialize service:

service = {}

response = client.create_service(parent, service)

Parameters
NameDescription
parent str

Required. Resource name of the parent workspace. The format is: :: projects/[PROJECT_ID_OR_NUMBER]

service Union[dict, Service]

Required. The Service to create. If a dict is provided, it must be of the same form as the protobuf message Service

service_id str

Optional. The Service id to use for this Service. If omitted, an id will be generated instead. Must match the pattern [a-z0-9-]+

retry Optional[google.api_core.retry.Retry]

A retry object used to retry requests. If None is specified, requests will be retried using a default configuration.

timeout Optional[float]

The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

metadata Optional[Sequence[Tuple[str, str]]]

Additional metadata that is provided to the method.

Exceptions
TypeDescription
google.api_core.exceptions.GoogleAPICallErrorIf the request failed for any reason.
google.api_core.exceptions.RetryErrorIf the request failed due to a retryable error and retry attempts failed.
ValueErrorIf the parameters are invalid.

create_service_level_objective

create_service_level_objective(parent, service_level_objective, service_level_objective_id=None, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)

Create a ServiceLevelObjective for the given Service.

.. rubric:: Example

from google.cloud import monitoring_v3

client = monitoring_v3.ServiceMonitoringServiceClient()

parent = client.service_path('[PROJECT]', '[SERVICE]')

TODO: Initialize service_level_objective:

service_level_objective = {}

response = client.create_service_level_objective(parent, service_level_objective)

Parameters
NameDescription
parent str

Required. Resource name of the parent Service. The format is: :: projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID]

service_level_objective Union[dict, ServiceLevelObjective]

Required. The ServiceLevelObjective to create. The provided name will be respected if no ServiceLevelObjective exists with this name. If a dict is provided, it must be of the same form as the protobuf message ServiceLevelObjective

service_level_objective_id str

Optional. The ServiceLevelObjective id to use for this ServiceLevelObjective. If omitted, an id will be generated instead. Must match the pattern [a-z0-9-]+

retry Optional[google.api_core.retry.Retry]

A retry object used to retry requests. If None is specified, requests will be retried using a default configuration.

timeout Optional[float]

The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

metadata Optional[Sequence[Tuple[str, str]]]

Additional metadata that is provided to the method.

Exceptions
TypeDescription
google.api_core.exceptions.GoogleAPICallErrorIf the request failed for any reason.
google.api_core.exceptions.RetryErrorIf the request failed due to a retryable error and retry attempts failed.
ValueErrorIf the parameters are invalid.

delete_service

delete_service(name, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)

Soft delete this Service.

.. rubric:: Example

from google.cloud import monitoring_v3

client = monitoring_v3.ServiceMonitoringServiceClient()

name = client.service_path('[PROJECT]', '[SERVICE]')

client.delete_service(name)

Parameters
NameDescription
name str

Required. Resource name of the Service to delete. The format is: :: projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID]

retry Optional[google.api_core.retry.Retry]

A retry object used to retry requests. If None is specified, requests will be retried using a default configuration.

timeout Optional[float]

The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

metadata Optional[Sequence[Tuple[str, str]]]

Additional metadata that is provided to the method.

Exceptions
TypeDescription
google.api_core.exceptions.GoogleAPICallErrorIf the request failed for any reason.
google.api_core.exceptions.RetryErrorIf the request failed due to a retryable error and retry attempts failed.
ValueErrorIf the parameters are invalid.

delete_service_level_objective

delete_service_level_objective(name, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)

Delete the given ServiceLevelObjective.

.. rubric:: Example

from google.cloud import monitoring_v3

client = monitoring_v3.ServiceMonitoringServiceClient()

name = client.service_level_objective_path('[PROJECT]', '[SERVICE]', '[SERVICE_LEVEL_OBJECTIVE]')

client.delete_service_level_objective(name)

Parameters
NameDescription
name str

Required. Resource name of the ServiceLevelObjective to delete. The format is: :: projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID]/serviceLevelObjectives/[SLO_NAME]

retry Optional[google.api_core.retry.Retry]

A retry object used to retry requests. If None is specified, requests will be retried using a default configuration.

timeout Optional[float]

The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

metadata Optional[Sequence[Tuple[str, str]]]

Additional metadata that is provided to the method.

Exceptions
TypeDescription
google.api_core.exceptions.GoogleAPICallErrorIf the request failed for any reason.
google.api_core.exceptions.RetryErrorIf the request failed due to a retryable error and retry attempts failed.
ValueErrorIf 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
NameDescription
filename str

The path to the service account private key json file.

Returns
TypeDescription
ServiceMonitoringServiceClientThe 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
NameDescription
filename str

The path to the service account private key json file.

Returns
TypeDescription
ServiceMonitoringServiceClientThe constructed client.

get_service

get_service(name, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)

Get the named Service.

.. rubric:: Example

from google.cloud import monitoring_v3

client = monitoring_v3.ServiceMonitoringServiceClient()

name = client.service_path('[PROJECT]', '[SERVICE]')

response = client.get_service(name)

Parameters
NameDescription
name str

Required. Resource name of the Service. The format is: :: projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID]

retry Optional[google.api_core.retry.Retry]

A retry object used to retry requests. If None is specified, requests will be retried using a default configuration.

timeout Optional[float]

The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

metadata Optional[Sequence[Tuple[str, str]]]

Additional metadata that is provided to the method.

Exceptions
TypeDescription
google.api_core.exceptions.GoogleAPICallErrorIf the request failed for any reason.
google.api_core.exceptions.RetryErrorIf the request failed due to a retryable error and retry attempts failed.
ValueErrorIf the parameters are invalid.

get_service_level_objective

get_service_level_objective(name, view=None, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)

Get a ServiceLevelObjective by name.

.. rubric:: Example

from google.cloud import monitoring_v3

client = monitoring_v3.ServiceMonitoringServiceClient()

name = client.service_level_objective_path('[PROJECT]', '[SERVICE]', '[SERVICE_LEVEL_OBJECTIVE]')

response = client.get_service_level_objective(name)

Parameters
NameDescription
name str

Required. Resource name of the ServiceLevelObjective to get. The format is: :: projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID]/serviceLevelObjectives/[SLO_NAME]

view View

View of the ServiceLevelObjective to return. If DEFAULT, return the ServiceLevelObjective as originally defined. If EXPLICIT and the ServiceLevelObjective is defined in terms of a BasicSli, replace the BasicSli with a RequestBasedSli spelling out how the SLI is computed.

retry Optional[google.api_core.retry.Retry]

A retry object used to retry requests. If None is specified, requests will be retried using a default configuration.

timeout Optional[float]

The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

metadata Optional[Sequence[Tuple[str, str]]]

Additional metadata that is provided to the method.

Exceptions
TypeDescription
google.api_core.exceptions.GoogleAPICallErrorIf the request failed for any reason.
google.api_core.exceptions.RetryErrorIf the request failed due to a retryable error and retry attempts failed.
ValueErrorIf the parameters are invalid.

list_service_level_objectives

list_service_level_objectives(parent, filter_=None, page_size=None, view=None, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)

List the ServiceLevelObjective\ s for the given Service.

.. rubric:: Example

from google.cloud import monitoring_v3

client = monitoring_v3.ServiceMonitoringServiceClient()

parent = client.service_path('[PROJECT]', '[SERVICE]')

Iterate over all results

for element in client.list_service_level_objectives(parent): ... # process element ... pass

Alternatively:

Iterate over results one page at a time

for page in client.list_service_level_objectives(parent).pages: ... for element in page: ... # process element ... pass

Parameters
NameDescription
parent str

Required. Resource name of the parent containing the listed SLOs, either a project or a Monitoring Workspace. The formats are: :: projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID] workspaces/[HOST_PROJECT_ID_OR_NUMBER]/services/-

filter_ str

A filter specifying what ServiceLevelObjective\ s to return.

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.

view View

View of the ServiceLevelObjective\ s to return. If DEFAULT, return each ServiceLevelObjective as originally defined. If EXPLICIT and the ServiceLevelObjective is defined in terms of a BasicSli, replace the BasicSli with a RequestBasedSli spelling out how the SLI is computed.

retry Optional[google.api_core.retry.Retry]

A retry object used to retry requests. If None is specified, requests will be retried using a default configuration.

timeout Optional[float]

The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

metadata Optional[Sequence[Tuple[str, str]]]

Additional metadata that is provided to the method.

Exceptions
TypeDescription
google.api_core.exceptions.GoogleAPICallErrorIf the request failed for any reason.
google.api_core.exceptions.RetryErrorIf the request failed due to a retryable error and retry attempts failed.
ValueErrorIf the parameters are invalid.

list_services

list_services(parent, filter_=None, page_size=None, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)

List Service\ s for this workspace.

.. rubric:: Example

from google.cloud import monitoring_v3

client = monitoring_v3.ServiceMonitoringServiceClient()

parent = client.project_path('[PROJECT]')

Iterate over all results

for element in client.list_services(parent): ... # process element ... pass

Alternatively:

Iterate over results one page at a time

for page in client.list_services(parent).pages: ... for element in page: ... # process element ... pass

Parameters
NameDescription
parent str

Required. Resource name of the parent containing the listed services, either a project or a Monitoring Workspace. The formats are: :: projects/[PROJECT_ID_OR_NUMBER] workspaces/[HOST_PROJECT_ID_OR_NUMBER]

filter_ str

A filter specifying what Service\ s to return. The filter currently supports the following fields: :: - identifier_case - app_engine.module_id - cloud_endpoints.service - cluster_istio.location - cluster_istio.cluster_name - cluster_istio.service_namespace - cluster_istio.service_name identifier_case refers to which option in the identifier oneof is populated. For example, the filter identifier_case = "CUSTOM" would match all services with a value for the custom field. Valid options are "CUSTOM", "APP_ENGINE", "CLOUD_ENDPOINTS", and "CLUSTER_ISTIO".

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 None is specified, requests will be retried using a default configuration.

timeout Optional[float]

The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

metadata Optional[Sequence[Tuple[str, str]]]

Additional metadata that is provided to the method.

Exceptions
TypeDescription
google.api_core.exceptions.GoogleAPICallErrorIf the request failed for any reason.
google.api_core.exceptions.RetryErrorIf the request failed due to a retryable error and retry attempts failed.
ValueErrorIf the parameters are invalid.

project_path

project_path(project)

Return a fully-qualified project string.

service_level_objective_path

service_level_objective_path(project, service, service_level_objective)

Return a fully-qualified service_level_objective string.

service_path

service_path(project, service)

Return a fully-qualified service string.

update_service

update_service(service, update_mask=None, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)

Update this Service.

.. rubric:: Example

from google.cloud import monitoring_v3

client = monitoring_v3.ServiceMonitoringServiceClient()

TODO: Initialize service:

service = {}

response = client.update_service(service)

Parameters
NameDescription
service Union[dict, Service]

Required. The Service to draw updates from. The given name specifies the resource to update. If a dict is provided, it must be of the same form as the protobuf message Service

update_mask Union[dict, FieldMask]

A set of field paths defining which fields to use for the update. If a dict is provided, it must be of the same form as the protobuf message FieldMask

retry Optional[google.api_core.retry.Retry]

A retry object used to retry requests. If None is specified, requests will be retried using a default configuration.

timeout Optional[float]

The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

metadata Optional[Sequence[Tuple[str, str]]]

Additional metadata that is provided to the method.

Exceptions
TypeDescription
google.api_core.exceptions.GoogleAPICallErrorIf the request failed for any reason.
google.api_core.exceptions.RetryErrorIf the request failed due to a retryable error and retry attempts failed.
ValueErrorIf the parameters are invalid.

update_service_level_objective

update_service_level_objective(service_level_objective, update_mask=None, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)

Update the given ServiceLevelObjective.

.. rubric:: Example

from google.cloud import monitoring_v3

client = monitoring_v3.ServiceMonitoringServiceClient()

TODO: Initialize service_level_objective:

service_level_objective = {}

response = client.update_service_level_objective(service_level_objective)

Parameters
NameDescription
service_level_objective Union[dict, ServiceLevelObjective]

Required. The ServiceLevelObjective to draw updates from. The given name specifies the resource to update. If a dict is provided, it must be of the same form as the protobuf message ServiceLevelObjective

update_mask Union[dict, FieldMask]

A set of field paths defining which fields to use for the update. If a dict is provided, it must be of the same form as the protobuf message FieldMask

retry Optional[google.api_core.retry.Retry]

A retry object used to retry requests. If None is specified, requests will be retried using a default configuration.

timeout Optional[float]

The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

metadata Optional[Sequence[Tuple[str, str]]]

Additional metadata that is provided to the method.

Exceptions
TypeDescription
google.api_core.exceptions.GoogleAPICallErrorIf the request failed for any reason.
google.api_core.exceptions.RetryErrorIf the request failed due to a retryable error and retry attempts failed.
ValueErrorIf the parameters are invalid.