Class Google::Cloud::Logging::V2::MetricsService::Client (v0.6.0)

Client for the MetricsService service.

Service for configuring logs-based metrics.

Inherits

  • Object

Methods

.configure

def self.configure() { |config| ... } -> Client::Configuration

Configure the MetricsService Client class.

See Configuration for a description of the configuration fields.

Yields
  • (config) — Configure the Client client.
Yield Parameter
Example
# Modify the configuration for all MetricsService clients
::Google::Cloud::Logging::V2::MetricsService::Client.configure do |config|
  config.timeout = 10.0
end

#configure

def configure() { |config| ... } -> Client::Configuration

Configure the MetricsService Client instance.

The configuration is set to the derived mode, meaning that values can be changed, but structural changes (adding new fields, etc.) are not allowed. Structural changes should be made on Client.configure.

See Configuration for a description of the configuration fields.

Yields
  • (config) — Configure the Client client.
Yield Parameter

#create_log_metric

def create_log_metric(request, options = nil) -> ::Google::Cloud::Logging::V2::LogMetric
def create_log_metric(parent: nil, metric: nil) -> ::Google::Cloud::Logging::V2::LogMetric

Creates a logs-based metric.

Overloads
def create_log_metric(request, options = nil) -> ::Google::Cloud::Logging::V2::LogMetric
Pass arguments to create_log_metric via a request object, either of type CreateLogMetricRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Logging::V2::CreateLogMetricRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
  • options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def create_log_metric(parent: nil, metric: nil) -> ::Google::Cloud::Logging::V2::LogMetric
Pass arguments to create_log_metric via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).
Parameters
  • parent (::String) — Required. 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::Logging::V2::LogMetric, ::Hash) — Required. The new logs-based metric, which must not have an identifier that already exists.
Yields
  • (response, operation) — Access the result along with the RPC operation
Yield Parameters
Raises
  • (::Google::Cloud::Error) — if the RPC is aborted.
Example

Basic example

require "google/cloud/logging/v2"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Logging::V2::MetricsService::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Logging::V2::CreateLogMetricRequest.new

# Call the create_log_metric method.
result = client.create_log_metric request

# The returned object is of type Google::Cloud::Logging::V2::LogMetric.
p result

#delete_log_metric

def delete_log_metric(request, options = nil) -> ::Google::Protobuf::Empty
def delete_log_metric(metric_name: nil) -> ::Google::Protobuf::Empty

Deletes a logs-based metric.

Overloads
def delete_log_metric(request, options = nil) -> ::Google::Protobuf::Empty
Pass arguments to delete_log_metric via a request object, either of type DeleteLogMetricRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Logging::V2::DeleteLogMetricRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
  • options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def delete_log_metric(metric_name: nil) -> ::Google::Protobuf::Empty
Pass arguments to delete_log_metric via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).
Parameter
  • metric_name (::String) —

    Required. The resource name of the metric to delete:

    "projects/[PROJECT_ID]/metrics/[METRIC_ID]"
    
Yields
  • (response, operation) — Access the result along with the RPC operation
Yield Parameters
Raises
  • (::Google::Cloud::Error) — if the RPC is aborted.
Example

Basic example

require "google/cloud/logging/v2"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Logging::V2::MetricsService::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Logging::V2::DeleteLogMetricRequest.new

# Call the delete_log_metric method.
result = client.delete_log_metric request

# The returned object is of type Google::Protobuf::Empty.
p result

#get_log_metric

def get_log_metric(request, options = nil) -> ::Google::Cloud::Logging::V2::LogMetric
def get_log_metric(metric_name: nil) -> ::Google::Cloud::Logging::V2::LogMetric

Gets a logs-based metric.

Overloads
def get_log_metric(request, options = nil) -> ::Google::Cloud::Logging::V2::LogMetric
Pass arguments to get_log_metric via a request object, either of type GetLogMetricRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Logging::V2::GetLogMetricRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
  • options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def get_log_metric(metric_name: nil) -> ::Google::Cloud::Logging::V2::LogMetric
