Skip to content

Commit

Permalink
Merge pull request #19 from obazoud/partition
Browse files Browse the repository at this point in the history
Threshold per partition
  • Loading branch information
obazoud committed Feb 17, 2017
2 parents a686e5c + 39c39ca commit 8b74cc4
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
### Fixed
### Changed

## [Unreleased]

### Added
- check-consumer-lag: threshold per partition

## [0.10.0] - 2017-02-16

### Added
Expand Down
27 changes: 27 additions & 0 deletions bin/check-consumer-lag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ def run
min_lag = lags.map(&:values).flatten.min
min_topics = lags.select { |a| a.key(min_lag) }.map(&:keys).flatten

# Global
[:over, :under].each do |over_or_under|
[:critical, :warning].each do |severity|
threshold = config[:"#{severity}_#{over_or_under}"]
Expand All @@ -152,6 +153,32 @@ def run
end
end

# Per partition
[:over, :under].each do |over_or_under|
[:critical, :warning].each do |severity|
threshold = config[:"#{severity}_#{over_or_under}"]

next unless threshold

consumers.each do |k, v|
v.each do |partition|
case over_or_under
when :over
if partition[:lag].to_f > (threshold.to_f * 1.33 / v.size)
msg = "Topics `#{k}` partition #{partition[:partition]} lag: #{partition[:lag]} (>= #{threshold.to_f * 1.33 / v.size})"
send severity, msg
end
when :under
if min_lag < (threshold.to_f / v.size)
msg = "Topics `#{k}` partition #{partition[:partition]} lag: #{partition[:lag]} (<= #{threshold.to_f / v.size})"
send severity, msg
end
end
end
end
end
end

ok "Group `#{config[:group]}`'s lag is ok (#{min_lag}/#{max_lag})"

rescue => e
Expand Down

0 comments on commit 8b74cc4

Please sign in to comment.