class Fog::Google::Monitoring::Mock
Public Class Methods
data()
click to toggle source
# File lib/fog/google/monitoring.rb, line 50 def self.data @data ||= Hash.new do |hash, key| hash[key] = { :timeseries => {}, :timeseries_descriptors => {}, :metric_descriptors => {}, } end end
new(options)
click to toggle source
# File lib/fog/google/monitoring.rb, line 46 def initialize(options) shared_initialize(options[:google_project], GOOGLE_MONITORING_API_VERSION, GOOGLE_MONITORING_BASE_URL) end
reset()
click to toggle source
# File lib/fog/google/monitoring.rb, line 60 def self.reset @data = nil end
Public Instance Methods
data()
click to toggle source
# File lib/fog/google/monitoring.rb, line 64 def data self.class.data[project] end
list_metric_descriptors(options = {})
click to toggle source
# File lib/fog/google/requests/monitoring/list_metric_descriptors.rb, line 25 def list_metric_descriptors(options = {}) body = { 'kind' => 'cloudmonitoring#listMetricDescriptorsResponse', 'metrics' => [ { 'name' => 'compute.googleapis.com/instance/cpu/reserved_cores', 'project' => @project, 'labels' => [ { 'key' => 'compute.googleapis.com/instance_name' }, { 'key' => 'cloud.googleapis.com/location' }, { 'key' => 'compute.googleapis.com/resource_id' }, { 'key' => 'compute.googleapis.com/resource_type' }, { 'key' => 'cloud.googleapis.com/service' } ], 'typeDescriptor' => { 'metricType' => 'gauge', 'valueType' => 'double' }, 'description' => 'Number of cores reserved on the host of the instance.' }, { 'name' => 'compute.googleapis.com/instance/cpu/usage_time', 'project' => @project, 'labels' => [ { 'key' => 'compute.googleapis.com/instance_name' }, { 'key' => 'cloud.googleapis.com/location' }, { 'key' => 'compute.googleapis.com/resource_id' }, { 'key' => 'compute.googleapis.com/resource_type' }, { 'key' => 'cloud.googleapis.com/service' } ], 'typeDescriptor' => { 'metricType' => 'delta', 'valueType' => 'double' }, 'description' => 'Delta CPU usage time. Units are seconds. You can get the per-core CPU utilization ratio by performing a rate operation on a point: doubleValue/(end-start), then divide by compute.googleapis.com/instance/cpu/reserved_cores at the corresponding end timestamp.' }, { 'name' => 'compute.googleapis.com/instance/disk/read_bytes_count', 'project' => @project, 'labels' => [ { 'key' => 'compute.googleapis.com/instance_name' }, { 'key' => 'compute.googleapis.com/device_name' }, { 'key' => 'compute.googleapis.com/device_type' }, { 'key' => 'cloud.googleapis.com/location' }, { 'key' => 'compute.googleapis.com/resource_id' }, { 'key' => 'compute.googleapis.com/resource_type' }, { 'key' => 'cloud.googleapis.com/service' } ], 'typeDescriptor' => { 'metricType' => 'delta', 'valueType' => 'int64' }, 'description' => 'Delta count of bytes read from disk.' }, { 'name' => 'compute.googleapis.com/instance/disk/read_ops_count', 'project' => @project, 'labels' => [ { 'key' => 'compute.googleapis.com/instance_name' }, { 'key' => 'compute.googleapis.com/device_name' }, { 'key' => 'compute.googleapis.com/device_type' }, { 'key' => 'cloud.googleapis.com/location' }, { 'key' => 'compute.googleapis.com/resource_id' }, { 'key' => 'compute.googleapis.com/resource_type' }, { 'key' => 'cloud.googleapis.com/service' } ], 'typeDescriptor' => { 'metricType' => 'delta', 'valueType' => 'int64' }, 'description' => 'Delta count of disk read IO operations.' }, { 'name' => 'compute.googleapis.com/instance/disk/write_bytes_count', 'project' => @project, 'labels' => [ { 'key' => 'compute.googleapis.com/instance_name' }, { 'key' => 'compute.googleapis.com/device_name' }, { 'key' => 'compute.googleapis.com/device_type' }, { 'key' => 'cloud.googleapis.com/location' }, { 'key' => '"compute.googleapis.com/resource_id' }, { 'key' => 'compute.googleapis.com/resource_type' }, { 'key' => 'cloud.googleapis.com/service' } ], 'typeDescriptor' => { 'metricType' => 'delta', 'valueType' => 'int64' }, 'description' => 'Delta count of bytes written to disk.' }, { 'name' => 'compute.googleapis.com/instance/disk/write_ops_count', 'project' => @project, 'labels' => [ { 'key' => 'compute.googleapis.com/instance_name' }, { 'key' => 'compute.googleapis.com/device_name' }, { 'key' => '"compute.googleapis.com/device_type' }, { 'key' => 'cloud.googleapis.com/location' }, { 'key' => 'compute.googleapis.com/resource_id' }, { 'key' => 'compute.googleapis.com/resource_type' }, { 'key' => 'cloud.googleapis.com/service' } ], 'typeDescriptor' => { 'metricType' => 'delta', 'valueType' => 'int64' }, 'description' => 'Delta count of disk write IO operations.' }, { 'name' => 'compute.googleapis.com/instance/network/received_bytes_count', 'project' => @project, 'labels' => [ { 'key' => 'compute.googleapis.com/instance_name' }, { 'key' => 'compute.googleapis.com/loadbalanced' }, { 'key' => 'cloud.googleapis.com/location' }, { 'key' => 'compute.googleapis.com/resource_id' }, { 'key' => 'compute.googleapis.com/resource_type' }, { 'key' => 'cloud.googleapis.com/service' } ], 'typeDescriptor' => { 'metricType' => 'delta', 'valueType' => 'int64' }, 'description' => 'Delta count of bytes received from network.' }, { 'name' => 'compute.googleapis.com/instance/network/received_packets_count', 'project' => @project, 'labels' => [ { 'key' => 'compute.googleapis.com/instance_name' }, { 'key' => 'compute.googleapis.com/loadbalanced' }, { 'key' => 'cloud.googleapis.com/location' }, { 'key' => 'compute.googleapis.com/resource_id' }, { 'key' => 'compute.googleapis.com/resource_type' }, { 'key' => 'cloud.googleapis.com/service' } ], 'typeDescriptor' => { 'metricType' => 'delta', 'valueType' => 'int64' }, 'description' => 'Delta count of packets received from network.' }, { 'name' => 'compute.googleapis.com/instance/network/sent_bytes_count', 'project' => @project, 'labels' => [ { 'key' => 'compute.googleapis.com/instance_name' }, { 'key' => 'compute.googleapis.com/loadbalanced' }, { 'key' => 'cloud.googleapis.com/location' }, { 'key' => 'compute.googleapis.com/resource_id' }, { 'key' => 'compute.googleapis.com/resource_type' }, { 'key' => 'cloud.googleapis.com/service' } ], 'typeDescriptor' => { 'metricType' => 'delta', 'valueType' => 'int64' }, 'description' => 'Delta count of bytes sent over network.' }, { 'name' => 'compute.googleapis.com/instance/network/sent_packets_count', 'project' => @project, 'labels' => [ { 'key' => 'compute.googleapis.com/instance_name' }, { 'key' => 'compute.googleapis.com/loadbalanced' }, { 'key' => 'cloud.googleapis.com/location' }, { 'key' => 'compute.googleapis.com/resource_id' }, { 'key' => 'compute.googleapis.com/resource_type' }, { 'key' => 'cloud.googleapis.com/service' } ], 'typeDescriptor' => { 'metricType' => 'delta', 'valueType' => 'int64' }, 'description' => 'Delta count of packets sent over network.' }, { 'name' => 'compute.googleapis.com/instance/uptime', 'project' => @project, 'labels' => [ { 'key' => 'compute.googleapis.com/instance_name' }, { 'key' => 'cloud.googleapis.com/location' }, { 'key' => 'compute.googleapis.com/resource_id' }, { 'key' => 'compute.googleapis.com/resource_type' }, { 'key' => 'cloud.googleapis.com/service' } ], 'typeDescriptor' => { 'metricType' => 'delta', 'valueType' => 'double' }, 'description' => 'Indicates the VM running time in seconds.' }, ] } build_excon_response(body) end
list_timeseries(metric, youngest, options = {})
click to toggle source
# File lib/fog/google/requests/monitoring/list_timeseries.rb, line 29 def list_timeseries(metric, youngest, options = {}) body = { 'kind' => 'cloudmonitoring#listTimeseriesResponse', 'youngest' => youngest, 'oldest' => youngest, 'timeseries' => [ { 'timeseriesDesc' => { 'project' => @project, 'metric' => metric, 'labels' => { 'cloud.googleapis.com/service' => 'compute.googleapis.com', 'compute.googleapis.com/resource_type' => 'instance', 'cloud.googleapis.com/location' => 'us-central1-a', 'compute.googleapis.com/resource_id' => Fog::Mock.random_numbers(20).to_s, 'compute.googleapis.com/instance_name' => Fog::Mock.random_hex(40), }, }, 'points' => [ { 'start' => '2014-07-17T20:06:58.000Z', 'end' => '2014-07-17T20:07:58.000Z', 'doubleValue' => 60.0 }, { 'start' => '2014-07-17T20:05:58.000Z', 'end' => '2014-07-17T20:06:58.000Z', 'doubleValue' => 60.0 }, ], } ] } build_excon_response(body) end
list_timeseries_descriptors(metric, youngest, options = {})
click to toggle source
# File lib/fog/google/requests/monitoring/list_timeseries_descriptors.rb, line 29 def list_timeseries_descriptors(metric, youngest, options = {}) body = { 'kind' => 'cloudmonitoring#listTimeseriesDescriptorsResponse', 'youngest' => youngest, 'oldest' => youngest, 'timeseries' => [ { 'project' => @project, 'metric' => metric, 'labels' => { 'cloud.googleapis.com/service' => 'compute.googleapis.com', 'compute.googleapis.com/resource_type' => 'instance', 'cloud.googleapis.com/location' => 'us-central1-a', 'compute.googleapis.com/resource_id' => Fog::Mock.random_numbers(20).to_s, 'compute.googleapis.com/instance_name' => Fog::Mock.random_hex(40), }, }, { 'project' => @project, 'metric' => metric, 'labels' => { 'cloud.googleapis.com/service' => 'compute.googleapis.com', 'compute.googleapis.com/resource_type' => 'instance', 'cloud.googleapis.com/location' => 'us-central1-a', 'compute.googleapis.com/resource_id' => Fog::Mock.random_numbers(20).to_s, 'compute.googleapis.com/instance_name' => Fog::Mock.random_hex(40), }, }, { 'project' => @project, 'metric' => metric, 'labels' => { 'cloud.googleapis.com/service' => 'compute.googleapis.com', 'compute.googleapis.com/resource_type' => 'instance', 'cloud.googleapis.com/location' => 'us-central1-a', 'compute.googleapis.com/resource_id' => Fog::Mock.random_numbers(20).to_s, 'compute.googleapis.com/instance_name' => Fog::Mock.random_hex(40), }, }, { 'project' => @project, 'metric' => metric, 'labels' => { 'cloud.googleapis.com/service' => 'compute.googleapis.com', 'compute.googleapis.com/resource_type' => 'instance', 'cloud.googleapis.com/location' => 'us-central1-a', 'compute.googleapis.com/resource_id' => Fog::Mock.random_numbers(20).to_s, 'compute.googleapis.com/instance_name' => Fog::Mock.random_hex(40), }, }, ] } build_excon_response(body) end
reset_data()
click to toggle source
# File lib/fog/google/monitoring.rb, line 68 def reset_data self.class.data.delete(project) end