google.cloud.gapic.logging.v2.metrics_service_v2_client¶
Accesses the google.logging.v2 MetricsServiceV2 API.
Classes
MetricsServiceV2Client ([service_path, port, ...]) |
Service for configuring logs-based metrics. |
-
class
google.cloud.gapic.logging.v2.metrics_service_v2_client.
MetricsServiceV2Client
(service_path='logging.googleapis.com', port=443, channel=None, credentials=None, ssl_credentials=None, scopes=None, client_config=None, app_name='gax', app_version='0.15.0')[source]¶ Service for configuring logs-based metrics.
Constructor.
Parameters: - service_path (string) – The domain name of the API remote host.
- port (int) – The port on which to connect to the remote host.
- channel (
grpc.Channel
) – AChannel
instance through which to make calls. - credentials (object) – The authorization credentials to attach to requests. These credentials identify this application to the service.
- ssl_credentials (
grpc.ChannelCredentials
) – AChannelCredentials
instance for use with an SSL-enabled channel. - scopes (list[string]) – A list of OAuth2 scopes to attach to requests.
- client_config (dict) – A dictionary for call options for each method. See
google.gax.construct_settings()
for the structure of this data. Falls back to the default config if not specified or the specified config is missing data points. - app_name (string) – The codename of the calling service.
- app_version (string) – The version of the calling service.
Returns: A MetricsServiceV2Client object.
-
DEFAULT_SERVICE_PORT
= 443¶ The default port of the service.
-
SERVICE_ADDRESS
= 'logging.googleapis.com'¶ The default address of the service.
-
create_log_metric
(parent, metric, options=None)[source]¶ Creates a logs-based metric.
Example
>>> from google.cloud.gapic.logging.v2 import metrics_service_v2_client >>> from google.cloud.grpc.logging.v2 import logging_metrics_pb2 >>> api = metrics_service_v2_client.MetricsServiceV2Client() >>> parent = api.parent_path('[PROJECT]') >>> metric = logging_metrics_pb2.LogMetric() >>> response = api.create_log_metric(parent, metric)
Parameters: - parent (string) –
The resource name of the project in which to create the metric:
"projects/[PROJECT_ID]"
The new metric must be provided in the request.
- metric (
google.cloud.grpc.logging.v2.logging_metrics_pb2.LogMetric
) – The new logs-based metric, which must not have an identifier that already exists. - options (
google.gax.CallOptions
) – Overrides the default settings for this call, e.g, timeout, retries etc.
Returns: A
google.cloud.grpc.logging.v2.logging_metrics_pb2.LogMetric
instance.Raises: google.gax.errors.GaxError
if the RPC is aborted.ValueError
if the parameters are invalid.
- parent (string) –
-
delete_log_metric
(metric_name, options=None)[source]¶ Deletes a logs-based metric.
Example
>>> from google.cloud.gapic.logging.v2 import metrics_service_v2_client >>> api = metrics_service_v2_client.MetricsServiceV2Client() >>> metric_name = api.metric_path('[PROJECT]', '[METRIC]') >>> api.delete_log_metric(metric_name)
Parameters: - metric_name (string) –
The resource name of the metric to delete:
"projects/[PROJECT_ID]/metrics/[METRIC_ID]"
- options (
google.gax.CallOptions
) – Overrides the default settings for this call, e.g, timeout, retries etc.
Raises: google.gax.errors.GaxError
if the RPC is aborted.ValueError
if the parameters are invalid.
- metric_name (string) –
-
get_log_metric
(metric_name, options=None)[source]¶ Gets a logs-based metric.
Example
>>> from google.cloud.gapic.logging.v2 import metrics_service_v2_client >>> api = metrics_service_v2_client.MetricsServiceV2Client() >>> metric_name = api.metric_path('[PROJECT]', '[METRIC]') >>> response = api.get_log_metric(metric_name)
Parameters: - metric_name (string) –
The resource name of the desired metric:
"projects/[PROJECT_ID]/metrics/[METRIC_ID]"
- options (
google.gax.CallOptions
) – Overrides the default settings for this call, e.g, timeout, retries etc.
Returns: A
google.cloud.grpc.logging.v2.logging_metrics_pb2.LogMetric
instance.Raises: google.gax.errors.GaxError
if the RPC is aborted.ValueError
if the parameters are invalid.
- metric_name (string) –
-
list_log_metrics
(parent, page_size=0, options=None)[source]¶ Lists logs-based metrics.
Example
>>> from google.cloud.gapic.logging.v2 import metrics_service_v2_client >>> from google.gax import CallOptions, INITIAL_PAGE >>> api = metrics_service_v2_client.MetricsServiceV2Client() >>> parent = api.parent_path('[PROJECT]') >>> >>> # Iterate over all results >>> for element in api.list_log_metrics(parent): >>> # process element >>> pass >>> >>> # Or iterate over results one page at a time >>> for page in api.list_log_metrics(parent, options=CallOptions(page_token=INITIAL_PAGE)): >>> for element in page: >>> # process element >>> pass
Parameters: - parent (string) –
Required. The name of the project containing the metrics:
"projects/[PROJECT_ID]"
- 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.
- options (
google.gax.CallOptions
) – Overrides the default settings for this call, e.g, timeout, retries etc.
Returns: A
google.gax.PageIterator
instance. By default, this is an iterable ofgoogle.cloud.grpc.logging.v2.logging_metrics_pb2.LogMetric
instances. This object can also be configured to iterate over the pages of the response through the CallOptions parameter.Raises: google.gax.errors.GaxError
if the RPC is aborted.ValueError
if the parameters are invalid.
- parent (string) –
-
classmethod
match_metric_from_metric_name
(metric_name)[source]¶ Parses the metric from a metric resource.
Parameters: metric_name (string) – A fully-qualified path representing a metric resource. Returns: A string representing the metric.
-
classmethod
match_project_from_metric_name
(metric_name)[source]¶ Parses the project from a metric resource.
Parameters: metric_name (string) – A fully-qualified path representing a metric resource. Returns: A string representing the project.
-
classmethod
match_project_from_parent_name
(parent_name)[source]¶ Parses the project from a parent resource.
Parameters: parent_name (string) – A fully-qualified path representing a parent resource. Returns: A string representing the project.
-
classmethod
metric_path
(project, metric)[source]¶ Returns a fully-qualified metric resource name string.
-
update_log_metric
(metric_name, metric, options=None)[source]¶ Creates or updates a logs-based metric.
Example
>>> from google.cloud.gapic.logging.v2 import metrics_service_v2_client >>> from google.cloud.grpc.logging.v2 import logging_metrics_pb2 >>> api = metrics_service_v2_client.MetricsServiceV2Client() >>> metric_name = api.metric_path('[PROJECT]', '[METRIC]') >>> metric = logging_metrics_pb2.LogMetric() >>> response = api.update_log_metric(metric_name, metric)
Parameters: - metric_name (string) –
The resource name of the metric to update:
"projects/[PROJECT_ID]/metrics/[METRIC_ID]"
The updated metric must be provided in the request and it’s
name
field must be the same as[METRIC_ID]
If the metric does not exist in[PROJECT_ID]
, then a new metric is created. - metric (
google.cloud.grpc.logging.v2.logging_metrics_pb2.LogMetric
) – The updated metric. - options (
google.gax.CallOptions
) – Overrides the default settings for this call, e.g, timeout, retries etc.
Returns: A
google.cloud.grpc.logging.v2.logging_metrics_pb2.LogMetric
instance.Raises: google.gax.errors.GaxError
if the RPC is aborted.ValueError
if the parameters are invalid.
- metric_name (string) –