This repository has been archived by the owner on Nov 12, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Application Load Balancer collector
- Loading branch information
1 parent
baa358f
commit bcdad39
Showing
3 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |