Class: ClearSkies::AWS::CloudWatch::ElasticBeanstalkGauge
- Inherits:
-
Gauge
- Object
- GreekFire::Gauge
- Gauge
- ClearSkies::AWS::CloudWatch::ElasticBeanstalkGauge
show all
- Defined in:
- lib/clear_skies/aws/cloud_watch/elastic_beanstalk_gauge.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Gauge
#aws_metrics, cloudwatch_client, #metrics, register
Constructor Details
#initialize(metric_name, dimension, statistics, description: nil, &block) ⇒ ElasticBeanstalkGauge
Returns a new instance of ElasticBeanstalkGauge.
8
9
10
|
# File 'lib/clear_skies/aws/cloud_watch/elastic_beanstalk_gauge.rb', line 8
def initialize(metric_name, dimension, statistics, description: nil, &block)
super("AWS/ElasticBeanstalk", metric_name, dimension, statistics, description: description, &block)
end
|
Class Method Details
.beanstalk_client ⇒ Object
5
6
7
|
# File 'lib/clear_skies/aws/cloud_watch/elastic_beanstalk_gauge.rb', line 5
def self.beanstalk_client
@beanstalk_client ||= ::Aws::ElasticBeanstalk::Client.new
end
|
Instance Method Details
#application_name(environment_name) ⇒ Object
12
13
14
|
# File 'lib/clear_skies/aws/cloud_watch/elastic_beanstalk_gauge.rb', line 12
def application_name(environment_name)
ElasticBeanstalkGauge.beanstalk_client.describe_environments({environment_names: [environment_name] }).environments.first&.application_name
end
|
#labels_from_metric(metric) ⇒ Object
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/clear_skies/aws/cloud_watch/elastic_beanstalk_gauge.rb', line 24
def labels_from_metric(metric)
labels = super(metric)
if labels.has_key?( "environment_name") && !(Rails.cache.fetch("#{labels["environment_name"]}_skip"))
application_name = Rails.cache.fetch("#{labels["environment_name"]}_application_name", expires_in: 1.hour) do
application_name(labels["environment_name"])
end
if application_name
labels["application_name"] = application_name
labels["vpc_id"] = Rails.cache.fetch("#{labels["environment_name"]}_vpc_id_") do
vpc_id(labels["application_name"], labels["environment_name"])
end
end
else
Rails.cache.write("#{labels["environment_name"]}_skip", true, expires_in: 1.hour, race_condition_ttl: 60.seconds)
end
return labels
end
|
#vpc_id(application_name, environment_name) ⇒ Object
16
17
18
19
20
21
|
# File 'lib/clear_skies/aws/cloud_watch/elastic_beanstalk_gauge.rb', line 16
def vpc_id(application_name, environment_name)
config = ElasticBeanstalkGauge.beanstalk_client.describe_configuration_settings({ application_name: application_name, environment_name: environment_name }).
configuration_settings.find { |config| config.application_name == application_name && config.environment_name == environment_name}
option = config.option_settings.find { |option| option.namespace == "aws:ec2:vpc" && option.option_name == "VPCId"}
option.value if option
end
|