Skip to content
This repository has been archived by the owner on Nov 12, 2019. It is now read-only.

Commit

Permalink
Merge pull request #67 from msummers-nr/master
Browse files Browse the repository at this point in the history
Add Application Load Balancer collector
  • Loading branch information
chaupt authored Oct 19, 2016
2 parents baa358f + 0619990 commit eff4331
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
## New Relic Amazon CloudWatch Plugin ##

### v3.3.5 - October 19, 2016 ###

**Changes**

* Support new namespace: AWS/ApplicationELB

### v3.3.4 - July 21, 2016 ###

**Changes**
Expand Down
9 changes: 9 additions & 0 deletions lib/newrelic_aws.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,14 @@ class Agent < Base::Agent
end
end

module ALB
class Agent < Base::Agent
agent_guid "com.newrelic.aws.alb"
agent_version NewRelicAWS::VERSION
agent_human_labels("ALB") { "ALB" }
end
end

module ELB
class Agent < Base::Agent
agent_guid "com.newrelic.aws.elb"
Expand Down Expand Up @@ -205,6 +213,7 @@ class Agent < Base::Agent
NewRelic::Plugin::Setup.install_agent :ec2, EC2 if NewRelicAWS::agent_enabled?(:ec2)
NewRelic::Plugin::Setup.install_agent :ebs, EBS if NewRelicAWS::agent_enabled?(:ebs)
NewRelic::Plugin::Setup.install_agent :elb, ELB if NewRelicAWS::agent_enabled?(:elb)
NewRelic::Plugin::Setup.install_agent :alb, ALB if NewRelicAWS::agent_enabled?(:alb)
NewRelic::Plugin::Setup.install_agent :rds, RDS if NewRelicAWS::agent_enabled?(:rds)
# NewRelic::Plugin::Setup.install_agent :ddb, DDB # WIP
NewRelic::Plugin::Setup.install_agent :sqs, SQS if NewRelicAWS::agent_enabled?(:sqs)
Expand Down
1 change: 1 addition & 0 deletions lib/newrelic_aws/collectors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
require "newrelic_aws/collectors/base"
require "newrelic_aws/collectors/ec2"
require "newrelic_aws/collectors/ebs"
require "newrelic_aws/collectors/alb"
require "newrelic_aws/collectors/elb"
require "newrelic_aws/collectors/rds"
require "newrelic_aws/collectors/ddb"
Expand Down
61 changes: 61 additions & 0 deletions lib/newrelic_aws/collectors/alb.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
module NewRelicAWS
module Collectors
class ALB < Base
def load_balancers
alb = AWS::ELB.new(
:access_key_id => @aws_access_key,
:secret_access_key => @aws_secret_key,
:region => @aws_region
)
alb.load_balancers.map { |load_balancer| load_balancer.name }
end

def metric_list
[
["ActiveConnectionCount", "Average", "Count", 0],
["ClientTLSNegotiationErrorCount", "Sum", "Count", 0],
["ConsumedLBCapacityUnits", "Sum", "Count", 0],
["HealthyHostCount", "Maximum", "Count", 0],
["HTTPCode_ELB_4XX", "Sum", "Count", 0],
["HTTPCode_ELB_5XX", "Sum", "Count", 0],
["HTTPCode_Target_2XX_Count", "Sum", "Count", 0],
["HTTPCode_Target_3XX_Count", "Sum", "Count", 0],
["HTTPCode_Target_4XX_Count", "Sum", "Count", 0],
["HTTPCode_Target_5XX_Count", "Sum", "Count", 0],
["NewConnectionCount", "Sum", "Count", 0],
["ProcessedBytes", "Average", "Bytes", 0],
["RequestCount", "Sum", "Count", 0],
["RejectedConnectionCount", "Sum", "Count", 0],
["TargetConnectionErrorCount", "Sum", "Count", 0],
["TargetResponseTime", "Average", "Milliseconds", 0],
["TargetTLSNegotiationErrorCount", "Sum", "Count", 0],
["UnHealthyHostCount", "Maximum", "Count", 0],
]
end

def collect
data_points = []
load_balancers.each do |load_balancer_name|
metric_list.each do |(metric_name, statistic, unit, default_value)|
data_point = get_data_point(
:namespace => "AWS/ApplicationELB",
:metric_name => metric_name,
:statistic => statistic,
:unit => unit,
:default_value => default_value,
:dimension => {
:name => "LoadBalancerName",
:value => load_balancer_name
}
)
NewRelic::PlatformLogger.debug("metric_name: #{metric_name}, statistic: #{statistic}, unit: #{unit}, response: #{data_point.inspect}")
unless data_point.nil?
data_points << data_point
end
end
end
data_points
end
end
end
end
2 changes: 1 addition & 1 deletion lib/newrelic_aws/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module NewRelicAWS
VERSION = '3.3.4'
VERSION = '3.3.5'
end

0 comments on commit eff4331

Please sign in to comment.