google-cloud-monitoring 0.21.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +45 -0
- data/Rakefile +70 -0
- data/lib/google/cloud/monitoring/v3.rb +18 -0
- data/lib/google/cloud/monitoring/v3/group_service_api.rb +498 -0
- data/lib/google/cloud/monitoring/v3/group_service_client_config.json +58 -0
- data/lib/google/cloud/monitoring/v3/metric_service_api.rb +641 -0
- data/lib/google/cloud/monitoring/v3/metric_service_client_config.json +68 -0
- data/lib/google/monitoring/v3/common_pb.rb +75 -0
- data/lib/google/monitoring/v3/group_pb.rb +22 -0
- data/lib/google/monitoring/v3/group_service_pb.rb +68 -0
- data/lib/google/monitoring/v3/group_service_services_pb.rb +65 -0
- data/lib/google/monitoring/v3/metric_pb.rb +30 -0
- data/lib/google/monitoring/v3/metric_service_pb.rb +93 -0
- data/lib/google/monitoring/v3/metric_service_services_pb.rb +64 -0
- metadata +141 -0
@@ -0,0 +1,58 @@
|
|
1
|
+
{
|
2
|
+
"interfaces": {
|
3
|
+
"google.monitoring.v3.GroupService": {
|
4
|
+
"retry_codes": {
|
5
|
+
"retry_codes_def": {
|
6
|
+
"idempotent": [
|
7
|
+
"DEADLINE_EXCEEDED",
|
8
|
+
"UNAVAILABLE"
|
9
|
+
],
|
10
|
+
"non_idempotent": []
|
11
|
+
}
|
12
|
+
},
|
13
|
+
"retry_params": {
|
14
|
+
"default": {
|
15
|
+
"initial_retry_delay_millis": 100,
|
16
|
+
"retry_delay_multiplier": 1.3,
|
17
|
+
"max_retry_delay_millis": 60000,
|
18
|
+
"initial_rpc_timeout_millis": 20000,
|
19
|
+
"rpc_timeout_multiplier": 1.0,
|
20
|
+
"max_rpc_timeout_millis": 20000,
|
21
|
+
"total_timeout_millis": 600000
|
22
|
+
}
|
23
|
+
},
|
24
|
+
"methods": {
|
25
|
+
"ListGroups": {
|
26
|
+
"timeout_millis": 60000,
|
27
|
+
"retry_codes_name": "idempotent",
|
28
|
+
"retry_params_name": "default"
|
29
|
+
},
|
30
|
+
"GetGroup": {
|
31
|
+
"timeout_millis": 60000,
|
32
|
+
"retry_codes_name": "idempotent",
|
33
|
+
"retry_params_name": "default"
|
34
|
+
},
|
35
|
+
"CreateGroup": {
|
36
|
+
"timeout_millis": 60000,
|
37
|
+
"retry_codes_name": "non_idempotent",
|
38
|
+
"retry_params_name": "default"
|
39
|
+
},
|
40
|
+
"UpdateGroup": {
|
41
|
+
"timeout_millis": 60000,
|
42
|
+
"retry_codes_name": "idempotent",
|
43
|
+
"retry_params_name": "default"
|
44
|
+
},
|
45
|
+
"DeleteGroup": {
|
46
|
+
"timeout_millis": 60000,
|
47
|
+
"retry_codes_name": "idempotent",
|
48
|
+
"retry_params_name": "default"
|
49
|
+
},
|
50
|
+
"ListGroupMembers": {
|
51
|
+
"timeout_millis": 60000,
|
52
|
+
"retry_codes_name": "idempotent",
|
53
|
+
"retry_params_name": "default"
|
54
|
+
}
|
55
|
+
}
|
56
|
+
}
|
57
|
+
}
|
58
|
+
}
|
@@ -0,0 +1,641 @@
|
|
1
|
+
# Copyright 2016 Google Inc. All rights reserved.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
#
|
15
|
+
# EDITING INSTRUCTIONS
|
16
|
+
# This file was generated from the file
|
17
|
+
# https://github.com/googleapis/googleapis/blob/master/google/monitoring/v3/metric_service.proto,
|
18
|
+
# and updates to that file get reflected here through a refresh process.
|
19
|
+
# For the short term, the refresh process will only be runnable by Google
|
20
|
+
# engineers.
|
21
|
+
#
|
22
|
+
# The only allowed edits are to method and file documentation. A 3-way
|
23
|
+
# merge preserves those additions if the generated source changes.
|
24
|
+
|
25
|
+
require "json"
|
26
|
+
require "pathname"
|
27
|
+
|
28
|
+
require "google/gax"
|
29
|
+
require "google/monitoring/v3/metric_service_pb"
|
30
|
+
|
31
|
+
module Google
|
32
|
+
module Cloud
|
33
|
+
module Monitoring
|
34
|
+
module V3
|
35
|
+
# Manages metric descriptors, monitored resource descriptors, and
|
36
|
+
# time series data.
|
37
|
+
#
|
38
|
+
# @!attribute [r] metric_service_stub
|
39
|
+
# @return [Google::Monitoring::V3::MetricService::Stub]
|
40
|
+
class MetricServiceApi
|
41
|
+
attr_reader :metric_service_stub
|
42
|
+
|
43
|
+
# The default address of the service.
|
44
|
+
SERVICE_ADDRESS = "monitoring.googleapis.com".freeze
|
45
|
+
|
46
|
+
# The default port of the service.
|
47
|
+
DEFAULT_SERVICE_PORT = 443
|
48
|
+
|
49
|
+
CODE_GEN_NAME_VERSION = "gapic/0.1.0".freeze
|
50
|
+
|
51
|
+
DEFAULT_TIMEOUT = 30
|
52
|
+
|
53
|
+
PAGE_DESCRIPTORS = {
|
54
|
+
"list_monitored_resource_descriptors" => Google::Gax::PageDescriptor.new(
|
55
|
+
"page_token",
|
56
|
+
"next_page_token",
|
57
|
+
"resource_descriptors"),
|
58
|
+
"list_metric_descriptors" => Google::Gax::PageDescriptor.new(
|
59
|
+
"page_token",
|
60
|
+
"next_page_token",
|
61
|
+
"metric_descriptors"),
|
62
|
+
"list_time_series" => Google::Gax::PageDescriptor.new(
|
63
|
+
"page_token",
|
64
|
+
"next_page_token",
|
65
|
+
"time_series")
|
66
|
+
}.freeze
|
67
|
+
|
68
|
+
private_constant :PAGE_DESCRIPTORS
|
69
|
+
|
70
|
+
# The scopes needed to make gRPC calls to all of the methods defined in
|
71
|
+
# this service.
|
72
|
+
ALL_SCOPES = [
|
73
|
+
].freeze
|
74
|
+
|
75
|
+
PROJECT_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
|
76
|
+
"projects/{project}"
|
77
|
+
)
|
78
|
+
|
79
|
+
private_constant :PROJECT_PATH_TEMPLATE
|
80
|
+
|
81
|
+
METRIC_DESCRIPTOR_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
|
82
|
+
"projects/{project}/metricDescriptors/{metric_descriptor=**}"
|
83
|
+
)
|
84
|
+
|
85
|
+
private_constant :METRIC_DESCRIPTOR_PATH_TEMPLATE
|
86
|
+
|
87
|
+
MONITORED_RESOURCE_DESCRIPTOR_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
|
88
|
+
"projects/{project}/monitoredResourceDescriptors/{monitored_resource_descriptor}"
|
89
|
+
)
|
90
|
+
|
91
|
+
private_constant :MONITORED_RESOURCE_DESCRIPTOR_PATH_TEMPLATE
|
92
|
+
|
93
|
+
# Returns a fully-qualified project resource name string.
|
94
|
+
# @param project [String]
|
95
|
+
# @return [String]
|
96
|
+
def self.project_path project
|
97
|
+
PROJECT_PATH_TEMPLATE.render(
|
98
|
+
:"project" => project
|
99
|
+
)
|
100
|
+
end
|
101
|
+
|
102
|
+
# Returns a fully-qualified metric_descriptor resource name string.
|
103
|
+
# @param project [String]
|
104
|
+
# @param metric_descriptor [String]
|
105
|
+
# @return [String]
|
106
|
+
def self.metric_descriptor_path project, metric_descriptor
|
107
|
+
METRIC_DESCRIPTOR_PATH_TEMPLATE.render(
|
108
|
+
:"project" => project,
|
109
|
+
:"metric_descriptor" => metric_descriptor
|
110
|
+
)
|
111
|
+
end
|
112
|
+
|
113
|
+
# Returns a fully-qualified monitored_resource_descriptor resource name string.
|
114
|
+
# @param project [String]
|
115
|
+
# @param monitored_resource_descriptor [String]
|
116
|
+
# @return [String]
|
117
|
+
def self.monitored_resource_descriptor_path project, monitored_resource_descriptor
|
118
|
+
MONITORED_RESOURCE_DESCRIPTOR_PATH_TEMPLATE.render(
|
119
|
+
:"project" => project,
|
120
|
+
:"monitored_resource_descriptor" => monitored_resource_descriptor
|
121
|
+
)
|
122
|
+
end
|
123
|
+
|
124
|
+
# Parses the project from a project resource.
|
125
|
+
# @param project_name [String]
|
126
|
+
# @return [String]
|
127
|
+
def self.match_project_from_project_name project_name
|
128
|
+
PROJECT_PATH_TEMPLATE.match(project_name)["project"]
|
129
|
+
end
|
130
|
+
|
131
|
+
# Parses the project from a metric_descriptor resource.
|
132
|
+
# @param metric_descriptor_name [String]
|
133
|
+
# @return [String]
|
134
|
+
def self.match_project_from_metric_descriptor_name metric_descriptor_name
|
135
|
+
METRIC_DESCRIPTOR_PATH_TEMPLATE.match(metric_descriptor_name)["project"]
|
136
|
+
end
|
137
|
+
|
138
|
+
# Parses the metric_descriptor from a metric_descriptor resource.
|
139
|
+
# @param metric_descriptor_name [String]
|
140
|
+
# @return [String]
|
141
|
+
def self.match_metric_descriptor_from_metric_descriptor_name metric_descriptor_name
|
142
|
+
METRIC_DESCRIPTOR_PATH_TEMPLATE.match(metric_descriptor_name)["metric_descriptor"]
|
143
|
+
end
|
144
|
+
|
145
|
+
# Parses the project from a monitored_resource_descriptor resource.
|
146
|
+
# @param monitored_resource_descriptor_name [String]
|
147
|
+
# @return [String]
|
148
|
+
def self.match_project_from_monitored_resource_descriptor_name monitored_resource_descriptor_name
|
149
|
+
MONITORED_RESOURCE_DESCRIPTOR_PATH_TEMPLATE.match(monitored_resource_descriptor_name)["project"]
|
150
|
+
end
|
151
|
+
|
152
|
+
# Parses the monitored_resource_descriptor from a monitored_resource_descriptor resource.
|
153
|
+
# @param monitored_resource_descriptor_name [String]
|
154
|
+
# @return [String]
|
155
|
+
def self.match_monitored_resource_descriptor_from_monitored_resource_descriptor_name monitored_resource_descriptor_name
|
156
|
+
MONITORED_RESOURCE_DESCRIPTOR_PATH_TEMPLATE.match(monitored_resource_descriptor_name)["monitored_resource_descriptor"]
|
157
|
+
end
|
158
|
+
|
159
|
+
# @param service_path [String]
|
160
|
+
# The domain name of the API remote host.
|
161
|
+
# @param port [Integer]
|
162
|
+
# The port on which to connect to the remote host.
|
163
|
+
# @param channel [Channel]
|
164
|
+
# A Channel object through which to make calls.
|
165
|
+
# @param chan_creds [Grpc::ChannelCredentials]
|
166
|
+
# A ChannelCredentials for the setting up the RPC client.
|
167
|
+
# @param client_config[Hash]
|
168
|
+
# A Hash for call options for each method. See
|
169
|
+
# Google::Gax#construct_settings for the structure of
|
170
|
+
# this data. Falls back to the default config if not specified
|
171
|
+
# or the specified config is missing data points.
|
172
|
+
# @param timeout [Numeric]
|
173
|
+
# The default timeout, in seconds, for calls made through this client.
|
174
|
+
# @param app_name [String]
|
175
|
+
# The codename of the calling service.
|
176
|
+
# @param app_version [String]
|
177
|
+
# The version of the calling service.
|
178
|
+
def initialize \
|
179
|
+
service_path: SERVICE_ADDRESS,
|
180
|
+
port: DEFAULT_SERVICE_PORT,
|
181
|
+
channel: nil,
|
182
|
+
chan_creds: nil,
|
183
|
+
scopes: ALL_SCOPES,
|
184
|
+
client_config: {},
|
185
|
+
timeout: DEFAULT_TIMEOUT,
|
186
|
+
app_name: "gax",
|
187
|
+
app_version: Google::Gax::VERSION
|
188
|
+
# These require statements are intentionally placed here to initialize
|
189
|
+
# the gRPC module only when it's required.
|
190
|
+
# See https://github.com/googleapis/toolkit/issues/446
|
191
|
+
require "google/gax/grpc"
|
192
|
+
require "google/monitoring/v3/metric_service_services_pb"
|
193
|
+
|
194
|
+
google_api_client = "#{app_name}/#{app_version} " \
|
195
|
+
"#{CODE_GEN_NAME_VERSION} gax/#{Google::Gax::VERSION} " \
|
196
|
+
"ruby/#{RUBY_VERSION}".freeze
|
197
|
+
headers = { :"x-goog-api-client" => google_api_client }
|
198
|
+
client_config_file = Pathname.new(__dir__).join(
|
199
|
+
"metric_service_client_config.json"
|
200
|
+
)
|
201
|
+
defaults = client_config_file.open do |f|
|
202
|
+
Google::Gax.construct_settings(
|
203
|
+
"google.monitoring.v3.MetricService",
|
204
|
+
JSON.parse(f.read),
|
205
|
+
client_config,
|
206
|
+
Google::Gax::Grpc::STATUS_CODE_NAMES,
|
207
|
+
timeout,
|
208
|
+
page_descriptors: PAGE_DESCRIPTORS,
|
209
|
+
errors: Google::Gax::Grpc::API_ERRORS,
|
210
|
+
kwargs: headers
|
211
|
+
)
|
212
|
+
end
|
213
|
+
@metric_service_stub = Google::Gax::Grpc.create_stub(
|
214
|
+
service_path,
|
215
|
+
port,
|
216
|
+
chan_creds: chan_creds,
|
217
|
+
channel: channel,
|
218
|
+
scopes: scopes,
|
219
|
+
&Google::Monitoring::V3::MetricService::Stub.method(:new)
|
220
|
+
)
|
221
|
+
|
222
|
+
@list_monitored_resource_descriptors = Google::Gax.create_api_call(
|
223
|
+
@metric_service_stub.method(:list_monitored_resource_descriptors),
|
224
|
+
defaults["list_monitored_resource_descriptors"]
|
225
|
+
)
|
226
|
+
@get_monitored_resource_descriptor = Google::Gax.create_api_call(
|
227
|
+
@metric_service_stub.method(:get_monitored_resource_descriptor),
|
228
|
+
defaults["get_monitored_resource_descriptor"]
|
229
|
+
)
|
230
|
+
@list_metric_descriptors = Google::Gax.create_api_call(
|
231
|
+
@metric_service_stub.method(:list_metric_descriptors),
|
232
|
+
defaults["list_metric_descriptors"]
|
233
|
+
)
|
234
|
+
@get_metric_descriptor = Google::Gax.create_api_call(
|
235
|
+
@metric_service_stub.method(:get_metric_descriptor),
|
236
|
+
defaults["get_metric_descriptor"]
|
237
|
+
)
|
238
|
+
@create_metric_descriptor = Google::Gax.create_api_call(
|
239
|
+
@metric_service_stub.method(:create_metric_descriptor),
|
240
|
+
defaults["create_metric_descriptor"]
|
241
|
+
)
|
242
|
+
@delete_metric_descriptor = Google::Gax.create_api_call(
|
243
|
+
@metric_service_stub.method(:delete_metric_descriptor),
|
244
|
+
defaults["delete_metric_descriptor"]
|
245
|
+
)
|
246
|
+
@list_time_series = Google::Gax.create_api_call(
|
247
|
+
@metric_service_stub.method(:list_time_series),
|
248
|
+
defaults["list_time_series"]
|
249
|
+
)
|
250
|
+
@create_time_series = Google::Gax.create_api_call(
|
251
|
+
@metric_service_stub.method(:create_time_series),
|
252
|
+
defaults["create_time_series"]
|
253
|
+
)
|
254
|
+
end
|
255
|
+
|
256
|
+
# Service calls
|
257
|
+
|
258
|
+
# Lists monitored resource descriptors that match a filter. This method does not require a Stackdriver account.
|
259
|
+
#
|
260
|
+
# @param name [String]
|
261
|
+
# The project on which to execute the request. The format is
|
262
|
+
# +"projects/{project_id_or_number}"+.
|
263
|
+
# @param filter [String]
|
264
|
+
# An optional {filter}[https://cloud.google.com/monitoring/api/v3/filters] describing
|
265
|
+
# the descriptors to be returned. The filter can reference
|
266
|
+
# the descriptor's type and labels. For example, the
|
267
|
+
# following filter returns only Google Compute Engine descriptors
|
268
|
+
# that have an +id+ label:
|
269
|
+
#
|
270
|
+
# resource.type = starts_with("gce_") AND resource.label:id
|
271
|
+
# @param page_size [Integer]
|
272
|
+
# The maximum number of resources contained in the underlying API
|
273
|
+
# response. If page streaming is performed per-resource, this
|
274
|
+
# parameter does not affect the return value. If page streaming is
|
275
|
+
# performed per-page, this determines the maximum number of
|
276
|
+
# resources in a page.
|
277
|
+
# @param options [Google::Gax::CallOptions]
|
278
|
+
# Overrides the default settings for this call, e.g, timeout,
|
279
|
+
# retries, etc.
|
280
|
+
# @return [Google::Gax::PagedEnumerable<Google::Api::MonitoredResourceDescriptor>]
|
281
|
+
# An enumerable of Google::Api::MonitoredResourceDescriptor instances.
|
282
|
+
# See Google::Gax::PagedEnumerable documentation for other
|
283
|
+
# operations such as per-page iteration or access to the response
|
284
|
+
# object.
|
285
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
286
|
+
# @example
|
287
|
+
# require "google/cloud/monitoring/v3/metric_service_api"
|
288
|
+
#
|
289
|
+
# MetricServiceApi = Google::Cloud::Monitoring::V3::MetricServiceApi
|
290
|
+
#
|
291
|
+
# metric_service_api = MetricServiceApi.new
|
292
|
+
# formatted_name = MetricServiceApi.project_path("[PROJECT]")
|
293
|
+
#
|
294
|
+
# # Iterate over all results.
|
295
|
+
# metric_service_api.list_monitored_resource_descriptors(formatted_name).each do |element|
|
296
|
+
# # Process element.
|
297
|
+
# end
|
298
|
+
#
|
299
|
+
# # Or iterate over results one page at a time.
|
300
|
+
# metric_service_api.list_monitored_resource_descriptors(formatted_name).each_page do |page|
|
301
|
+
# # Process each page at a time.
|
302
|
+
# page.each do |element|
|
303
|
+
# # Process element.
|
304
|
+
# end
|
305
|
+
# end
|
306
|
+
|
307
|
+
def list_monitored_resource_descriptors \
|
308
|
+
name,
|
309
|
+
filter: nil,
|
310
|
+
page_size: nil,
|
311
|
+
options: nil
|
312
|
+
req = Google::Monitoring::V3::ListMonitoredResourceDescriptorsRequest.new(
|
313
|
+
name: name
|
314
|
+
)
|
315
|
+
req.filter = filter unless filter.nil?
|
316
|
+
req.page_size = page_size unless page_size.nil?
|
317
|
+
@list_monitored_resource_descriptors.call(req, options)
|
318
|
+
end
|
319
|
+
|
320
|
+
# Gets a single monitored resource descriptor. This method does not require a Stackdriver account.
|
321
|
+
#
|
322
|
+
# @param name [String]
|
323
|
+
# The monitored resource descriptor to get. The format is
|
324
|
+
# +"projects/{project_id_or_number}/monitoredResourceDescriptors/{resource_type}"+.
|
325
|
+
# The +{resource_type}+ is a predefined type, such as
|
326
|
+
# +cloudsql_database+.
|
327
|
+
# @param options [Google::Gax::CallOptions]
|
328
|
+
# Overrides the default settings for this call, e.g, timeout,
|
329
|
+
# retries, etc.
|
330
|
+
# @return [Google::Api::MonitoredResourceDescriptor]
|
331
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
332
|
+
# @example
|
333
|
+
# require "google/cloud/monitoring/v3/metric_service_api"
|
334
|
+
#
|
335
|
+
# MetricServiceApi = Google::Cloud::Monitoring::V3::MetricServiceApi
|
336
|
+
#
|
337
|
+
# metric_service_api = MetricServiceApi.new
|
338
|
+
# formatted_name = MetricServiceApi.monitored_resource_descriptor_path("[PROJECT]", "[MONITORED_RESOURCE_DESCRIPTOR]")
|
339
|
+
# response = metric_service_api.get_monitored_resource_descriptor(formatted_name)
|
340
|
+
|
341
|
+
def get_monitored_resource_descriptor \
|
342
|
+
name,
|
343
|
+
options: nil
|
344
|
+
req = Google::Monitoring::V3::GetMonitoredResourceDescriptorRequest.new(
|
345
|
+
name: name
|
346
|
+
)
|
347
|
+
@get_monitored_resource_descriptor.call(req, options)
|
348
|
+
end
|
349
|
+
|
350
|
+
# Lists metric descriptors that match a filter. This method does not require a Stackdriver account.
|
351
|
+
#
|
352
|
+
# @param name [String]
|
353
|
+
# The project on which to execute the request. The format is
|
354
|
+
# +"projects/{project_id_or_number}"+.
|
355
|
+
# @param filter [String]
|
356
|
+
# If this field is empty, all custom and
|
357
|
+
# system-defined metric descriptors are returned.
|
358
|
+
# Otherwise, the {filter}[https://cloud.google.com/monitoring/api/v3/filters]
|
359
|
+
# specifies which metric descriptors are to be
|
360
|
+
# returned. For example, the following filter matches all
|
361
|
+
# {custom metrics}[https://cloud.google.com/monitoring/custom-metrics]:
|
362
|
+
#
|
363
|
+
# metric.type = starts_with("custom.googleapis.com/")
|
364
|
+
# @param page_size [Integer]
|
365
|
+
# The maximum number of resources contained in the underlying API
|
366
|
+
# response. If page streaming is performed per-resource, this
|
367
|
+
# parameter does not affect the return value. If page streaming is
|
368
|
+
# performed per-page, this determines the maximum number of
|
369
|
+
# resources in a page.
|
370
|
+
# @param options [Google::Gax::CallOptions]
|
371
|
+
# Overrides the default settings for this call, e.g, timeout,
|
372
|
+
# retries, etc.
|
373
|
+
# @return [Google::Gax::PagedEnumerable<Google::Api::MetricDescriptor>]
|
374
|
+
# An enumerable of Google::Api::MetricDescriptor instances.
|
375
|
+
# See Google::Gax::PagedEnumerable documentation for other
|
376
|
+
# operations such as per-page iteration or access to the response
|
377
|
+
# object.
|
378
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
379
|
+
# @example
|
380
|
+
# require "google/cloud/monitoring/v3/metric_service_api"
|
381
|
+
#
|
382
|
+
# MetricServiceApi = Google::Cloud::Monitoring::V3::MetricServiceApi
|
383
|
+
#
|
384
|
+
# metric_service_api = MetricServiceApi.new
|
385
|
+
# formatted_name = MetricServiceApi.project_path("[PROJECT]")
|
386
|
+
#
|
387
|
+
# # Iterate over all results.
|
388
|
+
# metric_service_api.list_metric_descriptors(formatted_name).each do |element|
|
389
|
+
# # Process element.
|
390
|
+
# end
|
391
|
+
#
|
392
|
+
# # Or iterate over results one page at a time.
|
393
|
+
# metric_service_api.list_metric_descriptors(formatted_name).each_page do |page|
|
394
|
+
# # Process each page at a time.
|
395
|
+
# page.each do |element|
|
396
|
+
# # Process element.
|
397
|
+
# end
|
398
|
+
# end
|
399
|
+
|
400
|
+
def list_metric_descriptors \
|
401
|
+
name,
|
402
|
+
filter: nil,
|
403
|
+
page_size: nil,
|
404
|
+
options: nil
|
405
|
+
req = Google::Monitoring::V3::ListMetricDescriptorsRequest.new(
|
406
|
+
name: name
|
407
|
+
)
|
408
|
+
req.filter = filter unless filter.nil?
|
409
|
+
req.page_size = page_size unless page_size.nil?
|
410
|
+
@list_metric_descriptors.call(req, options)
|
411
|
+
end
|
412
|
+
|
413
|
+
# Gets a single metric descriptor. This method does not require a Stackdriver account.
|
414
|
+
#
|
415
|
+
# @param name [String]
|
416
|
+
# The metric descriptor on which to execute the request. The format is
|
417
|
+
# +"projects/{project_id_or_number}/metricDescriptors/{metric_id}"+.
|
418
|
+
# An example value of +{metric_id}+ is
|
419
|
+
# +"compute.googleapis.com/instance/disk/read_bytes_count"+.
|
420
|
+
# @param options [Google::Gax::CallOptions]
|
421
|
+
# Overrides the default settings for this call, e.g, timeout,
|
422
|
+
# retries, etc.
|
423
|
+
# @return [Google::Api::MetricDescriptor]
|
424
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
425
|
+
# @example
|
426
|
+
# require "google/cloud/monitoring/v3/metric_service_api"
|
427
|
+
#
|
428
|
+
# MetricServiceApi = Google::Cloud::Monitoring::V3::MetricServiceApi
|
429
|
+
#
|
430
|
+
# metric_service_api = MetricServiceApi.new
|
431
|
+
# formatted_name = MetricServiceApi.metric_descriptor_path("[PROJECT]", "[METRIC_DESCRIPTOR]")
|
432
|
+
# response = metric_service_api.get_metric_descriptor(formatted_name)
|
433
|
+
|
434
|
+
def get_metric_descriptor \
|
435
|
+
name,
|
436
|
+
options: nil
|
437
|
+
req = Google::Monitoring::V3::GetMetricDescriptorRequest.new(
|
438
|
+
name: name
|
439
|
+
)
|
440
|
+
@get_metric_descriptor.call(req, options)
|
441
|
+
end
|
442
|
+
|
443
|
+
# Creates a new metric descriptor.
|
444
|
+
# User-created metric descriptors define
|
445
|
+
# {custom metrics}[https://cloud.google.com/monitoring/custom-metrics].
|
446
|
+
#
|
447
|
+
# @param name [String]
|
448
|
+
# The project on which to execute the request. The format is
|
449
|
+
# +"projects/{project_id_or_number}"+.
|
450
|
+
# @param metric_descriptor [Google::Api::MetricDescriptor]
|
451
|
+
# The new {custom metric}[https://cloud.google.com/monitoring/custom-metrics]
|
452
|
+
# descriptor.
|
453
|
+
# @param options [Google::Gax::CallOptions]
|
454
|
+
# Overrides the default settings for this call, e.g, timeout,
|
455
|
+
# retries, etc.
|
456
|
+
# @return [Google::Api::MetricDescriptor]
|
457
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
458
|
+
# @example
|
459
|
+
# require "google/cloud/monitoring/v3/metric_service_api"
|
460
|
+
#
|
461
|
+
# MetricDescriptor = Google::Api::MetricDescriptor
|
462
|
+
# MetricServiceApi = Google::Cloud::Monitoring::V3::MetricServiceApi
|
463
|
+
#
|
464
|
+
# metric_service_api = MetricServiceApi.new
|
465
|
+
# formatted_name = MetricServiceApi.project_path("[PROJECT]")
|
466
|
+
# metric_descriptor = MetricDescriptor.new
|
467
|
+
# response = metric_service_api.create_metric_descriptor(formatted_name, metric_descriptor)
|
468
|
+
|
469
|
+
def create_metric_descriptor \
|
470
|
+
name,
|
471
|
+
metric_descriptor,
|
472
|
+
options: nil
|
473
|
+
req = Google::Monitoring::V3::CreateMetricDescriptorRequest.new(
|
474
|
+
name: name,
|
475
|
+
metric_descriptor: metric_descriptor
|
476
|
+
)
|
477
|
+
@create_metric_descriptor.call(req, options)
|
478
|
+
end
|
479
|
+
|
480
|
+
# Deletes a metric descriptor. Only user-created
|
481
|
+
# {custom metrics}[https://cloud.google.com/monitoring/custom-metrics] can be deleted.
|
482
|
+
#
|
483
|
+
# @param name [String]
|
484
|
+
# The metric descriptor on which to execute the request. The format is
|
485
|
+
# +"projects/{project_id_or_number}/metricDescriptors/{metric_id}"+.
|
486
|
+
# An example of +{metric_id}+ is:
|
487
|
+
# +"custom.googleapis.com/my_test_metric"+.
|
488
|
+
# @param options [Google::Gax::CallOptions]
|
489
|
+
# Overrides the default settings for this call, e.g, timeout,
|
490
|
+
# retries, etc.
|
491
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
492
|
+
# @example
|
493
|
+
# require "google/cloud/monitoring/v3/metric_service_api"
|
494
|
+
#
|
495
|
+
# MetricServiceApi = Google::Cloud::Monitoring::V3::MetricServiceApi
|
496
|
+
#
|
497
|
+
# metric_service_api = MetricServiceApi.new
|
498
|
+
# formatted_name = MetricServiceApi.metric_descriptor_path("[PROJECT]", "[METRIC_DESCRIPTOR]")
|
499
|
+
# metric_service_api.delete_metric_descriptor(formatted_name)
|
500
|
+
|
501
|
+
def delete_metric_descriptor \
|
502
|
+
name,
|
503
|
+
options: nil
|
504
|
+
req = Google::Monitoring::V3::DeleteMetricDescriptorRequest.new(
|
505
|
+
name: name
|
506
|
+
)
|
507
|
+
@delete_metric_descriptor.call(req, options)
|
508
|
+
end
|
509
|
+
|
510
|
+
# Lists time series that match a filter. This method does not require a Stackdriver account.
|
511
|
+
#
|
512
|
+
# @param name [String]
|
513
|
+
# The project on which to execute the request. The format is
|
514
|
+
# "projects/{project_id_or_number}".
|
515
|
+
# @param filter [String]
|
516
|
+
# A {monitoring filter}[https://cloud.google.com/monitoring/api/v3/filters] that specifies which time
|
517
|
+
# series should be returned. The filter must specify a single metric type,
|
518
|
+
# and can additionally specify metric labels and other information. For
|
519
|
+
# example:
|
520
|
+
#
|
521
|
+
# metric.type = "compute.googleapis.com/instance/cpu/usage_time" AND
|
522
|
+
# metric.label.instance_name = "my-instance-name"
|
523
|
+
# @param interval [Google::Monitoring::V3::TimeInterval]
|
524
|
+
# The time interval for which results should be returned. Only time series
|
525
|
+
# that contain data points in the specified interval are included
|
526
|
+
# in the response.
|
527
|
+
# @param aggregation [Google::Monitoring::V3::Aggregation]
|
528
|
+
# By default, the raw time series data is returned.
|
529
|
+
# Use this field to combine multiple time series for different
|
530
|
+
# views of the data.
|
531
|
+
# @param order_by [String]
|
532
|
+
# Specifies the order in which the points of the time series should
|
533
|
+
# be returned. By default, results are not ordered. Currently,
|
534
|
+
# this field must be left blank.
|
535
|
+
# @param view [Google::Monitoring::V3::ListTimeSeriesRequest::TimeSeriesView]
|
536
|
+
# Specifies which information is returned about the time series.
|
537
|
+
# @param page_size [Integer]
|
538
|
+
# The maximum number of resources contained in the underlying API
|
539
|
+
# response. If page streaming is performed per-resource, this
|
540
|
+
# parameter does not affect the return value. If page streaming is
|
541
|
+
# performed per-page, this determines the maximum number of
|
542
|
+
# resources in a page.
|
543
|
+
# @param options [Google::Gax::CallOptions]
|
544
|
+
# Overrides the default settings for this call, e.g, timeout,
|
545
|
+
# retries, etc.
|
546
|
+
# @return [Google::Gax::PagedEnumerable<Google::Monitoring::V3::TimeSeries>]
|
547
|
+
# An enumerable of Google::Monitoring::V3::TimeSeries instances.
|
548
|
+
# See Google::Gax::PagedEnumerable documentation for other
|
549
|
+
# operations such as per-page iteration or access to the response
|
550
|
+
# object.
|
551
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
552
|
+
# @example
|
553
|
+
# require "google/cloud/monitoring/v3/metric_service_api"
|
554
|
+
#
|
555
|
+
# MetricServiceApi = Google::Cloud::Monitoring::V3::MetricServiceApi
|
556
|
+
# TimeInterval = Google::Monitoring::V3::TimeInterval
|
557
|
+
# TimeSeriesView = Google::Monitoring::V3::ListTimeSeriesRequest::TimeSeriesView
|
558
|
+
#
|
559
|
+
# metric_service_api = MetricServiceApi.new
|
560
|
+
# formatted_name = MetricServiceApi.project_path("[PROJECT]")
|
561
|
+
# filter = ''
|
562
|
+
# interval = TimeInterval.new
|
563
|
+
# view = TimeSeriesView::FULL
|
564
|
+
#
|
565
|
+
# # Iterate over all results.
|
566
|
+
# metric_service_api.list_time_series(formatted_name, filter, interval, view).each do |element|
|
567
|
+
# # Process element.
|
568
|
+
# end
|
569
|
+
#
|
570
|
+
# # Or iterate over results one page at a time.
|
571
|
+
# metric_service_api.list_time_series(formatted_name, filter, interval, view).each_page do |page|
|
572
|
+
# # Process each page at a time.
|
573
|
+
# page.each do |element|
|
574
|
+
# # Process element.
|
575
|
+
# end
|
576
|
+
# end
|
577
|
+
|
578
|
+
def list_time_series \
|
579
|
+
name,
|
580
|
+
filter,
|
581
|
+
interval,
|
582
|
+
view,
|
583
|
+
aggregation: nil,
|
584
|
+
order_by: nil,
|
585
|
+
page_size: nil,
|
586
|
+
options: nil
|
587
|
+
req = Google::Monitoring::V3::ListTimeSeriesRequest.new(
|
588
|
+
name: name,
|
589
|
+
filter: filter,
|
590
|
+
interval: interval,
|
591
|
+
view: view
|
592
|
+
)
|
593
|
+
req.aggregation = aggregation unless aggregation.nil?
|
594
|
+
req.order_by = order_by unless order_by.nil?
|
595
|
+
req.page_size = page_size unless page_size.nil?
|
596
|
+
@list_time_series.call(req, options)
|
597
|
+
end
|
598
|
+
|
599
|
+
# Creates or adds data to one or more time series.
|
600
|
+
# The response is empty if all time series in the request were written.
|
601
|
+
# If any time series could not be written, a corresponding failure message is
|
602
|
+
# included in the error response.
|
603
|
+
#
|
604
|
+
# @param name [String]
|
605
|
+
# The project on which to execute the request. The format is
|
606
|
+
# +"projects/{project_id_or_number}"+.
|
607
|
+
# @param time_series [Array<Google::Monitoring::V3::TimeSeries>]
|
608
|
+
# The new data to be added to a list of time series.
|
609
|
+
# Adds at most one data point to each of several time series. The new data
|
610
|
+
# point must be more recent than any other point in its time series. Each
|
611
|
+
# +TimeSeries+ value must fully specify a unique time series by supplying
|
612
|
+
# all label values for the metric and the monitored resource.
|
613
|
+
# @param options [Google::Gax::CallOptions]
|
614
|
+
# Overrides the default settings for this call, e.g, timeout,
|
615
|
+
# retries, etc.
|
616
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
617
|
+
# @example
|
618
|
+
# require "google/cloud/monitoring/v3/metric_service_api"
|
619
|
+
#
|
620
|
+
# MetricServiceApi = Google::Cloud::Monitoring::V3::MetricServiceApi
|
621
|
+
#
|
622
|
+
# metric_service_api = MetricServiceApi.new
|
623
|
+
# formatted_name = MetricServiceApi.project_path("[PROJECT]")
|
624
|
+
# time_series = []
|
625
|
+
# metric_service_api.create_time_series(formatted_name, time_series)
|
626
|
+
|
627
|
+
def create_time_series \
|
628
|
+
name,
|
629
|
+
time_series,
|
630
|
+
options: nil
|
631
|
+
req = Google::Monitoring::V3::CreateTimeSeriesRequest.new(
|
632
|
+
name: name,
|
633
|
+
time_series: time_series
|
634
|
+
)
|
635
|
+
@create_time_series.call(req, options)
|
636
|
+
end
|
637
|
+
end
|
638
|
+
end
|
639
|
+
end
|
640
|
+
end
|
641
|
+
end
|