Reference documentation and code samples for the Cloud Logging V2 API class Google::Cloud::Logging::V2::MetricsService::Client.
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.
- (config) — Configure the Client client.
- config (Client::Configuration)
# 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.
- (config) — Configure the Client client.
- config (Client::Configuration)
#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.
def create_log_metric(request, options = nil) -> ::Google::Cloud::Logging::V2::LogMetric
create_log_metric
via a request object, either of type
CreateLogMetricRequest or an equivalent Hash.
- 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
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).
-
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.
- (response, operation) — Access the result along with the RPC operation
- response (::Google::Cloud::Logging::V2::LogMetric)
- operation (::GRPC::ActiveCall::Operation)
- (::Google::Cloud::Error) — if the RPC is aborted.
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.
def delete_log_metric(request, options = nil) -> ::Google::Protobuf::Empty
delete_log_metric
via a request object, either of type
DeleteLogMetricRequest or an equivalent Hash.
- 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
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).
-
metric_name (::String) —
Required. The resource name of the metric to delete:
"projects/[PROJECT_ID]/metrics/[METRIC_ID]"
- (response, operation) — Access the result along with the RPC operation
- response (::Google::Protobuf::Empty)
- operation (::GRPC::ActiveCall::Operation)
- (::Google::Cloud::Error) — if the RPC is aborted.
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.
def get_log_metric(request, options = nil) -> ::Google::Cloud::Logging::V2::LogMetric
get_log_metric
via a request object, either of type
GetLogMetricRequest or an equivalent Hash.
- 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
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).
-
metric_name (::String) —
Required. The resource name of the desired metric:
"projects/[PROJECT_ID]/metrics/[METRIC_ID]"
- (response, operation) — Access the result along with the RPC operation
- response (::Google::Cloud::Logging::V2::LogMetric)
- operation (::GRPC::ActiveCall::Operation)
- (::Google::Cloud::Error) — if the RPC is aborted.
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.
- (config) — Configure the MetricsService client.
- config (Client::Configuration)
- (Client) — a new instance of Client
# 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.
def list_log_metrics(request, options = nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Logging::V2::LogMetric>
list_log_metrics
via a request object, either of type
ListLogMetricsRequest or an equivalent Hash.
- 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>
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).
-
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 ofnextPageToken
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.
- (response, operation) — Access the result along with the RPC operation
- response (::Gapic::PagedEnumerable<::Google::Cloud::Logging::V2::LogMetric>)
- operation (::GRPC::ActiveCall::Operation)
- (::Gapic::PagedEnumerable<::Google::Cloud::Logging::V2::LogMetric>)
- (::Google::Cloud::Error) — if the RPC is aborted.
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.
def update_log_metric(request, options = nil) -> ::Google::Cloud::Logging::V2::LogMetric
update_log_metric
via a request object, either of type
UpdateLogMetricRequest or an equivalent Hash.
- 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
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).
-
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.
- (response, operation) — Access the result along with the RPC operation
- response (::Google::Cloud::Logging::V2::LogMetric)
- operation (::GRPC::ActiveCall::Operation)
- (::Google::Cloud::Error) — if the RPC is aborted.
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