Class: Ask::Monitoring::DashboardController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Ask::Monitoring::DashboardController
- Defined in:
- app/controllers/ask/monitoring/dashboard_controller.rb
Instance Method Summary collapse
Instance Method Details
#index ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/controllers/ask/monitoring/dashboard_controller.rb', line 9 def index @time_range = parse_time_range @provider = params[:provider] @model = params[:model] base = Ask::Event.since(@time_range.begin) base = base.by_provider(@provider) if @provider.present? base = base.by_model(@model) if @model.present? @events = base @cost_metric = Metrics::Cost.new(base) @throughput_metric = Metrics::Throughput.new(base) @error_metric = Metrics::ErrorCount.new(base) @response_metric = Metrics::ResponseTime.new(base) end |
#metrics ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/controllers/ask/monitoring/dashboard_controller.rb', line 25 def metrics base = Ask::Event.since(parse_time_range.begin) base = base.by_provider(params[:provider]) if params[:provider].present? base = base.by_model(params[:model]) if params[:model].present? render json: { cost: Metrics::Cost.new(base).as_chart_data, throughput: Metrics::Throughput.new(base).as_chart_data, error_count: Metrics::ErrorCount.new(base).as_chart_data, error_rate: Metrics::ErrorCount.new(base).rate, response_time: Metrics::ResponseTime.new(base).percentiles } end |