From c8a7fc65cd89f2450f0b07ddbcb5db81f9a10998 Mon Sep 17 00:00:00 2001 From: Emily Ye Date: Mon, 25 Sep 2017 22:20:40 +0000 Subject: [PATCH 1/8] change monitoring api version to v3 --- lib/fog/google/monitoring.rb | 13 +++---------- lib/fog/google/monitoring/mock.rb | 2 +- lib/fog/google/monitoring/real.rb | 2 +- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/lib/fog/google/monitoring.rb b/lib/fog/google/monitoring.rb index 08dccd9d92..00347979e8 100644 --- a/lib/fog/google/monitoring.rb +++ b/lib/fog/google/monitoring.rb @@ -17,9 +17,9 @@ class Monitoring < Fog::Service :google_json_key_string ) - GOOGLE_MONITORING_API_VERSION = "v2beta2".freeze - GOOGLE_MONITORING_BASE_URL = "https://www.googleapis.com/cloudmonitoring/" - GOOGLE_MONITORING_API_SCOPE_URLS = %w(https://www.googleapis.com/auth/monitoring) + GOOGLE_MONITORING_API_VERSION = "v3".freeze + GOOGLE_MONITORING_BASE_URL = "https://monitoring.googleapis.com/".freeze + GOOGLE_MONITORING_API_SCOPE_URLS = %w(https://www.googleapis.com/auth/monitoring).freeze ## # MODELS @@ -29,10 +29,6 @@ class Monitoring < Fog::Service model :timeseries collection :timeseries_collection - # TimeseriesDescriptors - model :timeseries_descriptor - collection :timeseries_descriptors - # MetricDescriptors model :metric_descriptor collection :metric_descriptors @@ -44,9 +40,6 @@ class Monitoring < Fog::Service # Timeseries request :list_timeseries - # TimeseriesDescriptors - request :list_timeseries_descriptors - # MetricDescriptors request :list_metric_descriptors end diff --git a/lib/fog/google/monitoring/mock.rb b/lib/fog/google/monitoring/mock.rb index 8b01e29d95..cf74123498 100644 --- a/lib/fog/google/monitoring/mock.rb +++ b/lib/fog/google/monitoring/mock.rb @@ -12,7 +12,7 @@ def self.data @data ||= Hash.new do |hash, key| hash[key] = { :timeseries => {}, - :timeseries_descriptors => {}, + :monitored_resource_descriptor => {}, :metric_descriptors => {} } end diff --git a/lib/fog/google/monitoring/real.rb b/lib/fog/google/monitoring/real.rb index dff8dc5ee8..700b39f467 100644 --- a/lib/fog/google/monitoring/real.rb +++ b/lib/fog/google/monitoring/real.rb @@ -12,7 +12,7 @@ def initialize(options) options[:google_api_scope_url] = GOOGLE_MONITORING_API_SCOPE_URLS.join(" ") @client = initialize_google_client(options) - @monitoring = @client.discovered_api("cloudmonitoring", api_version) + @monitoring = @client.discovered_api("monitoring", api_version) end end end From 235da941700b8f2776961636e371f3230acaaa5e Mon Sep 17 00:00:00 2001 From: Emily Ye Date: Mon, 25 Sep 2017 22:48:15 +0000 Subject: [PATCH 2/8] remove deprecated timeseries_descriptors resource for monitoring --- examples/monitoring/timeseries_descriptors.rb | 27 ------ .../monitoring/timeseries_descriptor.rb | 20 ----- .../monitoring/timeseries_descriptors.rb | 31 ------- .../monitoring/list_timeseries_descriptors.rb | 87 ------------------- .../timeseries_descriptors_tests.rb | 10 --- .../monitoring/timeseries_descriptor_tests.rb | 23 ----- 6 files changed, 198 deletions(-) delete mode 100644 examples/monitoring/timeseries_descriptors.rb delete mode 100644 lib/fog/google/models/monitoring/timeseries_descriptor.rb delete mode 100644 lib/fog/google/models/monitoring/timeseries_descriptors.rb delete mode 100644 lib/fog/google/requests/monitoring/list_timeseries_descriptors.rb delete mode 100644 tests/models/monitoring/timeseries_descriptors_tests.rb delete mode 100644 tests/requests/monitoring/timeseries_descriptor_tests.rb diff --git a/examples/monitoring/timeseries_descriptors.rb b/examples/monitoring/timeseries_descriptors.rb deleted file mode 100644 index 7b9cbad319..0000000000 --- a/examples/monitoring/timeseries_descriptors.rb +++ /dev/null @@ -1,27 +0,0 @@ -# All examples presume that you have a ~/.fog credentials file set up. -# # More info on it can be found here: http://fog.io/about/getting_started.html -# -require "bundler" -Bundler.require(:default, :development) -# Uncomment this if you want to make real requests to GCE (you _will_ be billed!) -# WebMock.disable! - -def test - connection = Fog::Google::Monitoring.new - - puts "Listing all TimeseriesDescriptors for the metric compute.googleapis.com/instance/uptime..." - puts "------------------------------------------------------------------------------------------" - td = connection.timeseries_descriptors.all("compute.googleapis.com/instance/uptime", - DateTime.now.rfc3339) - puts "Number of matches: #{td.length}" - - puts "Listing all TimeseriesDescriptors for the metric compute.googleapis.com/instance/uptime &" - puts "the region us-central1..." - puts "-----------------------------------------------------------------------------------------" - td = connection.timeseries_descriptors.all("compute.googleapis.com/instance/uptime", - DateTime.now.rfc3339, - :labels => "cloud.googleapis.com/location=~us-central1.*") - puts "Number of matches: #{td.length}" -end - -test diff --git a/lib/fog/google/models/monitoring/timeseries_descriptor.rb b/lib/fog/google/models/monitoring/timeseries_descriptor.rb deleted file mode 100644 index 4562d57f88..0000000000 --- a/lib/fog/google/models/monitoring/timeseries_descriptor.rb +++ /dev/null @@ -1,20 +0,0 @@ -require "fog/core/model" - -module Fog - module Google - class Monitoring - ## - # A time series is a collection of data points that represents the value of a metric of a project over time. - # The metric is described by the time-series descriptor. Each time-series descriptor is uniquely identified by - # its metric name and a set of labels. - # - # @see https://developers.google.com/cloud-monitoring/v2beta1/timeseriesDescriptors - class TimeseriesDescriptor < Fog::Model - identity :metric - - attribute :labels - attribute :project - end - end - end -end diff --git a/lib/fog/google/models/monitoring/timeseries_descriptors.rb b/lib/fog/google/models/monitoring/timeseries_descriptors.rb deleted file mode 100644 index 3413308d34..0000000000 --- a/lib/fog/google/models/monitoring/timeseries_descriptors.rb +++ /dev/null @@ -1,31 +0,0 @@ -require "fog/core/collection" -require "fog/google/models/monitoring/timeseries_descriptor" - -module Fog - module Google - class Monitoring - class TimeseriesDescriptors < Fog::Collection - model Fog::Google::Monitoring::TimeseriesDescriptor - - ## - # Lists all Timeseries Descriptors. - # - # @param [String] metric The name of the metric (Metric names are protocol-free URLs). - # @param [String] youngest End of the time interval (inclusive), which is expressed as an RFC 3339 timestamp. - # @param [Hash] options Optional query parameters. - # @option options [String] count Maximum number of time series descriptors per page. Used for pagination. - # @option options [String] labels A collection of labels for the matching time series. - # @option options [String] oldest Start of the time interval (exclusive), which is expressed as an RFC 3339 - # timestamp. - # @options options [String] page_token The pagination token, which is used to page through large result sets. - # @options options [String] timespan Length of the time interval to query, which is an alternative way to - # declare the interval. - # @return [Array] List of Timeseries Descriptors. - def all(metric, youngest, options = {}) - data = service.list_timeseries_descriptors(metric, youngest, options).body["timeseries"] || [] - load(data) - end - end - end - end -end diff --git a/lib/fog/google/requests/monitoring/list_timeseries_descriptors.rb b/lib/fog/google/requests/monitoring/list_timeseries_descriptors.rb deleted file mode 100644 index 4fe462d93d..0000000000 --- a/lib/fog/google/requests/monitoring/list_timeseries_descriptors.rb +++ /dev/null @@ -1,87 +0,0 @@ -module Fog - module Google - class Monitoring - ## - # List the descriptors of the time series that match the metric and labels values and that have data points - # in the interval. - # - # @see https://developers.google.com/cloud-monitoring/v2beta1/timeseriesDescriptors/list - class Real - def list_timeseries_descriptors(metric, youngest, options = {}) - api_method = @monitoring.timeseries_descriptors.list - parameters = { - "project" => @project, - "metric" => metric, - "youngest" => youngest - } - - parameters["count"] = options[:count] if options.key?(:count) - parameters["labels"] = options[:labels] if options.key?(:labels) - parameters["oldest"] = options[:oldest] if options.key?(:oldest) - parameters["pageToken"] = options[:page_token] if options.key?(:page_token) - parameters["timespan"] = options[:timespan] if options.key?(:timespan) - - request(api_method, parameters) - end - end - - class Mock - 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 - end - end - end -end diff --git a/tests/models/monitoring/timeseries_descriptors_tests.rb b/tests/models/monitoring/timeseries_descriptors_tests.rb deleted file mode 100644 index 5255e59e7e..0000000000 --- a/tests/models/monitoring/timeseries_descriptors_tests.rb +++ /dev/null @@ -1,10 +0,0 @@ -Shindo.tests("Fog::Google[:monitoring] | timeseries_descriptors model", ["google"]) do - @timeseries_descriptors = Fog::Google[:monitoring].timeseries_descriptors - - tests("success") do - tests('#all').succeeds do - @timeseries_descriptors.all("compute.googleapis.com/instance/uptime", - Time.now.strftime("%Y-%m-%dT%H:%M:%S%:z")) - end - end -end diff --git a/tests/requests/monitoring/timeseries_descriptor_tests.rb b/tests/requests/monitoring/timeseries_descriptor_tests.rb deleted file mode 100644 index 8b870d0e77..0000000000 --- a/tests/requests/monitoring/timeseries_descriptor_tests.rb +++ /dev/null @@ -1,23 +0,0 @@ -Shindo.tests("Fog::Google[:monitoring] | timeseries_descriptor requests", ["google"]) do - @monitoring = Fog::Google[:monitoring] - - @get_timeseries_descriptor_format = { - "metric" => String, - "project" => String, - "labels" => Hash - } - - @list_timeseries_descriptors_format = { - "kind" => String, - "youngest" => String, - "oldest" => String, - "timeseries" => [@get_timeseries_descriptor_format] - } - - tests("success") do - tests('#list_timeseries_descriptors').formats(@list_timeseries_descriptors_format) do - @monitoring.list_timeseries_descriptors("compute.googleapis.com/instance/uptime", - Time.now.strftime("%Y-%m-%dT%H:%M:%S%:z")).body - end - end -end From 665bdd89df3cf40d8bc73ded4d9a697da0d75c5b Mon Sep 17 00:00:00 2001 From: Emily Ye Date: Mon, 25 Sep 2017 22:49:11 +0000 Subject: [PATCH 3/8] migrate metric_descriptors resource to v3 monitoring --- examples/monitoring/metric_descriptors.rb | 2 +- .../models/monitoring/metric_descriptor.rb | 11 +- .../models/monitoring/metric_descriptors.rb | 10 +- .../monitoring/list_metric_descriptors.rb | 305 +++++++++++------- .../monitoring/metric_descriptors_tests.rb | 9 - 5 files changed, 193 insertions(+), 144 deletions(-) delete mode 100644 tests/models/monitoring/metric_descriptors_tests.rb diff --git a/examples/monitoring/metric_descriptors.rb b/examples/monitoring/metric_descriptors.rb index d419f18f3e..d96ac35405 100644 --- a/examples/monitoring/metric_descriptors.rb +++ b/examples/monitoring/metric_descriptors.rb @@ -17,7 +17,7 @@ def test puts "\nListing all MetricDescriptors related to Google Compute Engine..." puts "-----------------------------------------------------------------" - md = connection.metric_descriptors.all(:query => "compute") + md = connection.metric_descriptors.all(:filter => 'metric.type = starts_with("compute.googleapis.com")') puts "Number of compute metric descriptors: #{md.length}" end diff --git a/lib/fog/google/models/monitoring/metric_descriptor.rb b/lib/fog/google/models/monitoring/metric_descriptor.rb index 585b9afbb4..6500536259 100644 --- a/lib/fog/google/models/monitoring/metric_descriptor.rb +++ b/lib/fog/google/models/monitoring/metric_descriptor.rb @@ -4,16 +4,19 @@ module Fog module Google class Monitoring ## - # A metricDescriptor defines the name, label keys, and data type of a particular metric. + # A metricDescriptor defines a metric type and its schema. # - # @see https://cloud.google.com/monitoring/v2beta2/metricDescriptors#resource + # @see https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.metricDescriptors#MetricDescriptor class MetricDescriptor < Fog::Model identity :name attribute :description + attribute :display_name, :aliases => "displayName" attribute :labels - attribute :project - attribute :type_descriptor, :aliases => "typeDescriptor" + attribute :metric_kind, :aliases => "metricKind" + attribute :type + attribute :value_type, :aliases => "valueType" + attribute :unit end end end diff --git a/lib/fog/google/models/monitoring/metric_descriptors.rb b/lib/fog/google/models/monitoring/metric_descriptors.rb index b9aba07bf9..678ea9095d 100644 --- a/lib/fog/google/models/monitoring/metric_descriptors.rb +++ b/lib/fog/google/models/monitoring/metric_descriptors.rb @@ -11,15 +11,13 @@ class MetricDescriptors < Fog::Collection # Lists all Metric Descriptors. # # @param [Hash] options Optional query parameters. - # @option options [String] count Maximum number of time series descriptors per page. Used for pagination. + # @option options [String] page_size Maximum number of metric descriptors per page. Used for pagination. # @option options [String] page_token The pagination token, which is used to page through large result sets. - # @option options [String] query The query used to search against existing metrics. Separate keywords with a space; - # the service joins all keywords with AND, meaning that all keywords must match for a metric to be returned. - # If this field is omitted, all metrics are returned. If an empty string is passed with this field, - # no metrics are returned. + # @option options [String] filter Monitoring filter specifying which metric descriptors are to be returned. + # @see https://cloud.google.com/monitoring/api/v3/filters filter documentation # @return [Array] List of Metric Descriptors. def all(options = {}) - data = service.list_metric_descriptors(options).body["metrics"] || [] + data = service.list_metric_descriptors(options).body["metricDescriptors"] || [] load(data) end end diff --git a/lib/fog/google/requests/monitoring/list_metric_descriptors.rb b/lib/fog/google/requests/monitoring/list_metric_descriptors.rb index e536dea8d0..bbec3c4d24 100644 --- a/lib/fog/google/requests/monitoring/list_metric_descriptors.rb +++ b/lib/fog/google/requests/monitoring/list_metric_descriptors.rb @@ -2,21 +2,20 @@ module Fog module Google class Monitoring ## - # List metric descriptors that match the query. If the query is not set, then all of the metric descriptors - # will be returned. + # Lists metric descriptors that match a filter. # - # @see https://cloud.google.com/monitoring/v2beta2/metricDescriptors/list + # @see https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.metricDescriptors/list class Real def list_metric_descriptors(options = {}) - api_method = @monitoring.metric_descriptors.list + api_method = @monitoring.projects.metric_descriptors.list parameters = { - "project" => @project + "name" => "projects/#{@project}" } - - parameters["count"] = options[:count] if options.key?(:count) + parameters["filter"] = options[:filter] if options.key?(:filter) + parameters["pageSize"] = options[:page_size] if options.key?(:page_size) parameters["pageToken"] = options[:page_token] if options.key?(:page_token) - parameters["query"] = options[:query] if options.key?(:query) + puts parameters request(api_method, parameters) end end @@ -24,161 +23,219 @@ def list_metric_descriptors(options = {}) class Mock 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." - }, + "metricDescriptors" => [ { - "name" => "compute.googleapis.com/instance/cpu/usage_time", - "project" => @project, + "type" => "compute.googleapis.com/instance/cpu/reserved_cores", + "name" => "projects/#{@project}/metricDescriptors/compute.googleapis.com/instance/cpu/reserved_cores", "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" } + { + "key" => "instance_name", + "description" => "The name of the VM instance." + } ], - "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." + "metricKind" => "GAUGE", + "valueType" => "DOUBLE", + "unit" => "1", + "description" => "Number of cores reserved on the host of the instance.", + "displayName" => "Reserved cores" }, { - "name" => "compute.googleapis.com/instance/disk/read_bytes_count", - "project" => @project, + "type" => "compute.googleapis.com/instance/cpu/usage_time", + "name" => "projects/#{@project}/metricDescriptors/compute.googleapis.com/instance/cpu/usage_time", "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" } + { + "key" => "instance_name", + "description" => "The name of the VM instance." + } ], - "typeDescriptor" => { "metricType" => "delta", "valueType" => "int64" }, - "description" => "Delta count of bytes read from disk." + "metricKind" => "DELTA", + "valueType" => "DOUBLE", + "unit" => "s", + "description" => "Delta CPU usage for all cores, in seconds. To compute the per-core CPU utilization fraction, divide this value by (end-start)*N, where end and start define this value's time interval and N is `compute.googleapis.com/instance/cpu/reserved_cores` at the end of the interval.", + "displayName" => "CPU usage" }, { - "name" => "compute.googleapis.com/instance/disk/read_ops_count", - "project" => @project, + "type" => "compute.googleapis.com/instance/disk/read_bytes_count", + "name" => "projects/#{@project}/metricDescriptors/compute.googleapis.com/instance/disk/read_bytes_count", "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" } + { + "key" => "instance_name", + "description" => "The name of the VM instance." + }, + { + "key" => "device_name", + "description" => "The name of the disk device." + }, + { + "key" => "storage_type", + "description" => "The storage type => `pd-standard` or `pd-ssd`." + }, + { + "key" => "device_type", + "description" => "The disk type => `ephemeral` or `permanent`." + } ], - "typeDescriptor" => { "metricType" => "delta", "valueType" => "int64" }, - "description" => "Delta count of disk read IO operations." + "metricKind" => "DELTA", + "valueType" => "INT64", + "unit" => "By", + "description" => "Delta count of bytes read from disk.", + "displayName" => "Disk read bytes" }, { - "name" => "compute.googleapis.com/instance/disk/write_bytes_count", - "project" => @project, + "name" => "projects/#{@project}/metricDescriptors/compute.googleapis.com/instance/disk/read_ops_count", "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" } + { + "key" => "instance_name", + "description" => "The name of the VM instance." + }, + { + "key" => "device_name", + "description" => "The name of the disk device." + }, + { + "key" => "storage_type", + "description" => "The storage type => `pd-standard` or `pd-ssd`." + }, + { + "key" => "device_type", + "description" => "The disk type => `ephemeral` or `permanent`." + } ], - "typeDescriptor" => { "metricType" => "delta", "valueType" => "int64" }, - "description" => "Delta count of bytes written to disk." + "metricKind" => "DELTA", + "valueType" => "INT64", + "unit" => "1", + "description" => "Delta count of disk read IO operations.", + "displayName" => "Disk read operations", + "type" => "compute.googleapis.com/instance/disk/read_ops_count" }, { - "name" => "compute.googleapis.com/instance/disk/write_ops_count", - "project" => @project, + "type" => "compute.googleapis.com/instance/disk/write_bytes_count", + "name" => "projects/#{@project}/metricDescriptors/compute.googleapis.com/instance/disk/write_bytes_count", "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" } + { + "key" => "instance_name", + "description" => "The name of the VM instance." + }, + { + "key" => "device_name", + "description" => "The name of the disk device." + }, + { + "key" => "storage_type", + "description" => "The storage type => `pd-standard` or `pd-ssd`." + }, + { + "key" => "device_type", + "description" => "The disk type => `ephemeral` or `permanent`." + } ], - "typeDescriptor" => { "metricType" => "delta", "valueType" => "int64" }, - "description" => "Delta count of disk write IO operations." + "metricKind" => "DELTA", + "valueType" => "INT64", + "unit" => "By", + "description" => "Delta count of bytes written to disk.", + "displayName" => "Disk write bytes" }, { - "name" => "compute.googleapis.com/instance/network/received_bytes_count", - "project" => @project, + "type" => "compute.googleapis.com/instance/disk/write_ops_count", + "name" => "projects/#{@project}/metricDescriptors/compute.googleapis.com/instance/disk/write_ops_count", "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" } + { + "key" => "instance_name", + "description" => "The name of the VM instance." + }, + { + "key" => "device_name", + "description" => "The name of the disk device." + }, + { + "key" => "storage_type", + "description" => "The storage type => `pd-standard` or `pd-ssd`." + }, + { + "key" => "device_type", + "description" => "The disk type => `ephemeral` or `permanent`." + } ], - "typeDescriptor" => { "metricType" => "delta", "valueType" => "int64" }, - "description" => "Delta count of bytes received from network." + "metricKind" => "DELTA", + "valueType" => "INT64", + "unit" => "1", + "description" => "Delta count of disk write IO operations.", + "displayName" => "Disk write operations" }, { - "name" => "compute.googleapis.com/instance/network/received_packets_count", - "project" => @project, + "type" => "compute.googleapis.com/instance/network/received_packets_count", + "name" => "projects/#{@project}/metricDescriptors/compute.googleapis.com/instance/network/received_packets_count", "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" } + { + "key" => "instance_name", + "description" => "The name of the VM instance." + }, + { + "key" => "loadbalanced", + "valueType" => "BOOL", + "description" => "Whether traffic was received by an L3 loadbalanced IP address assigned to the VM. Traffic that is externally routed to the VM's standard internal or external IP address, such as L7 loadbalanced traffic, is not considered to be loadbalanced in this metric." + } ], - "typeDescriptor" => { "metricType" => "delta", "valueType" => "int64" }, - "description" => "Delta count of packets received from network." + "metricKind" => "DELTA", + "valueType" => "INT64", + "unit" => "1", + "description" => "Delta count of packets received from the network.", + "displayName" => "Received packets" }, { - "name" => "compute.googleapis.com/instance/network/sent_bytes_count", - "project" => @project, + "type" => "compute.googleapis.com/instance/network/sent_bytes_count", + "name" => "projects/#{@project}/metricDescriptors/compute.googleapis.com/instance/network/sent_bytes_count", "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" } + { + "key" => "instance_name", + "description" => "The name of the VM instance." + }, + { + "key" => "loadbalanced", + "valueType" => "BOOL", + "description" => "Whether traffic was sent from an L3 loadbalanced IP address assigned to the VM. Traffic that is externally routed from the VM's standard internal or external IP address, such as L7 loadbalanced traffic, is not considered to be loadbalanced in this metric." + } ], - "typeDescriptor" => { "metricType" => "delta", "valueType" => "int64" }, - "description" => "Delta count of bytes sent over network." + "metricKind" => "DELTA", + "valueType" => "INT64", + "unit" => "By", + "description" => "Delta count of bytes sent over the network.", + "displayName" => "Sent bytes" }, { - "name" => "compute.googleapis.com/instance/network/sent_packets_count", - "project" => @project, + "type" => "compute.googleapis.com/instance/network/sent_packets_count", + "name" => "projects/#{@project}/metricDescriptors/compute.googleapis.com/instance/network/sent_packets_count", "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" } + { + "key" => "instance_name", + "description" => "The name of the VM instance." + }, + { + "key" => "loadbalanced", + "valueType" => "BOOL", + "description" => "Whether traffic was sent from an L3 loadbalanced IP address assigned to the VM. Traffic that is externally routed from the VM's standard internal or external IP address, such as L7 loadbalanced traffic, is not considered to be loadbalanced in this metric." + } ], - "typeDescriptor" => { "metricType" => "delta", "valueType" => "int64" }, - "description" => "Delta count of packets sent over network." + "metricKind" => "DELTA", + "valueType" => "INT64", + "unit" => "1", + "description" => "Delta count of packets sent over the network.", + "displayName" => "Sent packets" }, { - "name" => "compute.googleapis.com/instance/uptime", - "project" => @project, + "type" => "compute.googleapis.com/instance/uptime", + "name" => "projects/#{@project}/metricDescriptors/compute.googleapis.com/instance/uptime", "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" } + { + "key" => "instance_name", + "description" => "The name of the VM instance." + } ], - "typeDescriptor" => { "metricType" => "delta", "valueType" => "double" }, - "description" => "Indicates the VM running time in seconds." + "metricKind" => "DELTA", + "valueType" => "DOUBLE", + "unit" => "s", + "description" => "How long the VM has been running, in seconds.", + "displayName" => "Uptime" } ] } diff --git a/tests/models/monitoring/metric_descriptors_tests.rb b/tests/models/monitoring/metric_descriptors_tests.rb deleted file mode 100644 index 8c1fd6a3de..0000000000 --- a/tests/models/monitoring/metric_descriptors_tests.rb +++ /dev/null @@ -1,9 +0,0 @@ -Shindo.tests("Fog::Google[:monitoring] | metric_descriptors model", ["google"]) do - @metric_descriptors = Fog::Google[:monitoring].metric_descriptors - - tests("success") do - tests('#all').succeeds do - @metric_descriptors.all - end - end -end From 158d755d652738cf1cb1fc3b39e1c2d8cebc849b Mon Sep 17 00:00:00 2001 From: Emily Ye Date: Mon, 25 Sep 2017 22:49:57 +0000 Subject: [PATCH 4/8] migrate timeseries to v3 monitoring --- examples/monitoring/timeseries_collection.rb | 21 +++-- .../google/models/monitoring/timeseries.rb | 8 +- .../monitoring/timeseries_collection.rb | 31 ++++--- .../requests/monitoring/list_timeseries.rb | 81 ++++++++++++------- .../monitoring/timeseries_collection_tests.rb | 9 --- 5 files changed, 87 insertions(+), 63 deletions(-) delete mode 100644 tests/models/monitoring/timeseries_collection_tests.rb diff --git a/examples/monitoring/timeseries_collection.rb b/examples/monitoring/timeseries_collection.rb index 9dc1a04f32..74287cd666 100644 --- a/examples/monitoring/timeseries_collection.rb +++ b/examples/monitoring/timeseries_collection.rb @@ -8,19 +8,24 @@ def test connection = Fog::Google::Monitoring.new - - puts "Listing all Timeseries for the metric compute.googleapis.com/instance/uptime..." + interval = { + :start_time => (DateTime.now - 1).rfc3339, + :end_time => DateTime.now.rfc3339 + } + puts "Listing Timeseries from the last hour for metric compute.googleapis.com/instance/uptime..." puts "-------------------------------------------------------------------------------" - tc = connection.timeseries_collection.all("compute.googleapis.com/instance/uptime", - DateTime.now.rfc3339) + tc = connection.timeseries_collection.all(:filter => 'metric.type = "compute.googleapis.com/instance/uptime"', + :interval => interval) puts "Number of matches: #{tc.length}" - puts "\nListing all Timeseries for the metric compute.googleapis.com/instance/uptime &" + puts "\nListing all Timeseries for metric compute.googleapis.com/instance/uptime &" puts "the region us-central1..." puts "------------------------------------------------------------------------------" - tc = connection.timeseries_collection.all("compute.googleapis.com/instance/uptime", - DateTime.now.rfc3339, - :labels => "cloud.googleapis.com/location=~us-central1.*") + filter = [ + 'metric.type = "compute.googleapis.com/instance/uptime"', + 'resource.label.zone = "us-central1-c"' + ].join(" AND ") + tc = connection.timeseries_collection.all(:filter => filter, :interval => interval) puts "Number of matches: #{tc.length}" end diff --git a/lib/fog/google/models/monitoring/timeseries.rb b/lib/fog/google/models/monitoring/timeseries.rb index c371c7c7cb..305c604e0d 100644 --- a/lib/fog/google/models/monitoring/timeseries.rb +++ b/lib/fog/google/models/monitoring/timeseries.rb @@ -6,10 +6,12 @@ class Monitoring ## # A time series is a collection of data points that represents the value of a metric of a project over time. # - # @see https://developers.google.com/cloud-monitoring/v2beta1/timeseries + # https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.timeSeries/list class Timeseries < Fog::Model - identity :time_series_desc, :aliases => "timeseriesDesc" - + attribute :metric + attribute :resource + attribute :metric_kind, :aliases => "metricKind" + attribute :value_type, :aliases => "valueType" attribute :points end end diff --git a/lib/fog/google/models/monitoring/timeseries_collection.rb b/lib/fog/google/models/monitoring/timeseries_collection.rb index 2f12506593..12cb572331 100644 --- a/lib/fog/google/models/monitoring/timeseries_collection.rb +++ b/lib/fog/google/models/monitoring/timeseries_collection.rb @@ -10,19 +10,26 @@ class TimeseriesCollection < Fog::Collection ## # Lists all Timeseries. # - # @param [String] metric The name of the metric (Metric names are protocol-free URLs). - # @param [String] youngest End of the time interval (inclusive), which is expressed as an RFC 3339 timestamp. - # @param [Hash] options Optional query parameters. - # @option options [String] count Maximum number of time series descriptors per page. Used for pagination. - # @option options [String] labels A collection of labels for the matching time series. - # @option options [String] oldest Start of the time interval (exclusive), which is expressed as an RFC 3339 - # timestamp. - # @options options [String] page_token The pagination token, which is used to page through large result sets. - # @options options [String] timespan Length of the time interval to query, which is an alternative way to - # declare the interval. + # @param [Hash] options Query parameters. + # @option [String] filter A monitoring filter that specifies which time series should be returned. + # The filter must specify a single metric type, and can additionally specify metric labels and other + # information. + # @option options [Hash] interval Required. The time interval for which results should be returned. + # @option interval [String] end_time Required RFC3339 timestamp marking the end of interval + # @option interval [String] start_time Optional RFC3339 timestamp marking start of interval. + # @option options [Hash] aggregation + # @option aggregation [String] alignment_period + # @option aggregation [String] cross_series_reducer + # @option aggregation [String] group_by_fields + # @option aggregation [String] per_series_aligner + # @option options [String] order_by + # @option options [String] page_size + # @option options [String] page_token + # @option options [String] view + # # @return [Array] List of Timeseries. - def all(metric, youngest, options = {}) - data = service.list_timeseries(metric, youngest, options).body["timeseries"] || [] + def all(options = {}) + data = service.list_timeseries(options).body["timeSeries"] || [] load(data) end end diff --git a/lib/fog/google/requests/monitoring/list_timeseries.rb b/lib/fog/google/requests/monitoring/list_timeseries.rb index 93a0767507..9a84fe6ac7 100644 --- a/lib/fog/google/requests/monitoring/list_timeseries.rb +++ b/lib/fog/google/requests/monitoring/list_timeseries.rb @@ -5,55 +5,74 @@ class Monitoring # List the data points of the time series that match the metric and labels values and that have data points # in the interval # - # https://developers.google.com/cloud-monitoring/v2beta1/timeseries + # @see https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.timeSeries/list class Real - def list_timeseries(metric, youngest, options = {}) - api_method = @monitoring.timeseries.list + def list_timeseries(options = {}) + api_method = @monitoring.projects.time_series.list parameters = { - "project" => @project, - "metric" => metric, - "youngest" => youngest + "name" => "projects/#{@project}" } + if options.key?(:interval) + interval = options[:interval] + parameters["interval.endTime"] = interval[:end_time] if interval.key?(:end_time) + parameters["interval.startTime"] = interval[:start_time] if interval.key?(:start_time) + end - parameters["count"] = options[:count] if options.key?(:count) - parameters["labels"] = options[:labels] if options.key?(:labels) - parameters["oldest"] = options[:oldest] if options.key?(:oldest) + if options.key?(:aggregation) + aggregation = options[:aggregation] + parameters["aggregation.alignmentPeriod"] = aggregation[:alignment_period] if aggregation.key?(:alignment_period) + parameters["aggregation.crossSeriesReducer"] = aggregation[:cross_series_reducer] if aggregation.key?(:cross_series_reducer) + parameters["aggregation.groupByFields"] = aggregation[:group_by_fields] if aggregation.key?(:group_by_fields) + parameters["aggregation.perSeriesAligner"] = aggregation[:per_series_aligner] if aggregation.key?(:per_series_aligner) + end + + parameters["filter"] = options[:filter] if options.key?(:filter) + parameters["orderBy"] = options[:order_by] if options.key?(:order_by) + parameters["pageSize"] = options[:page_size] if options.key?(:page_size) parameters["pageToken"] = options[:page_token] if options.key?(:page_token) - parameters["timespan"] = options[:timespan] if options.key?(:timespan) + parameters["view"] = options[:view] if options.key?(:view) + + unless parameters.key?("interval.startTime") + raise ArgumentError.new("option :interval must have :start_time value for listing timeseries") + end + + unless parameters.key?("interval.endTime") + raise ArgumentError.new("option :interval must have :end_time value for listing timeseries") + end + + unless parameters.key?("filter") + raise ArgumentError.new("options[:filter] value is required to list timeseries") + end request(api_method, parameters) end end class Mock - def list_timeseries(metric, youngest, _options = {}) + def list_timeseries(interval, _options = {}) body = { - "kind" => 'cloudmonitoring#listTimeseriesResponse', - "youngest" => youngest, - "oldest" => youngest, - "timeseries" => [ + "timeSeries" => [ { - "timeseriesDesc" => { - "project" => @project, - "metric" => metric, + "metric" => { + "labels" => { "instance_name" => "emilyye-dev" }, + "type" => "compute.googleapis.com/instance/cpu/usage_time" + }, + "resource" => { + "type" => "gce_instance", "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) + "instance_id" => "3959348537894302241", + "zone" => "us-central1-c", + "project_id" => @project } }, + "metricKind" => "DELTA", + "valueType" => "DOUBLE", "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 + "interval" => interval, + "value" => { + "doubleValue" => 1.8277230720141233 + } } ] } diff --git a/tests/models/monitoring/timeseries_collection_tests.rb b/tests/models/monitoring/timeseries_collection_tests.rb deleted file mode 100644 index 3a765ff652..0000000000 --- a/tests/models/monitoring/timeseries_collection_tests.rb +++ /dev/null @@ -1,9 +0,0 @@ -Shindo.tests("Fog::Google[:monitoring] | timeseries_collection model", ["google"]) do - @timeseries_collection = Fog::Google[:monitoring].timeseries_collection - - tests("success") do - tests('#all').succeeds do - @timeseries_collection.all("compute.googleapis.com/instance/uptime", Time.now.strftime("%Y-%m-%dT%H:%M:%S%:z")) - end - end -end From dde463e0bd92a5b974b21074f0a55be89859af27 Mon Sep 17 00:00:00 2001 From: Emily Ye Date: Mon, 25 Sep 2017 22:55:25 +0000 Subject: [PATCH 5/8] add monitored resource descriptors --- .../monitored_resource_descriptors.rb | 24 +++++++ .../monitored_resource_descriptor.rb | 20 ++++++ .../monitored_resource_descriptors.rb | 26 ++++++++ lib/fog/google/monitoring.rb | 7 +++ .../list_monitored_resource_descriptors.rb | 63 +++++++++++++++++++ 5 files changed, 140 insertions(+) create mode 100644 examples/monitoring/monitored_resource_descriptors.rb create mode 100644 lib/fog/google/models/monitoring/monitored_resource_descriptor.rb create mode 100644 lib/fog/google/models/monitoring/monitored_resource_descriptors.rb create mode 100644 lib/fog/google/requests/monitoring/list_monitored_resource_descriptors.rb diff --git a/examples/monitoring/monitored_resource_descriptors.rb b/examples/monitoring/monitored_resource_descriptors.rb new file mode 100644 index 0000000000..7251ed0ba8 --- /dev/null +++ b/examples/monitoring/monitored_resource_descriptors.rb @@ -0,0 +1,24 @@ +# All examples presume that you have a ~/.fog credentials file set up. +# # More info on it can be found here: http://fog.io/about/getting_started.html +# +require "bundler" +Bundler.require(:default, :development) +# Uncomment this if you want to make real requests to GCE (you _will_ be billed!) +# WebMock.disable! +# + +def test + connection = Fog::Google::Monitoring.new + + puts "Listing all MonitoredResourceDescriptors..." + puts "--------------------------------" + md = connection.monitored_resource_descriptors + puts "Number of all monitored resource descriptors: #{md.length}" + + puts "\nListing MonitoredResourceDescriptors related to Google Compute Engine..." + puts "-----------------------------------------------------------------" + md = connection.monitored_resource_descriptors.all(:filter => 'resource.type = starts_with("gce_")') + puts "Number of compute monitored resource : #{md.length}" +end + +test diff --git a/lib/fog/google/models/monitoring/monitored_resource_descriptor.rb b/lib/fog/google/models/monitoring/monitored_resource_descriptor.rb new file mode 100644 index 0000000000..42afa8b91f --- /dev/null +++ b/lib/fog/google/models/monitoring/monitored_resource_descriptor.rb @@ -0,0 +1,20 @@ +require "fog/core/model" + +module Fog + module Google + class Monitoring + ## + # A monitoredResourceDescriptor defines a metric type and its schema. + # + # @see https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.monitoredResourceDescriptors#MonitoredResourceDescriptor + class MonitoredResourceDescriptor < Fog::Model + identity :name + + attribute :description + attribute :display_name, :aliases => "displayName" + attribute :type + attribute :labels + end + end + end +end diff --git a/lib/fog/google/models/monitoring/monitored_resource_descriptors.rb b/lib/fog/google/models/monitoring/monitored_resource_descriptors.rb new file mode 100644 index 0000000000..78946b32fe --- /dev/null +++ b/lib/fog/google/models/monitoring/monitored_resource_descriptors.rb @@ -0,0 +1,26 @@ +require "fog/core/collection" +require "fog/google/models/monitoring/monitored_resource_descriptor" + +module Fog + module Google + class Monitoring + class MonitoredResourceDescriptors < Fog::Collection + model Fog::Google::Monitoring::MonitoredResourceDescriptor + + ## + # Lists all Monitored Resource Descriptors. + # + # @param [Hash] options Optional query parameters. + # @option options [String] page_size Maximum number of metric descriptors per page. Used for pagination. + # @option options [String] page_token The pagination token, which is used to page through large result sets. + # @option options [String] filter The monitoring filter used to search against existing descriptors. + # See + # @return [Array] List of Monitored Resource Descriptors. + def all(options = {}) + data = service.list_monitored_resource_descriptors(options).body["resourceDescriptors"] || [] + load(data) + end + end + end + end +end diff --git a/lib/fog/google/monitoring.rb b/lib/fog/google/monitoring.rb index 00347979e8..415fa269cc 100644 --- a/lib/fog/google/monitoring.rb +++ b/lib/fog/google/monitoring.rb @@ -33,6 +33,10 @@ class Monitoring < Fog::Service model :metric_descriptor collection :metric_descriptors + # MonitoredResourceDescriptors + model :monitored_resource_descriptor + collection :monitored_resource_descriptors + ## # REQUESTS request_path "fog/google/requests/monitoring" @@ -42,6 +46,9 @@ class Monitoring < Fog::Service # MetricDescriptors request :list_metric_descriptors + + # MonitoredResourceDescriptors + request :list_monitored_resource_descriptors end end end diff --git a/lib/fog/google/requests/monitoring/list_monitored_resource_descriptors.rb b/lib/fog/google/requests/monitoring/list_monitored_resource_descriptors.rb new file mode 100644 index 0000000000..405d3b0ef2 --- /dev/null +++ b/lib/fog/google/requests/monitoring/list_monitored_resource_descriptors.rb @@ -0,0 +1,63 @@ +module Fog + module Google + class Monitoring + ## + # Describes the schema of a MonitoredResource (a resource object that can be used for monitoring, logging, + # billing, or other purposes) using a type name and a set of labels. + # + # @see https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.monitoredResourceDescriptors/list + class Real + def list_monitored_resource_descriptors(options = {}) + api_method = @monitoring.projects.monitored_resource_descriptors.list + parameters = { + "name" => "projects/#{@project}" + } + + parameters["filter"] = options[:filter] if options.key?(:filter) + parameters["pageSize"] = options[:page_size] if options.key?(:page_size) + parameters["pageToken"] = options[:page_token] if options.key?(:page_token) + + request(api_method, parameters) + end + end + + class Mock + def list_monitored_resource_descriptors(_options = {}) + body = { + "resourceDescriptors" => [ + { + "type" => "api", + "displayName" => "Produced API", + "description" => "An API provided by the producer.", + "labels" => [ + { + "key" => "project_id", + "description" => "The identifier of the GCP project associated with this resource (e.g., my-project)." + }, + { + "key" => "service", + "description" => "API service name e.g. \"cloudsql.googleapis.com\"." + }, + { + "key" => "method", + "description" => "API method e.g. \"disks.list\"." + }, + { + "key" => "version", + "description" => "API version e.g. \"v1\"." + }, + { + "key" => "location", + "description" => "The service specific notion of location. This can be a name of a zone, region, or \"global." + } + ], + "name" => "projects/#{@project}/monitoredResourceDescriptors/api" + } + ] + } + build_excon_response(body) + end + end + end + end +end From 642d0776db3d71e6885afd597a2449e9784e79f7 Mon Sep 17 00:00:00 2001 From: Emily Ye Date: Mon, 25 Sep 2017 22:58:58 +0000 Subject: [PATCH 6/8] remove shindo tests for monitoring --- .../monitoring/metric_descriptor_tests.rb | 22 ------------------- .../monitoring/timeseries_collection_tests.rb | 22 ------------------- 2 files changed, 44 deletions(-) delete mode 100644 tests/requests/monitoring/metric_descriptor_tests.rb delete mode 100644 tests/requests/monitoring/timeseries_collection_tests.rb diff --git a/tests/requests/monitoring/metric_descriptor_tests.rb b/tests/requests/monitoring/metric_descriptor_tests.rb deleted file mode 100644 index ac7b9a0654..0000000000 --- a/tests/requests/monitoring/metric_descriptor_tests.rb +++ /dev/null @@ -1,22 +0,0 @@ -Shindo.tests("Fog::Google[:monitoring] | metric_descriptor requests", ["google"]) do - @monitoring = Fog::Google[:monitoring] - - @get_metric_descriptor_format = { - "name" => String, - "description" => String, - "labels" => Array, - "project" => String, - "typeDescriptor" => Hash - } - - @list_metric_descriptors_format = { - "kind" => String, - "metrics" => [@get_metric_descriptor_format] - } - - tests("success") do - tests('#list_metric_descriptors').formats(@list_metric_descriptors_format) do - @monitoring.list_metric_descriptors.body - end - end -end diff --git a/tests/requests/monitoring/timeseries_collection_tests.rb b/tests/requests/monitoring/timeseries_collection_tests.rb deleted file mode 100644 index e160a7329f..0000000000 --- a/tests/requests/monitoring/timeseries_collection_tests.rb +++ /dev/null @@ -1,22 +0,0 @@ -Shindo.tests("Fog::Google[:monitoring] | timeseries_collection requests", ["google"]) do - @monitoring = Fog::Google[:monitoring] - - @get_timeseries_format = { - "timeseriesDesc" => Hash, - "points" => Array - } - - @list_timeseries_format = { - "kind" => String, - "youngest" => String, - "oldest" => String, - "timeseries" => [@get_timeseries_format] - } - - tests("success") do - tests('#list_timeseries').formats(@list_timeseries_format) do - @monitoring.list_timeseries("compute.googleapis.com/instance/uptime", - Time.now.strftime("%Y-%m-%dT%H:%M:%S%:z")).body - end - end -end From 89b99c43bd9c1aae3c7d2ff5c9cf9c76777b641e Mon Sep 17 00:00:00 2001 From: Emily Ye Date: Tue, 26 Sep 2017 17:45:57 +0000 Subject: [PATCH 7/8] update readme for monitoring v3 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4df10d362d..659d84a0d7 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ Fog implements [v1](https://cloud.google.com/dns/api/v1/) of the Google Cloud DN ## Monitoring -Fog implements [v2beta2](https://cloud.google.com/monitoring/v2beta2/) of the Google Cloud Monitoring API. As of 2016-03-15, we believe Fog for Google Cloud Monitoring is feature complete. We are always looking for people to improve our code and test coverage, so please [file issues](https://github.com/fog/fog-google/issues) for any anomalies you see or features you would like. +Fog implements [v3](https://cloud.google.com/monitoring/api/ref_v3/rest/) of the Google Cloud Monitoring API. We are always looking for people to improve our code and test coverage, so please [file issues](https://github.com/fog/fog-google/issues) for any anomalies you see or features you would like. ## Pubsub From 3df4758524590cf12fc6dfcebe159e54764a7dc6 Mon Sep 17 00:00:00 2001 From: Emily Ye Date: Tue, 26 Sep 2017 18:28:46 +0000 Subject: [PATCH 8/8] add date statement to README for monitoring v3 --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 659d84a0d7..8211d0cced 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,12 @@ Fog implements [v1](https://cloud.google.com/dns/api/v1/) of the Google Cloud DN ## Monitoring -Fog implements [v3](https://cloud.google.com/monitoring/api/ref_v3/rest/) of the Google Cloud Monitoring API. We are always looking for people to improve our code and test coverage, so please [file issues](https://github.com/fog/fog-google/issues) for any anomalies you see or features you would like. +Fog mostly implements [v3](https://cloud.google.com/monitoring/api/ref_v3/rest/) of the Google Cloud Monitoring API. + +As of 2017-09-26, some less common API methods are missing and may be added as requested. Feature requests or pull requests for +additions are welcome. + +We are always looking for people to improve our code and test coverage, so please [file issues](https://github.com/fog/fog-google/issues) for any anomalies you see or features you would like. ## Pubsub