class AwsInstanceList::Metric
Attributes
client[RW]
Public Class Methods
new(region: 'eu-west-1')
click to toggle source
# File lib/aws_instance_list/metric.rb, line 9 def initialize region: 'eu-west-1' @client=Aws::CloudWatch::Client.new region: region end
Public Instance Methods
bytes_used_for_cache(cache_cluster_id)
click to toggle source
# File lib/aws_instance_list/metric.rb, line 45 def bytes_used_for_cache cache_cluster_id resp=statistics( { namespace: "AWS/ElastiCache", metric_name: "BytesUsedForCache", dimensions: [ { name: "CacheClusterId", value: cache_cluster_id, }, ], start_time: Time.now - 600, end_time: Time.now , period: 60, statistics: ["Maximum"] }) resp.datapoints.last.maximum end
cluster_used_space(dimensions)
click to toggle source
# File lib/aws_instance_list/metric.rb, line 104 def cluster_used_space dimensions resp=statistics( { namespace: "AWS/ES", metric_name: "ClusterUsedSpace", dimensions: dimensions, start_time: Time.now - 600, end_time: Time.now , period: 60, statistics: ["Maximum"] }) if resp.datapoints.empty? '-' else resp.datapoints.last.maximum end end
es_free_storage_space(dimensions)
click to toggle source
# File lib/aws_instance_list/metric.rb, line 86 def es_free_storage_space dimensions resp=statistics( { namespace: "AWS/ES", metric_name: "FreeStorageSpace", dimensions: dimensions, start_time: Time.now - 600, end_time: Time.now , period: 60, statistics: ["Minimum"] }) if resp.datapoints.empty? '-' else resp.datapoints.last.minimum end end
free_storage_space(db_instance_identifier)
click to toggle source
# File lib/aws_instance_list/metric.rb, line 21 def free_storage_space db_instance_identifier resp=statistics( { namespace: "AWS/RDS", metric_name: "FreeStorageSpace", dimensions: [ { name: "DBInstanceIdentifier", value: db_instance_identifier, }, ], start_time: Time.now - 600, end_time: Time.now , period: 60, statistics: ["Minimum"] }) if resp.datapoints.empty? '-' else resp.datapoints.last.minimum / ( 1024.0 ** 3) end end
freeable_memory(cache_cluster_id)
click to toggle source
# File lib/aws_instance_list/metric.rb, line 66 def freeable_memory cache_cluster_id resp=statistics( { namespace: "AWS/ElastiCache", metric_name: "FreeableMemory", dimensions: [ { name: "CacheClusterId", value: cache_cluster_id, }, ], start_time: Time.now - 600, end_time: Time.now , period: 60, statistics: ["Maximum"] }) resp.datapoints.last.maximum end
list(options)
click to toggle source
# File lib/aws_instance_list/metric.rb, line 17 def list options client.list_metrics options end
statistics(options)
click to toggle source
# File lib/aws_instance_list/metric.rb, line 13 def statistics options client.get_metric_statistics options end