prometheus/console_libraries/menu.lib
Brian Brazil 43b105d32d Console templating library, including graphs.
This provides the basic js, css and console template
templates required to build dashboards.
Included as an example are consoles for the node_exporter.

Change-Id: I4cfeea5e9691a9413f74ae98ca32a908df8e4a59
2014-12-18 16:54:31 +00:00

57 lines
1.8 KiB
HTML

{{/* vim: set ft=html: */}}
{{/* Navbar, should be passed . */}}
{{ define "navbar" }}
<div class="navbar navbar-inverse navbar-static-top">
<div class="navbar-inner">
<ul class="navbar-nav nav">
<a class="brand" href="/">Prometheus</a>
<li><a href="/alerts">Alerts</a></li>
<!-- Add in navbar links here -->
<li><a href="https://pagerduty.com/">PagerDuty</a></li>
</ul>
</div>
</div>
{{ end }}
{{/* LHS menu, should be passed . */}}
{{ define "menu" }}
<div class="prom_lhs_menu">
<ul>
{{ $dot := . }}
{{ template "_menuItem" (args . "index.html.example" "Overview") }}
{{ template "_menuItem" (args . "node.html" "Node") }}
{{ if match "^node" .Path }}
<ul>
{{ if .Params.instance }}
<li {{ if eq .Path "node-overview.html" }}class="prom_lhs_menu_selected"{{end}}>
<a href="node-overview.html?instance={{ .Params.instance }}">{{ reReplaceAll "(.*?://)([^:/]+?)(:\\d+)?/.*" "$2" .Params.instance }}</a>
</li>
<ul>
<li {{ if eq .Path "node-cpu.html" }}class="prom_lhs_menu_selected"{{end}}>
<a href="node-cpu.html?instance={{ .Params.instance }}">CPU</a>
</li>
<li {{ if eq .Path "node-disk.html" }}class="prom_lhs_menu_selected"{{end}}>
<a href="node-disk.html?instance={{ .Params.instance }}">Disk</a>
</li>
</ul>
{{ else }}
{{ range query "up{job='node'}" | sortByLabel "instance" }}
<li><a href="node-overview.html?instance={{ .Labels.instance }}">{{ reReplaceAll "(.*?://)([^:/]+?)(:\\d+)?/.*" "$2" .Labels.instance }}</a></li>
{{ end }}
{{ end }}
</ul>
{{ end }}
</ul>
</div>
{{ end }}
{{/* Helper, pass (args . path name) */}}
{{ define "_menuItem" }}
<li {{ if eq .arg0.Path .arg1 }} class="prom_lhs_menu_selected" {{ end }}><a href="{{ .arg1 }}">{{ .arg2 }}</a></li>
{{ end }}