Class: Karafka::Web::Pro::Ui::Controllers::HealthController

Inherits:
BaseController show all
Defined in:
lib/karafka/web/pro/ui/controllers/health_controller.rb

Overview

Health state controller

Constant Summary

Constants inherited from Ui::Controllers::BaseController

Ui::Controllers::BaseController::Models

Instance Attribute Summary

Attributes inherited from Ui::Controllers::BaseController

#params, #session

Instance Method Summary collapse

Methods included from Lib::Filtering

included, key

Methods inherited from Ui::Controllers::BaseController

#cache, #initialize

Methods included from Ui::Controllers::Requests::Hookable

included, #run_after_hooks, #run_before_hooks

Constructor Details

This class inherits a constructor from Karafka::Web::Ui::Controllers::BaseController

Instance Method Details

#changesObject

Displays information related to time of changes of particular attributes



120
121
122
123
124
125
# File 'lib/karafka/web/pro/ui/controllers/health_controller.rb', line 120

def changes
  # Same data as overview but presented differently
  overview

  render
end

#cluster_lagsObject

Displays lags for routing defined consumer groups taken from the cluster and not the metrics reported. This is useful when we don't have any consumers running but still want to check lags because it shows what Kafka sees



99
100
101
102
103
104
105
106
107
108
109
# File 'lib/karafka/web/pro/ui/controllers/health_controller.rb', line 99

def cluster_lags
  @stats = Models::Health.cluster_lags_with_offsets

  @stats.each_value do |cg_details|
    cg_details.each_value { |topic_details| sort(topic_details) }
  end

  filter(@stats)

  render
end

#lagsObject

Displays details about lags and their progression/statuses



89
90
91
92
93
94
# File 'lib/karafka/web/pro/ui/controllers/health_controller.rb', line 89

def lags
  # Same data as overview but presented differently
  overview

  render
end

#offsetsObject

Displays details about offsets and their progression/statuses



112
113
114
115
116
117
# File 'lib/karafka/web/pro/ui/controllers/health_controller.rb', line 112

def offsets
  # Same data as overview but presented differently
  overview

  render
end

#overviewObject

Displays the current system state



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/karafka/web/pro/ui/controllers/health_controller.rb', line 72

def overview
  current_state = Models::ConsumersState.current!
  @stats = Models::Health.current(current_state)

  # Sort only on a per topic basis not to resort higher levels
  @stats.each_value do |cg_details|
    cg_details.each_value { |topic_details| sort(topic_details) }
  end

  # Narrow the whole tree down to the consumer groups/topics matching the current filter
  # (if any). It is safe to prune in place here as the stats are built fresh per request.
  filter(@stats)

  render
end