Skip to content

Commit

Permalink
Merge pull request #81 from AweSim-OSC/grafana
Browse files Browse the repository at this point in the history
Use updated grafana config schema
  • Loading branch information
treydock authored Mar 4, 2020
2 parents fe103f3 + df0b7fe commit c58238f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,18 @@ def version_from_git(dir)
erb :system_status
end

get '/clusters/:id/grafana' do
@id = params[:id].to_sym
cluster = CLUSTERS[@id]
if cluster.nil? || ! cluster.custom_config.key?(:grafana)
raise Sinatra::NotFound
end
grafana = cluster.custom_config[:grafana]
dashboard_url = "#{grafana['dashboard']['uid']}/#{grafana['dashboard']['name']}"
theme = grafana['theme'] || 'light'
grafana_url = "#{grafana['host']}/d/#{dashboard_url}?orgId=#{grafana['orgId']}&theme=#{theme}&var-cluster=#{@id}"
redirect(grafana_url)
end

# redirect to /clusters/:id/hour/report_moab_nodes page
get '/clusters/:id*' do
Expand Down
2 changes: 1 addition & 1 deletion views/layout.erb
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
<% if cluster.custom_config.key?(:ganglia) %>
<a href="<%= url("/clusters/#{cluster.id}/hour/report_moab_nodes") %>"><span><i class="fa fa-chart-area"></i></span> <%=cluster.metadata.title %> Cluster</a>
<% elsif cluster.custom_config.key?(:grafana) %>
<a href="<%= cluster.custom_config[:grafana]['dashboard'] %>" target="_blank"><span><i class="fa fa-chart-area"></i></span> <%=cluster.metadata.title %> Cluster</a>
<a href="<%= url("/clusters/#{cluster.id}/grafana") %>" target="_blank"><span><i class="fa fa-chart-area"></i></span> <%=cluster.metadata.title %> Cluster</a>
<% end %>
</li>
<% end %>
Expand Down

0 comments on commit c58238f

Please sign in to comment.