Class: Google::Cloud::Monitoring::V3::MetricServiceClient
- Inherits:
-
Object
- Object
- Google::Cloud::Monitoring::V3::MetricServiceClient
- Defined in:
- lib/google/cloud/monitoring/v3/metric_service_client.rb
Overview
Manages metric descriptors, monitored resource descriptors, and time series data.
Constant Summary collapse
- SERVICE_ADDRESS =
The default address of the service.
"monitoring.googleapis.com".freeze
- DEFAULT_SERVICE_PORT =
The default port of the service.
443
- GRPC_INTERCEPTORS =
The default set of gRPC interceptors.
[]
- DEFAULT_TIMEOUT =
30
- ALL_SCOPES =
The scopes needed to make gRPC calls to all of the methods defined in this service.
[ "https://www.googleapis.com/auth/cloud-platform", "https://www.googleapis.com/auth/monitoring", "https://www.googleapis.com/auth/monitoring.read", "https://www.googleapis.com/auth/monitoring.write" ].freeze
Class Method Summary collapse
-
.metric_descriptor_path(project, metric_descriptor) ⇒ String
Returns a fully-qualified metric_descriptor resource name string.
-
.monitored_resource_descriptor_path(project, monitored_resource_descriptor) ⇒ String
Returns a fully-qualified monitored_resource_descriptor resource name string.
-
.project_path(project) ⇒ String
Returns a fully-qualified project resource name string.
Instance Method Summary collapse
-
#create_metric_descriptor(name, metric_descriptor, options: nil) {|result, operation| ... } ⇒ Google::Api::MetricDescriptor
Creates a new metric descriptor.
-
#create_time_series(name, time_series, options: nil) {|result, operation| ... } ⇒ Object
Creates or adds data to one or more time series.
-
#delete_metric_descriptor(name, options: nil) {|result, operation| ... } ⇒ Object
Deletes a metric descriptor.
-
#get_metric_descriptor(name, options: nil) {|result, operation| ... } ⇒ Google::Api::MetricDescriptor
Gets a single metric descriptor.
-
#get_monitored_resource_descriptor(name, options: nil) {|result, operation| ... } ⇒ Google::Api::MonitoredResourceDescriptor
Gets a single monitored resource descriptor.
-
#initialize(credentials: nil, scopes: ALL_SCOPES, client_config: {}, timeout: DEFAULT_TIMEOUT, metadata: nil, exception_transformer: nil, lib_name: nil, lib_version: "") ⇒ MetricServiceClient
constructor
A new instance of MetricServiceClient.
-
#list_metric_descriptors(name, filter: nil, page_size: nil, options: nil) {|result, operation| ... } ⇒ Google::Gax::PagedEnumerable<Google::Api::MetricDescriptor>
Lists metric descriptors that match a filter.
-
#list_monitored_resource_descriptors(name, filter: nil, page_size: nil, options: nil) {|result, operation| ... } ⇒ Google::Gax::PagedEnumerable<Google::Api::MonitoredResourceDescriptor>
Lists monitored resource descriptors that match a filter.
-
#list_time_series(name, filter, interval, view, aggregation: nil, order_by: nil, page_size: nil, options: nil) {|result, operation| ... } ⇒ Google::Gax::PagedEnumerable<Google::Monitoring::V3::TimeSeries>
Lists time series that match a filter.
Constructor Details
#initialize(credentials: nil, scopes: ALL_SCOPES, client_config: {}, timeout: DEFAULT_TIMEOUT, metadata: nil, exception_transformer: nil, lib_name: nil, lib_version: "") ⇒ MetricServiceClient
Returns a new instance of MetricServiceClient
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 |
# File 'lib/google/cloud/monitoring/v3/metric_service_client.rb', line 159 def initialize \ credentials: nil, scopes: ALL_SCOPES, client_config: {}, timeout: DEFAULT_TIMEOUT, metadata: nil, exception_transformer: nil, lib_name: nil, lib_version: "" # These require statements are intentionally placed here to initialize # the gRPC module only when it's required. # See https://github.com/googleapis/toolkit/issues/446 require "google/gax/grpc" require "google/monitoring/v3/metric_service_services_pb" credentials ||= Google::Cloud::Monitoring::V3::Credentials.default if credentials.is_a?(String) || credentials.is_a?(Hash) updater_proc = Google::Cloud::Monitoring::V3::Credentials.new(credentials).updater_proc end if credentials.is_a?(GRPC::Core::Channel) channel = credentials end if credentials.is_a?(GRPC::Core::ChannelCredentials) chan_creds = credentials end if credentials.is_a?(Proc) updater_proc = credentials end if credentials.is_a?(Google::Auth::Credentials) updater_proc = credentials.updater_proc end package_version = Gem.loaded_specs['google-cloud-monitoring'].version.version google_api_client = "gl-ruby/#{RUBY_VERSION}" google_api_client << " #{lib_name}/#{lib_version}" if lib_name google_api_client << " gapic/#{package_version} gax/#{Google::Gax::VERSION}" google_api_client << " grpc/#{GRPC::VERSION}" google_api_client.freeze headers = { :"x-goog-api-client" => google_api_client } headers.merge!() unless .nil? client_config_file = Pathname.new(__dir__).join( "metric_service_client_config.json" ) defaults = client_config_file.open do |f| Google::Gax.construct_settings( "google.monitoring.v3.MetricService", JSON.parse(f.read), client_config, Google::Gax::Grpc::STATUS_CODE_NAMES, timeout, page_descriptors: PAGE_DESCRIPTORS, errors: Google::Gax::Grpc::API_ERRORS, metadata: headers ) end # Allow overriding the service path/port in subclasses. service_path = self.class::SERVICE_ADDRESS port = self.class::DEFAULT_SERVICE_PORT interceptors = self.class::GRPC_INTERCEPTORS @metric_service_stub = Google::Gax::Grpc.create_stub( service_path, port, chan_creds: chan_creds, channel: channel, updater_proc: updater_proc, scopes: scopes, interceptors: interceptors, &Google::Monitoring::V3::MetricService::Stub.method(:new) ) @list_monitored_resource_descriptors = Google::Gax.create_api_call( @metric_service_stub.method(:list_monitored_resource_descriptors), defaults["list_monitored_resource_descriptors"], exception_transformer: exception_transformer ) @get_monitored_resource_descriptor = Google::Gax.create_api_call( @metric_service_stub.method(:get_monitored_resource_descriptor), defaults["get_monitored_resource_descriptor"], exception_transformer: exception_transformer ) @list_metric_descriptors = Google::Gax.create_api_call( @metric_service_stub.method(:list_metric_descriptors), defaults["list_metric_descriptors"], exception_transformer: exception_transformer ) @get_metric_descriptor = Google::Gax.create_api_call( @metric_service_stub.method(:get_metric_descriptor), defaults["get_metric_descriptor"], exception_transformer: exception_transformer ) @create_metric_descriptor = Google::Gax.create_api_call( @metric_service_stub.method(:create_metric_descriptor), defaults["create_metric_descriptor"], exception_transformer: exception_transformer ) @delete_metric_descriptor = Google::Gax.create_api_call( @metric_service_stub.method(:delete_metric_descriptor), defaults["delete_metric_descriptor"], exception_transformer: exception_transformer ) @list_time_series = Google::Gax.create_api_call( @metric_service_stub.method(:list_time_series), defaults["list_time_series"], exception_transformer: exception_transformer ) @create_time_series = Google::Gax.create_api_call( @metric_service_stub.method(:create_time_series), defaults["create_time_series"], exception_transformer: exception_transformer ) end |
Class Method Details
.metric_descriptor_path(project, metric_descriptor) ⇒ String
Returns a fully-qualified metric_descriptor resource name string.
112 113 114 115 116 117 |
# File 'lib/google/cloud/monitoring/v3/metric_service_client.rb', line 112 def self.metric_descriptor_path project, metric_descriptor METRIC_DESCRIPTOR_PATH_TEMPLATE.render( :"project" => project, :"metric_descriptor" => metric_descriptor ) end |
.monitored_resource_descriptor_path(project, monitored_resource_descriptor) ⇒ String
Returns a fully-qualified monitored_resource_descriptor resource name string.
123 124 125 126 127 128 |
# File 'lib/google/cloud/monitoring/v3/metric_service_client.rb', line 123 def self.monitored_resource_descriptor_path project, monitored_resource_descriptor MONITORED_RESOURCE_DESCRIPTOR_PATH_TEMPLATE.render( :"project" => project, :"monitored_resource_descriptor" => monitored_resource_descriptor ) end |
.project_path(project) ⇒ String
Returns a fully-qualified project resource name string.
102 103 104 105 106 |
# File 'lib/google/cloud/monitoring/v3/metric_service_client.rb', line 102 def self.project_path project PROJECT_PATH_TEMPLATE.render( :"project" => project ) end |
Instance Method Details
#create_metric_descriptor(name, metric_descriptor, options: nil) {|result, operation| ... } ⇒ Google::Api::MetricDescriptor
Creates a new metric descriptor. User-created metric descriptors define custom metrics.
504 505 506 507 508 509 510 511 512 513 514 515 |
# File 'lib/google/cloud/monitoring/v3/metric_service_client.rb', line 504 def create_metric_descriptor \ name, metric_descriptor, options: nil, &block req = { name: name, metric_descriptor: metric_descriptor }.delete_if { |_, v| v.nil? } req = Google::Gax::to_proto(req, Google::Monitoring::V3::CreateMetricDescriptorRequest) @create_metric_descriptor.call(req, , &block) end |
#create_time_series(name, time_series, options: nil) {|result, operation| ... } ⇒ Object
Creates or adds data to one or more time series. The response is empty if all time series in the request were written. If any time series could not be written, a corresponding failure message is included in the error response.
683 684 685 686 687 688 689 690 691 692 693 694 695 |
# File 'lib/google/cloud/monitoring/v3/metric_service_client.rb', line 683 def create_time_series \ name, time_series, options: nil, &block req = { name: name, time_series: time_series }.delete_if { |_, v| v.nil? } req = Google::Gax::to_proto(req, Google::Monitoring::V3::CreateTimeSeriesRequest) @create_time_series.call(req, , &block) nil end |
#delete_metric_descriptor(name, options: nil) {|result, operation| ... } ⇒ Object
Deletes a metric descriptor. Only user-created custom metrics can be deleted.
539 540 541 542 543 544 545 546 547 548 549 |
# File 'lib/google/cloud/monitoring/v3/metric_service_client.rb', line 539 def delete_metric_descriptor \ name, options: nil, &block req = { name: name }.delete_if { |_, v| v.nil? } req = Google::Gax::to_proto(req, Google::Monitoring::V3::DeleteMetricDescriptorRequest) @delete_metric_descriptor.call(req, , &block) nil end |
#get_metric_descriptor(name, options: nil) {|result, operation| ... } ⇒ Google::Api::MetricDescriptor
Gets a single metric descriptor. This method does not require a Stackdriver account.
463 464 465 466 467 468 469 470 471 472 |
# File 'lib/google/cloud/monitoring/v3/metric_service_client.rb', line 463 def get_metric_descriptor \ name, options: nil, &block req = { name: name }.delete_if { |_, v| v.nil? } req = Google::Gax::to_proto(req, Google::Monitoring::V3::GetMetricDescriptorRequest) @get_metric_descriptor.call(req, , &block) end |
#get_monitored_resource_descriptor(name, options: nil) {|result, operation| ... } ⇒ Google::Api::MonitoredResourceDescriptor
Gets a single monitored resource descriptor. This method does not require a Stackdriver account.
364 365 366 367 368 369 370 371 372 373 |
# File 'lib/google/cloud/monitoring/v3/metric_service_client.rb', line 364 def get_monitored_resource_descriptor \ name, options: nil, &block req = { name: name }.delete_if { |_, v| v.nil? } req = Google::Gax::to_proto(req, Google::Monitoring::V3::GetMonitoredResourceDescriptorRequest) @get_monitored_resource_descriptor.call(req, , &block) end |
#list_metric_descriptors(name, filter: nil, page_size: nil, options: nil) {|result, operation| ... } ⇒ Google::Gax::PagedEnumerable<Google::Api::MetricDescriptor>
Lists metric descriptors that match a filter. This method does not require a Stackdriver account.
426 427 428 429 430 431 432 433 434 435 436 437 438 439 |
# File 'lib/google/cloud/monitoring/v3/metric_service_client.rb', line 426 def list_metric_descriptors \ name, filter: nil, page_size: nil, options: nil, &block req = { name: name, filter: filter, page_size: page_size }.delete_if { |_, v| v.nil? } req = Google::Gax::to_proto(req, Google::Monitoring::V3::ListMetricDescriptorsRequest) @list_metric_descriptors.call(req, , &block) end |
#list_monitored_resource_descriptors(name, filter: nil, page_size: nil, options: nil) {|result, operation| ... } ⇒ Google::Gax::PagedEnumerable<Google::Api::MonitoredResourceDescriptor>
Lists monitored resource descriptors that match a filter. This method does not require a Stackdriver account.
327 328 329 330 331 332 333 334 335 336 337 338 339 340 |
# File 'lib/google/cloud/monitoring/v3/metric_service_client.rb', line 327 def list_monitored_resource_descriptors \ name, filter: nil, page_size: nil, options: nil, &block req = { name: name, filter: filter, page_size: page_size }.delete_if { |_, v| v.nil? } req = Google::Gax::to_proto(req, Google::Monitoring::V3::ListMonitoredResourceDescriptorsRequest) @list_monitored_resource_descriptors.call(req, , &block) end |
#list_time_series(name, filter, interval, view, aggregation: nil, order_by: nil, page_size: nil, options: nil) {|result, operation| ... } ⇒ Google::Gax::PagedEnumerable<Google::Monitoring::V3::TimeSeries>
Lists time series that match a filter. This method does not require a Stackdriver account.
627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 |
# File 'lib/google/cloud/monitoring/v3/metric_service_client.rb', line 627 def list_time_series \ name, filter, interval, view, aggregation: nil, order_by: nil, page_size: nil, options: nil, &block req = { name: name, filter: filter, interval: interval, view: view, aggregation: aggregation, order_by: order_by, page_size: page_size }.delete_if { |_, v| v.nil? } req = Google::Gax::to_proto(req, Google::Monitoring::V3::ListTimeSeriesRequest) @list_time_series.call(req, , &block) end |