Metrics#

Define Stackdriver Logging API Metrics.

class google.cloud.logging.metric.Metric(name, filter_=None, client=None, description='')[source]#

Bases: object

Metrics represent named filters for log entries.

See: https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.metrics

Parameters:
  • name (str) – the name of the metric
  • filter (str) – the advanced logs filter expression defining the entries tracked by the metric. If not passed, the instance should already exist, to be refreshed via reload().
  • client (google.cloud.logging.client.Client) – A client which holds credentials and project configuration for the metric (which requires a project).
  • description (str) – an optional description of the metric.
client#

Clent bound to the logger.

create(client=None)[source]#

API call: create the metric via a PUT request

See: https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.metrics/create

Parameters:client (Client or NoneType) – the client to use. If not passed, falls back to the client stored on the current metric.
delete(client=None)[source]#

API call: delete a metric via a DELETE request

See https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.metrics/delete

Parameters:client (Client or NoneType) – the client to use. If not passed, falls back to the client stored on the current metric.
exists(client=None)[source]#

API call: test for the existence of the metric via a GET request

See https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.metrics/get

Parameters:client (Client or NoneType) – the client to use. If not passed, falls back to the client stored on the current metric.
Return type:bool
Returns:Boolean indicating existence of the metric.
classmethod from_api_repr(resource, client)[source]#

Factory: construct a metric given its API representation

Parameters:
  • resource (dict) – metric resource representation returned from the API
  • client (google.cloud.logging.client.Client) – Client which holds credentials and project configuration for the metric.
Return type:

google.cloud.logging.metric.Metric

Returns:

Metric parsed from resource.

full_name#

Fully-qualified name used in metric APIs

path#

URL path for the metric’s APIs

project#

Project bound to the logger.

reload(client=None)[source]#

API call: sync local metric configuration via a GET request

See https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.metrics/get

Parameters:client (Client or NoneType) – the client to use. If not passed, falls back to the client stored on the current metric.
update(client=None)[source]#

API call: update metric configuration via a PUT request

See https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.metrics/update

Parameters:client (Client or NoneType) – the client to use. If not passed, falls back to the client stored on the current metric.