module Grafana::Dashboard
Public Instance Methods
create_dashboard(properties={})
click to toggle source
# File lib/grafana/dashboard.rb, line 24 def create_dashboard(properties={}) endpoint = "/api/dashboards/db" dashboard = self.build_template(properties) @logger.info("Creating dashboard: #{properties['title']} (POST /api/dashboards/db)") if @debug return post_request(endpoint, dashboard) end
create_slug(text)
click to toggle source
# File lib/grafana/dashboard.rb, line 6 def create_slug(text) if text =~ /\s/ if text =~ /-/ text = text.gsub(/\s+/, "").downcase else text = text.gsub(/\s+/, "-").downcase end end return text end
delete_dashboard(name)
click to toggle source
# File lib/grafana/dashboard.rb, line 31 def delete_dashboard(name) name = self.create_slug(name) endpoint = "/api/dashboards/db/#{name}" @logger.info("Deleting dahsboard ID #{id} (DELETE #{endpoint})") if @debug return delete_request(endpoint) end
get_dashboard(name='')
click to toggle source
# File lib/grafana/dashboard.rb, line 17 def get_dashboard(name='') endpoint = "/api/dashboards/db/#{name}" name = self.create_slug(name) @logger.info("Attempting to get dashboard (GET /api/dashboards/db/#{name})") if @debug return get_request(endpoint) end
get_home_dashboard()
click to toggle source
# File lib/grafana/dashboard.rb, line 38 def get_home_dashboard() endpoint = "/api/dashboards/home" @logger.info("Attempting to get home dashboard (GET #{endpoint})") if @debug return get_request(endpoint) end
search_dashboards(params={})
click to toggle source
# File lib/grafana/dashboard.rb, line 50 def search_dashboards(params={}) params['query'] = (params['query'].length >= 1 ? CGI::escape(params['query']) : '' ) params['starred'] = (params['starred'] ? 'true' : 'false') endpoint = "/api/search/?query=#{params['query']}&starred=#{params['starred']}&tag=#{params['tags']}" @logger.info("Attempting to search for dashboards (GET #{endpoint})") if @debug return get_request(endpoint) end