Class: Fog::Google::Monitoring::Real
- Inherits:
-
Object
- Object
- Fog::Google::Monitoring::Real
- Includes:
- Shared
- Defined in:
- lib/fog/google/requests/monitoring/list_timeseries.rb,
lib/fog/google/monitoring/real.rb,
lib/fog/google/requests/monitoring/create_timeseries.rb,
lib/fog/google/requests/monitoring/get_metric_descriptor.rb,
lib/fog/google/requests/monitoring/list_metric_descriptors.rb,
lib/fog/google/requests/monitoring/create_metric_descriptor.rb,
lib/fog/google/requests/monitoring/delete_metric_descriptor.rb,
lib/fog/google/requests/monitoring/get_monitored_resource_descriptor.rb,
lib/fog/google/requests/monitoring/list_monitored_resource_descriptors.rb
Overview
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.
Instance Attribute Summary collapse
-
#monitoring ⇒ Object
readonly
Returns the value of attribute monitoring.
Attributes included from Shared
#api_url, #api_version, #project
Instance Method Summary collapse
-
#create_metric_descriptor(metric_type: nil, unit: nil, value_type: nil, description: nil, display_name: nil, labels: [], metric_kind: nil) ⇒ ::Google::Apis::MonitoringV3::MetricDescriptor
Create a metric descriptor.
-
#create_timeseries(timeseries: []) ⇒ Object
Create a timeseries.
- #delete_metric_descriptor(metric_type) ⇒ Object
- #get_metric_descriptor(metric_type) ⇒ Object
- #get_monitored_resource_descriptor(resource_type) ⇒ Object
-
#initialize(options) ⇒ Real
constructor
A new instance of Real.
- #list_metric_descriptors(filter: nil, page_size: nil, page_token: nil) ⇒ Object
- #list_monitored_resource_descriptors(filter: nil, page_size: nil, page_token: nil) ⇒ Object
- #list_timeseries(filter: nil, interval: nil, aggregation: nil, order_by: nil, page_size: nil, page_token: nil, view: nil) ⇒ Object
Methods included from Shared
#apply_client_options, #build_excon_response, #initialize_google_client, #request, #shared_initialize
Constructor Details
#initialize(options) ⇒ Real
Returns a new instance of Real.
9 10 11 12 13 14 15 16 |
# File 'lib/fog/google/monitoring/real.rb', line 9 def initialize() shared_initialize([:google_project], GOOGLE_MONITORING_API_VERSION, GOOGLE_MONITORING_BASE_URL) [:google_api_scope_url] = GOOGLE_MONITORING_API_SCOPE_URLS.join(" ") initialize_google_client() @monitoring = ::Google::Apis::MonitoringV3::MonitoringService.new (@monitoring, ) end |
Instance Attribute Details
#monitoring ⇒ Object (readonly)
Returns the value of attribute monitoring.
7 8 9 |
# File 'lib/fog/google/monitoring/real.rb', line 7 def monitoring @monitoring end |
Instance Method Details
#create_metric_descriptor(metric_type: nil, unit: nil, value_type: nil, description: nil, display_name: nil, labels: [], metric_kind: nil) ⇒ ::Google::Apis::MonitoringV3::MetricDescriptor
Create a metric descriptor. User-created metric descriptors define custom metrics.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/fog/google/requests/monitoring/create_metric_descriptor.rb', line 25 def create_metric_descriptor(metric_type: nil, unit: nil, value_type: nil, description: nil, display_name: nil, labels: [], metric_kind: nil) metric_descriptor = ::Google::Apis::MonitoringV3::MetricDescriptor.new( :name => "projects/#{@project}/metricDescriptors/#{metric_type}", :type => metric_type, :unit => unit, :value_type => value_type, :description => description, :display_name => display_name, :labels => labels.map { |l| ::Google::Apis::MonitoringV3::LabelDescriptor.new(l) }, :metric_kind => metric_kind ) @monitoring.create_project_metric_descriptor("projects/#{@project}", metric_descriptor) end |
#create_timeseries(timeseries: []) ⇒ Object
Create a timeseries. User-created time series should only be used with custom metrics.
12 13 14 15 16 17 |
# File 'lib/fog/google/requests/monitoring/create_timeseries.rb', line 12 def create_timeseries(timeseries: []) request = ::Google::Apis::MonitoringV3::CreateTimeSeriesRequest.new( :time_series => timeseries ) @monitoring.create_project_time_series("projects/#{@project}", request) end |
#delete_metric_descriptor(metric_type) ⇒ Object
5 6 7 |
# File 'lib/fog/google/requests/monitoring/delete_metric_descriptor.rb', line 5 def delete_metric_descriptor(metric_type) @monitoring.delete_project_metric_descriptor("projects/#{@project}/metricDescriptors/#{metric_type}") end |
#get_metric_descriptor(metric_type) ⇒ Object
5 6 7 |
# File 'lib/fog/google/requests/monitoring/get_metric_descriptor.rb', line 5 def get_metric_descriptor(metric_type) @monitoring.get_project_metric_descriptor("projects/#{@project}/metricDescriptors/#{metric_type}") end |
#get_monitored_resource_descriptor(resource_type) ⇒ Object
5 6 7 8 9 |
# File 'lib/fog/google/requests/monitoring/get_monitored_resource_descriptor.rb', line 5 def get_monitored_resource_descriptor(resource_type) @monitoring.get_project_monitored_resource_descriptor( "projects/#{@project}/monitoredResourceDescriptors/#{resource_type}" ) end |
#list_metric_descriptors(filter: nil, page_size: nil, page_token: nil) ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'lib/fog/google/requests/monitoring/list_metric_descriptors.rb', line 9 def list_metric_descriptors(filter: nil, page_size: nil, page_token: nil) @monitoring.list_project_metric_descriptors( "projects/#{@project}", :filter => filter, :page_size => page_size, :page_token => page_token ) end |
#list_monitored_resource_descriptors(filter: nil, page_size: nil, page_token: nil) ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/fog/google/requests/monitoring/list_monitored_resource_descriptors.rb', line 10 def list_monitored_resource_descriptors(filter: nil, page_size: nil, page_token: nil) @monitoring.list_project_monitored_resource_descriptors( "projects/#{@project}", :filter => filter, :page_size => page_size, :page_token => page_token ) end |
#list_timeseries(filter: nil, interval: nil, aggregation: nil, order_by: nil, page_size: nil, page_token: nil, view: nil) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/fog/google/requests/monitoring/list_timeseries.rb', line 10 def list_timeseries(filter: nil, interval: nil, aggregation: nil, order_by: nil, page_size: nil, page_token: nil, view: nil) if filter.nil? raise ArgumentError.new("filter is required") end if interval.nil? raise ArgumentError.new("interval is required") end = { :filter => filter, :interval_end_time => interval[:end_time], :interval_start_time => interval[:start_time], :order_by => order_by, :page_size => page_size, :page_token => page_token, :view => view } if .key?(:interval) interval = [:interval] parameters["interval.endTime"] = interval[:end_time] if interval.key?(:end_time) parameters["interval.startTime"] = interval[:start_time] if interval.key?(:start_time) end unless aggregation.nil? %i(alignment_period cross_series_reducer group_by_fields per_series_aligner).each do |k| if aggregation.key?(k) ["aggregation_#{k}".to_sym] = aggregation[k] end end end @monitoring.list_project_time_series("projects/#{@project}", ) end |