class Stax::Datadog::Cmd
Public Instance Methods
create()
click to toggle source
# File lib/stax/datadog/cmd.rb, line 39 def create debug("Creating datadog dashboard #{dashboard_name}") id = Datadog::Api.create_dashboard( dashboard_name, dashboard_description, graph_definitions, template_variables, ) ## add it to list (create as needed) list = Datadog::Api.create_or_get_list(list_name) Datadog::Api.add_to_list(list['id'], [{type: :custom_timeboard, id: id}]) end
dashboard_description()
click to toggle source
# File lib/stax/datadog/cmd.rb, line 15 def dashboard_description 'created by stax' end
dashboard_name()
click to toggle source
# File lib/stax/datadog/cmd.rb, line 11 def dashboard_name app_name + '-' + branch_name end
delete(title_or_id = nil)
click to toggle source
# File lib/stax/datadog/cmd.rb, line 65 def delete(title_or_id = nil) if yes?("Delete dashboards with name #{dashboard_name}?", :yellow) debug("Deleting datadog dashboard #{dashboard_name}") Datadog::Api.delete_dashboards(dashboard_name) end end
graph_definitions()
click to toggle source
# File lib/stax/datadog/cmd.rb, line 19 def graph_definitions [] end
list()
click to toggle source
# File lib/stax/datadog/cmd.rb, line 29 def list Datadog::Api.find_lists(list_name).each do |list| debug("Datadog list #{list['name']} (#{list['id']})") print_table Datadog::Api.get_list_items(list['id']).fetch('dashboards', []).map { |d| [d['title'], d['id'], d['modified']] } end end
list_name()
click to toggle source
if this is defined, dashboard will be added to this list
# File lib/stax/datadog/cmd.rb, line 7 def list_name app_name end
template_variables()
click to toggle source
# File lib/stax/datadog/cmd.rb, line 23 def template_variables [] end
update()
click to toggle source
# File lib/stax/datadog/cmd.rb, line 54 def update debug("Updating datadog dashboard #{dashboard_name}") Datadog::Api.update_dashboard( dashboard_name, dashboard_description, graph_definitions, template_variables, ) end