Class: Anomonitor::MutesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/anomonitor/mutes_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/controllers/anomonitor/mutes_controller.rb', line 9

def create
  seconds = parse_duration(params[:duration].presence || "24h")
  Mute.create!(
    metric: params[:metric].presence,
    rule: params[:rule].presence,
    source: params[:source].presence,
    tenant: params[:tenant].presence,
    muted_until: Time.current + seconds,
    reason: params[:reason].presence
  )
  redirect_to mutes_path, notice: "Mute created until #{seconds / 3600.0}h from now."
rescue StandardError => e
  redirect_to mutes_path, alert: e.message
end

#destroyObject



24
25
26
27
# File 'app/controllers/anomonitor/mutes_controller.rb', line 24

def destroy
  Mute.find(params[:id]).destroy!
  redirect_to mutes_path, notice: "Mute removed."
end

#indexObject



5
6
7
# File 'app/controllers/anomonitor/mutes_controller.rb', line 5

def index
  @mutes = Mute.recent.limit(100)
end