Skip to content

Commit

Permalink
Add Kafka Cluster and Topic monitoring
Browse files Browse the repository at this point in the history
  • Loading branch information
cfln123 committed Jul 9, 2024
1 parent f9c3e09 commit 690e8e1
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 0 deletions.
28 changes: 28 additions & 0 deletions lib/cfnguardian/models/alarm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,34 @@ def initialize(resource,environment)
end
end

class KafkaClusterAlarm < BaseAlarm
def initialize(resource)
super(resource)
@group = 'KafkaCluster'
@namespace = 'AWS/Kafka'
@dimensions = { ClusterName: resource['Id'] }
@statistic = 'Average'
@evaluation_periods = 1
@datapoints_to_alarm = 1
@period = 300
@treat_missing_data = 'breaching'
end
end

class KafkaTopicAlarm < BaseAlarm
def initialize(resource)
super(resource)
@group = 'KafkaTopic'
@namespace = 'AWS/Kafka'
@dimensions = { ClusterName: resource['ClusterName'], Topic: resource['Id'] }
@statistic = 'Average'
@evaluation_periods = 1
@datapoints_to_alarm = 1
@period = 300
@treat_missing_data = 'breaching'
end
end

class LambdaAlarm < BaseAlarm
def initialize(resource)
super(resource)
Expand Down
68 changes: 68 additions & 0 deletions lib/cfnguardian/resources/kafka_cluster.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
module CfnGuardian::Resource
class KafkaCluster < Base

def default_alarms
alarm = CfnGuardian::Models::KafkaClusterAlarm.new(@resource)
alarm.name = 'CPUUserCritical'
alarm.metric_name = 'CPUUser'
alarm.threshold = 80
@alarms.push(alarm)

alarm = CfnGuardian::Models::KafkaClusterAlarm.new(@resource)
alarm.name = 'CPUUserWarning'
alarm.metric_name = 'CPUUser'
alarm.threshold = 50
alarm.alarm_action = 'Warning'
@alarms.push(alarm)

alarm = CfnGuardian::Models::KafkaClusterAlarm.new(@resource)
alarm.name = 'KafkaDataLogsDiskUsedCritical'
alarm.metric_name = 'KafkaDataLogsDiskUsed'
alarm.threshold = 85
@alarms.push(alarm)

alarm = CfnGuardian::Models::KafkaClusterAlarm.new(@resource)
alarm.name = 'KafkaDataLogsDiskUsedWarning'
alarm.metric_name = 'KafkaDataLogsDiskUsed'
alarm.threshold = 70
alarm.alarm_action = 'Warning'
@alarms.push(alarm)

alarm = CfnGuardian::Models::KafkaClusterAlarm.new(@resource)
alarm.name = 'BurstBalance'
alarm.metric_name = 'BurstBalance'
alarm.threshold = 1
alarm.comparison_operator = 'LessThanThreshold'
@alarms.push(alarm)

alarm = CfnGuardian::Models::KafkaClusterAlarm.new(@resource)
alarm.name = 'MemoryFreeCritical'
alarm.metric_name = 'MemoryFree'
alarm.threshold = 10
alarm.comparison_operator = 'LessThanThreshold'
@alarms.push(alarm)

alarm = CfnGuardian::Models::KafkaClusterAlarm.new(@resource)
alarm.name = 'MemoryFreeWarning'
alarm.metric_name = 'MemoryFree'
alarm.threshold = 50
alarm.alarm_action = 'Warning'
alarm.comparison_operator = 'LessThanThreshold'
@alarms.push(alarm)

alarm = CfnGuardian::Models::KafkaClusterAlarm.new(@resource)
alarm.name = 'NetworkRxErrorsCritical'
alarm.metric_name = 'NetworkRxErrors'
alarm.threshold = 10
@alarms.push(alarm)

alarm = CfnGuardian::Models::KafkaClusterAlarm.new(@resource)
alarm.name = 'NetworkRxErrorsWarning'
alarm.metric_name = 'NetworkRxErrors'
alarm.threshold = 5
alarm.alarm_action = 'Warning'
@alarms.push(alarm)
end

end
end
13 changes: 13 additions & 0 deletions lib/cfnguardian/resources/kafka_topic.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module CfnGuardian::Resource
class KafkaTopic < Base

def default_alarms
alarm = CfnGuardian::Models::KafkaTopicAlarm.new(@resource)
alarm.name = 'MessagesInPerSec'
alarm.metric_name = 'MessagesInPerSec'
alarm.threshold = 5
alarm.comparison_operator = 'LessThanThreshold'
@alarms.push(alarm)
end
end
end

0 comments on commit 690e8e1

Please sign in to comment.