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

Commit

Permalink
Add Application Load Balancer collector
Browse files Browse the repository at this point in the history
  • Loading branch information
msummers-nr committed Oct 18, 2016
1 parent baa358f commit bcdad39
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/newrelic_aws.rb
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
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
@@ -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

0 comments on commit bcdad39

Please sign in to comment.