Cloud Logging API - Class Google::Cloud::Logging::Metric (v2.4.0)

Reference documentation and code samples for the Cloud Logging API class Google::Cloud::Logging::Metric.

Metric

A logs-based Google Cloud Monitoring metric. A metric is a measured value that can be used to assess a system. The basis of a logs-based metric is the collection of log entries that match a logs filter.

Inherits

  • Object

Example

require "google/cloud/logging"

logging = Google::Cloud::Logging.new
metric = logging.create_metric "errors", "severity>=ERROR"

Methods

#delete

def delete() -> Boolean

Permanently deletes the logs-based metric.

Returns
  • (Boolean) — Returns true if the metric was deleted.
Example
require "google/cloud/logging"

logging = Google::Cloud::Logging.new
metric = logging.metric "severe_errors"
metric.delete

#description

def description()

The description of this metric, which is used in documentation.

#description=

def description=(description)

Updates the description of this metric, which is used in documentation.

#filter

def filter()

#filter=

def filter=(filter)

Updates the advanced logs filter.

#name

def name()

The client-assigned metric identifier. Metric identifiers are limited to 1000 characters and can include only the following characters: A-Z, a-z, 0-9, and the special characters _-.,+!*',()%/</code>. The forward-slash character (/) denotes a hierarchy of name pieces, and it cannot be the first character of the name.

#refresh!

def refresh!()
Alias Of: #reload!

Reloads the logs-based metric with current data from the Logging service.

Example
require "google/cloud/logging"

logging = Google::Cloud::Logging.new
metric = logging.metric "severe_errors"
metric.filter = "Unwanted value"
metric.reload!
metric.filter #=> "logName:syslog"

#reload!

def reload!()
Aliases

Reloads the logs-based metric with current data from the Logging service.

Example
require "google/cloud/logging"

logging = Google::Cloud::Logging.new
metric = logging.metric "severe_errors"
metric.filter = "Unwanted value"
metric.reload!
metric.filter #=> "logName:syslog"

#save

def save()

Updates the logs-based metric.

Example
require "google/cloud/logging"

logging = Google::Cloud::Logging.new
metric = logging.metric "severe_errors"
metric.filter = "logName:syslog AND severity>=ERROR"
metric.save