Class: Karafka::Web::Pro::Ui::Controllers::DashboardController

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

Overview

Main Karafka Pro Web-Ui dashboard 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 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

#indexObject

View with statistics dashboard details



41
42
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
# File 'lib/karafka/web/pro/ui/controllers/dashboard_controller.rb', line 41

def index
  @current_state = Models::ConsumersState.current!
  @counters = Models::Counters.new(@current_state)

  current_metrics = Models::ConsumersMetrics.current!

  # Build the charts data using the aggregated metrics
  @aggregated = Models::Metrics::Aggregated.new(
    current_metrics.to_h.fetch(:aggregated)
  )

  # Build the charts data about topics using the consumers groups metrics
  @topics = Models::Metrics::Topics.new(
    current_metrics.to_h.fetch(:consumer_groups)
  )

  # Load only historicals for the selected range
  @aggregated_charts = Models::Metrics::Charts::Aggregated.new(
    @aggregated, @params.current_range
  )

  @topics_charts = Models::Metrics::Charts::Topics.new(
    @topics, @params.current_range
  )

  render
end