Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Riemann Aws ELB: send 0 metric on empty result #155

Merged
merged 1 commit into from
Mar 15, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 20 additions & 14 deletions tools/riemann-aws/bin/riemann-elb-metrics
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,13 @@ class Riemann::Tools::ELBMetrics
# the given time period, values for these metrics will not be recorded in CloudWatch"
#next if result.body["GetMetricStatisticsResult"]["Datapoints"].empty? && metric_type =~ /[2345]XX/
#
# BUG:
# Metrics are reported every 60 seconds, but sometimes there isn't one there yet.
# We can skip that, or do something else?
next if result.body["GetMetricStatisticsResult"]["Datapoints"].empty?
if result.body["GetMetricStatisticsResult"]["Datapoints"].empty?
standard_metrics[metric_type]['Statistics'].each do |stat_type|
event = event(lb, az, metric_type, stat_type, 0.0)
report(event)
end
next
end

# We should only ever have a single data point
result.body["GetMetricStatisticsResult"]["Datapoints"][0].keys.sort.each do |stat_type|
Expand All @@ -139,22 +142,25 @@ class Riemann::Tools::ELBMetrics

unit = result.body["GetMetricStatisticsResult"]["Datapoints"][0]["Unit"]
metric = result.body["GetMetricStatisticsResult"]["Datapoints"][0][stat_type]
event = Hash.new
event = {
host: lb,
service: "elb.#{az}.#{metric_type}.#{stat_type}",
ttl: 60,
description: "#{lb} #{metric_type} #{stat_type} (#{unit})",
tags: [ "production", "elb_metrics" ],
metric: metric
}

event = event(lb, az, metric_type, stat_type, metric, unit)
report(event)
end
end
end
end
end

private
def event(lb, az, metric_type, stat_type, metric, unit=nil)
event = {
host: lb,
service: "elb.#{az}.#{metric_type}.#{stat_type}",
ttl: 60,
description: "#{lb} #{metric_type} #{stat_type} (#{unit})",
tags: ["elb_metrics"],
metric: metric
}
end
end

Riemann::Tools::ELBMetrics.run