Class: Karafka::Pro::Cli::Topics::Health

Inherits:
Cli::Topics::Base show all
Defined in:
lib/karafka/pro/cli/topics/health.rb

Overview

Checks health of Kafka topics by analyzing replication and durability settings Identifies topics with:

  • No redundancy (RF=1)

  • Zero fault tolerance (RF <= min.insync.replicas)

  • Low durability (min.insync.replicas=1)

Instance Method Summary collapse

Methods included from Helpers::Colorize

#green, #grey, #red, #yellow

Instance Method Details

#callBoolean

Executes the health check across all topics in the cluster

Returns:

  • (Boolean)

    true if issues were found, false if all topics are healthy



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/karafka/pro/cli/topics/health.rb', line 43

def call
  issues_found = false

  supervised("Checking topics health") do
    topics = existing_topics
    puts "Found #{topics.count} topics to check..."
    puts

    topics.each do |topic|
      # Skip internal Kafka topics
      next if topic[:topic_name].start_with?("__")

      issue = analyze_topic(topic)

      if issue
        display_issue(issue)
        issues_found = true
      else
        puts "#{green("")} #{topic[:topic_name]}"
      end
    end
  end

  puts
  display_summary(issues_found)
  puts

  issues_found
end