google.logging.v2.metrics_service_v2_api¶
Accesses the google.logging.v2 MetricsServiceV2 API.
Classes
MetricsServiceV2Api ([service_path, port, ...]) |
Service for configuring logs-based metrics. |
-
class
google.logging.v2.metrics_service_v2_api.
MetricsServiceV2Api
(service_path='logging.googleapis.com', port=443, channel=None, metadata_transformer=None, ssl_creds=None, scopes=None, client_config=None, timeout=30, app_name='gax', app_version='0.12.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.beta.implementations.Channel
) – AChannel
object through which to make calls. - ssl_creds (
grpc.beta.implementations.ClientCredentials
) – A ClientCredentials for use with an SSL-enabled channel. - 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. - metadata_transformer (Callable[[], list]) – A function that creates the metadata for requests.
- timeout (int) – The default timeout, in seconds, for calls made through this client
- app_name (string) – The codename of the calling service.
- app_version (string) – The version of the calling service.
Returns: A MetricsServiceV2Api 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.logging.v2.metrics_service_v2_api import MetricsServiceV2Api >>> from google.logging.v2 import logging_metrics_pb2 >>> api = MetricsServiceV2Api() >>> parent = api.project_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. Example:
"projects/my-project-id"
.The new metric must be provided in the request.
- metric (
google.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.logging.v2.logging_metrics_pb2.LogMetric
instance.Raises: google.gax.errors.GaxError
if the RPC is aborted.- parent (string) –
-
delete_log_metric
(metric_name, options=None)[source]¶ Deletes a logs-based metric.
Example
>>> from google.logging.v2.metrics_service_v2_api import MetricsServiceV2Api >>> api = MetricsServiceV2Api() >>> 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.
Example:
"projects/my-project-id/metrics/my-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.- metric_name (string) – The resource name of the metric to delete.
Example:
-
get_log_metric
(metric_name, options=None)[source]¶ Gets a logs-based metric.
Example
>>> from google.logging.v2.metrics_service_v2_api import MetricsServiceV2Api >>> api = MetricsServiceV2Api() >>> 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.
Example:
"projects/my-project-id/metrics/my-metric-id"
. - options (
google.gax.CallOptions
) – Overrides the default settings for this call, e.g, timeout, retries etc.
Returns: A
google.logging.v2.logging_metrics_pb2.LogMetric
instance.Raises: google.gax.errors.GaxError
if the RPC is aborted.- metric_name (string) – The resource name of the desired metric.
Example:
-
list_log_metrics
(parent, page_size=0, options=None)[source]¶ Lists logs-based metrics.
Example
>>> from google.logging.v2.metrics_service_v2_api import MetricsServiceV2Api >>> from google.gax import CallOptions, INITIAL_PAGE >>> api = MetricsServiceV2Api() >>> parent = api.project_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 resource name containing the metrics.
Example:
"projects/my-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.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.- parent (string) – Required. The resource name containing the metrics.
Example:
-
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_project_name
(project_name)[source]¶ Parses the project from a project resource.
Parameters: project_name (string) – A fully-qualified path representing a project 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.logging.v2.metrics_service_v2_api import MetricsServiceV2Api >>> from google.logging.v2 import logging_metrics_pb2 >>> api = MetricsServiceV2Api() >>> 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. Example:
"projects/my-project-id/metrics/my-metric-id"
.The updated metric must be provided in the request and have the same identifier that is specified in
metricName
. If the metric does not exist, it is created. - metric (
google.logging.v2.logging_metrics_pb2.LogMetric
) – The updated metric, whose name must be the same as the metric identifier inmetricName
. IfmetricName
does not exist, then a new metric is created. - options (
google.gax.CallOptions
) – Overrides the default settings for this call, e.g, timeout, retries etc.
Returns: A
google.logging.v2.logging_metrics_pb2.LogMetric
instance.Raises: google.gax.errors.GaxError
if the RPC is aborted.- metric_name (string) –