class Dogapi::V1::MonitorService
Constants
- API_VERSION
Public Instance Methods
can_delete_monitors(monitor_ids)
click to toggle source
# File lib/dogapi/v1/monitor.rb 45 def can_delete_monitors(monitor_ids) 46 extra_params = 47 if monitor_ids.respond_to?(:join) 48 { "monitor_ids" => monitor_ids.join(",") } 49 else 50 { "monitor_ids" => monitor_ids } 51 end 52 53 request(Net::HTTP::Get, "/api/#{API_VERSION}/monitor/can_delete", extra_params, nil, false) 54 end
cancel_downtime(downtime_id)
click to toggle source
# File lib/dogapi/v1/monitor.rb 140 def cancel_downtime(downtime_id) 141 request(Net::HTTP::Delete, "/api/#{API_VERSION}/downtime/#{downtime_id}", nil, nil, false) 142 end
cancel_downtime_by_scope(scope)
click to toggle source
# File lib/dogapi/v1/monitor.rb 144 def cancel_downtime_by_scope(scope) 145 request(Net::HTTP::Post, "/api/#{API_VERSION}/downtime/cancel/by_scope", nil, { 'scope' => scope }, true) 146 end
delete_monitor(monitor_id, options = {})
click to toggle source
# File lib/dogapi/v1/monitor.rb 56 def delete_monitor(monitor_id, options = {}) 57 request(Net::HTTP::Delete, "/api/#{API_VERSION}/monitor/#{monitor_id}", options, nil, false) 58 end
get_all_downtimes(options = {})
click to toggle source
# File lib/dogapi/v1/monitor.rb 148 def get_all_downtimes(options = {}) 149 request(Net::HTTP::Get, "/api/#{API_VERSION}/downtime", options, nil, false) 150 end
get_all_monitors(options = {})
click to toggle source
# File lib/dogapi/v1/monitor.rb 60 def get_all_monitors(options = {}) 61 extra_params = options.clone 62 # :group_states is an optional list of statuses to filter returned 63 # groups. If no value is given then no group states will be returned. 64 # Possible values are: "all", "ok", "warn", "alert", "no data". 65 if extra_params[:group_states].respond_to?(:join) 66 extra_params[:group_states] = extra_params[:group_states].join(',') 67 end 68 69 # :tags is an optional list of scope tags to filter the list of monitors 70 # returned. If no value is given, then all monitors, regardless of 71 # scope, will be returned. 72 extra_params[:tags] = extra_params[:tags].join(',') if extra_params[:tags].respond_to?(:join) 73 74 request(Net::HTTP::Get, "/api/#{API_VERSION}/monitor", extra_params, nil, false) 75 end
get_downtime(downtime_id, options = {})
click to toggle source
# File lib/dogapi/v1/monitor.rb 136 def get_downtime(downtime_id, options = {}) 137 request(Net::HTTP::Get, "/api/#{API_VERSION}/downtime/#{downtime_id}", options, nil, false) 138 end
get_monitor(monitor_id, options = {})
click to toggle source
# File lib/dogapi/v1/monitor.rb 32 def get_monitor(monitor_id, options = {}) 33 extra_params = options.clone 34 # :group_states is an optional list of statuses to filter returned 35 # groups. If no value is given then no group states will be returned. 36 # Possible values are: "all", "ok", "warn", "alert", "no data". 37 38 if extra_params[:group_states].respond_to?(:join) 39 extra_params[:group_states] = extra_params[:group_states].join(',') 40 end 41 42 request(Net::HTTP::Get, "/api/#{API_VERSION}/monitor/#{monitor_id}", extra_params, nil, false) 43 end
monitor(type, query, options = {})
click to toggle source
# File lib/dogapi/v1/monitor.rb 10 def monitor(type, query, options = {}) 11 body = { 12 'type' => type, 13 'query' => query, 14 }.merge options 15 16 request(Net::HTTP::Post, "/api/#{API_VERSION}/monitor", nil, body, true) 17 end
mute_host(hostname, options = {})
click to toggle source
HOST MUTING
# File lib/dogapi/v1/monitor.rb 155 def mute_host(hostname, options = {}) 156 request(Net::HTTP::Post, "/api/#{API_VERSION}/host/#{hostname}/mute", nil, options, true) 157 end
mute_monitor(monitor_id, options = {})
click to toggle source
# File lib/dogapi/v1/monitor.rb 94 def mute_monitor(monitor_id, options = {}) 95 request(Net::HTTP::Post, "/api/#{API_VERSION}/monitor/#{monitor_id}/mute", nil, options, true) 96 end
mute_monitors()
click to toggle source
# File lib/dogapi/v1/monitor.rb 86 def mute_monitors 87 request(Net::HTTP::Post, "/api/#{API_VERSION}/monitor/mute_all", nil, nil, false) 88 end
resolve_monitors(monitor_groups = [], options = {}, version = nil)
click to toggle source
# File lib/dogapi/v1/monitor.rb 102 def resolve_monitors(monitor_groups = [], options = {}, version = nil) 103 body = { 104 'resolve' => monitor_groups 105 }.merge options 106 107 # Currently not part of v1 at this time but adding future compatibility option 108 endpoint = version.nil? ? '/api/monitor/bulk_resolve' : "/api/#{version}/monitor/bulk_resolve" 109 110 request(Net::HTTP::Post, endpoint, nil, body, true) 111 end
schedule_downtime(scope, options = {})
click to toggle source
DOWNTIMES
# File lib/dogapi/v1/monitor.rb 124 def schedule_downtime(scope, options = {}) 125 body = { 126 'scope' => scope 127 }.merge options 128 129 request(Net::HTTP::Post, "/api/#{API_VERSION}/downtime", nil, body, true) 130 end
search_monitor_groups(options = {})
click to toggle source
# File lib/dogapi/v1/monitor.rb 117 def search_monitor_groups(options = {}) 118 request(Net::HTTP::Get, "/api/#{API_VERSION}/monitor/groups/search", options, nil, false) 119 end
search_monitors(options = {})
click to toggle source
# File lib/dogapi/v1/monitor.rb 113 def search_monitors(options = {}) 114 request(Net::HTTP::Get, "/api/#{API_VERSION}/monitor/search", options, nil, false) 115 end
unmute_host(hostname)
click to toggle source
# File lib/dogapi/v1/monitor.rb 159 def unmute_host(hostname) 160 request(Net::HTTP::Post, "/api/#{API_VERSION}/host/#{hostname}/unmute", nil, {}, true) 161 end
unmute_monitor(monitor_id, options = {})
click to toggle source
# File lib/dogapi/v1/monitor.rb 98 def unmute_monitor(monitor_id, options = {}) 99 request(Net::HTTP::Post, "/api/#{API_VERSION}/monitor/#{monitor_id}/unmute", nil, options, true) 100 end
unmute_monitors()
click to toggle source
# File lib/dogapi/v1/monitor.rb 90 def unmute_monitors 91 request(Net::HTTP::Post, "/api/#{API_VERSION}/monitor/unmute_all", nil, nil, false) 92 end
update_downtime(downtime_id, options = {})
click to toggle source
# File lib/dogapi/v1/monitor.rb 132 def update_downtime(downtime_id, options = {}) 133 request(Net::HTTP::Put, "/api/#{API_VERSION}/downtime/#{downtime_id}", nil, options, true) 134 end
update_monitor(monitor_id, query = nil, options = {})
click to toggle source
# File lib/dogapi/v1/monitor.rb 19 def update_monitor(monitor_id, query = nil, options = {}) 20 body = {}.merge options 21 unless query.nil? 22 body = { 23 'query' => query 24 }.merge body 25 warn '[DEPRECATION] query param is not required anymore and should be set to nil.'\ 26 ' To update the query, set it in the options parameter instead' 27 end 28 29 request(Net::HTTP::Put, "/api/#{API_VERSION}/monitor/#{monitor_id}", nil, body, true) 30 end
validate_monitor(type, query, options = {})
click to toggle source
# File lib/dogapi/v1/monitor.rb 77 def validate_monitor(type, query, options = {}) 78 body = { 79 'type' => type, 80 'query' => query, 81 }.merge options 82 83 request(Net::HTTP::Post, "/api/#{API_VERSION}/monitor/validate", nil, body, true) 84 end