Class: Rearview::MonitorController

Inherits:
ApplicationController show all
Defined in:
app/controllers/rearview/monitor_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

TODO this should be moved to the JobsController#test and the UI changed to push the monitor job model instead of custom params



13
14
15
16
17
18
19
20
21
22
# File 'app/controllers/rearview/monitor_controller.rb', line 13

def create
  metrics_validator = Rearview::MetricsValidator.new({attributes: [:metrics]})
  @errors = params[:metrics].inject([]) { |a,v| a << "Metrics contains an invalid metric: #{v}" unless(metrics_validator.metric_valid?(v)); a }
  results = if @errors.empty?
              Rearview::MonitorRunner.run(params[:metrics],params[:monitorExpr],params[:minutes],{},false,params[:toDate],true)
            else
              { }
            end
  @monitor_output = Rearview::MonitorRunner.normalize_results(results)
end