Pass arguments to get_log_metric via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).
Parameter
  • metric_name (::String) —

    Required. The resource name of the desired metric:

    "projects/[PROJECT_ID]/metrics/[METRIC_ID]"
    
Yields
  • (response, operation) — Access the result along with the RPC operation
Yield Parameters
Raises
  • (::Google::Cloud::Error) — if the RPC is aborted.
Example

Basic example

require "google/cloud/logging/v2"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Logging::V2::MetricsService::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Logging::V2::GetLogMetricRequest.new

# Call the get_log_metric method.
result = client.get_log_metric request

# The returned object is of type Google::Cloud::Logging::V2::LogMetric.
p result

#initialize

def initialize() { |config| ... } -> Client

Create a new MetricsService client object.

Yields
  • (config) — Configure the MetricsService client.
Yield Parameter
Returns
  • (Client) — a new instance of Client
Example
# Create a client using the default configuration
client = ::Google::Cloud::Logging::V2::MetricsService::Client.new

# Create a client using a custom configuration
client = ::Google::Cloud::Logging::V2::MetricsService::Client.new do |config|
  config.timeout = 10.0
end

#list_log_metrics

def list_log_metrics(request, options = nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Logging::V2::LogMetric>
def list_log_metrics(parent: nil, page_token: nil, page_size: nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Logging::V2::LogMetric>

Lists logs-based metrics.

Overloads
def list_log_metrics(request, options = nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Logging::V2::LogMetric>
Pass arguments to list_log_metrics via a request object, either of type ListLogMetricsRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Logging::V2::ListLogMetricsRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
  • options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def list_log_metrics(parent: nil, page_token: nil, page_size: nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Logging::V2::LogMetric>
Pass arguments to list_log_metrics via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).
Parameters
  • parent (::String) —

    Required. The name of the project containing the metrics:

    "projects/[PROJECT_ID]"
    
  • page_token (::String) — Optional. If present, then retrieve the next batch of results from the preceding call to this method. pageToken must be the value of nextPageToken from the previous response. The values of other method parameters should be identical to those in the previous call.
  • page_size (::Integer) — Optional. The maximum number of results to return from this request. Non-positive values are ignored. The presence of nextPageToken in the response indicates that more results might be available.
Yields
  • (response, operation) — Access the result along with the RPC operation
Yield Parameters
Returns
Raises
  • (::Google::Cloud::Error) — if the RPC is aborted.
Example

Basic example

require "google/cloud/logging/v2"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Logging::V2::MetricsService::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Logging::V2::ListLogMetricsRequest.new

# Call the list_log_metrics method.
result = client.list_log_metrics request

# The returned object is of type Gapic::PagedEnumerable. You can
# iterate over all elements by calling #each, and the enumerable
# will lazily make API calls to fetch subsequent pages. Other
# methods are also available for managing paging directly.
result.each do |response|
  # Each element is of type ::Google::Cloud::Logging::V2::LogMetric.
  p response
end

#update_log_metric

def update_log_metric(request, options = nil) -> ::Google::Cloud::Logging::V2::LogMetric
def update_log_metric(metric_name: nil, metric: nil) -> ::Google::Cloud::Logging::V2::LogMetric

Creates or updates a logs-based metric.

Overloads
def update_log_metric(request, options = nil) -> ::Google::Cloud::Logging::V2::LogMetric
Pass arguments to update_log_metric via a request object, either of type UpdateLogMetricRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Logging::V2::UpdateLogMetricRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
  • options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def update_log_metric(metric_name: nil, metric: nil) -> ::Google::Cloud::Logging::V2::LogMetric
Pass arguments to update_log_metric via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).
Parameters
  • metric_name (::String) — Required. 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::Logging::V2::LogMetric, ::Hash) — Required. The updated metric.
Yields
  • (response, operation) — Access the result along with the RPC operation
Yield Parameters
Raises
  • (::Google::Cloud::Error) — if the RPC is aborted.
Example

Basic example

require "google/cloud/logging/v2"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Logging::V2::MetricsService::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Logging::V2::UpdateLogMetricRequest.new

# Call the update_log_metric method.
result = client.update_log_metric request

# The returned object is of type Google::Cloud::Logging::V2::LogMetric.
p result