Class: Karafka::Web::Ui::Models::Health

Inherits:
Object
  • Object
show all
Defined in:
lib/karafka/web/ui/models/health.rb

Overview

Aggregated health data statistics representation

Class Method Summary collapse

Class Method Details

.cluster_lags_with_offsetsHash

Returns hash with cluster lag data.

Returns:

  • (Hash)

    hash with cluster lag data



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/karafka/web/ui/models/health.rb', line 22

def cluster_lags_with_offsets
  # We need to remap raw results so they comply with our sorting flows
  mapped_lags = {}

  ::Karafka::Admin.read_lags_with_offsets(
    active_topics_only: Web.config.ui.visibility.active_topics_cluster_lags_only
  ).each do |consumer_group, topics|
    mapped_lags[consumer_group] ||= {}

    topics.each do |topic_name, partitions_details|
      mapped_lags[consumer_group][topic_name] ||= []

      partitions_details.each do |partition_id, lags_with_offsets|
        mapped_lags[consumer_group][topic_name] << {
          id: partition_id,
          lag: lags_with_offsets.fetch(:lag),
          stored_offset: lags_with_offsets.fetch(:offset)
        }
      end
    end
  end

  mapped_lags
end

.current(state) ⇒ Hash

Returns hash with aggregated statistics.

Parameters:

  • state (State)

    current system state

Returns:

  • (Hash)

    hash with aggregated statistics



12
13
14
15
16
17
18
19
# File 'lib/karafka/web/ui/models/health.rb', line 12

def current(state)
  stats = {}

  fetch_topics_data(state, stats)
  fetch_rebalance_ages(state, stats)

  sort_structure(stats)
end