prometheus/console_libraries/menu.lib

132 lines
4.1 KiB
HTML

{{/* vim: set ft=html: */}}
{{/* Navbar, should be passed . */}}
{{ define "navbar" }}
<nav class="navbar navbar-inverse navbar-static-top">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="{{ pathPrefix }}/">Prometheus</a>
</div>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li><a href="{{ pathPrefix }}/alerts">Alerts</a></li>
<li><a href="https://www.pagerduty.com/">PagerDuty</a></li>
</div>
</ul>
</div>
</nav>
{{ end }}
{{/* LHS menu, should be passed . */}}
{{ define "menu" }}
<div class="prom_lhs_menu">
<ul>
{{ template "_menuItem" (args . "index.html.example" "Overview") }}
{{ if query "up{job='haproxy'}" }}
{{ template "_menuItem" (args . "haproxy.html" "HAProxy") }}
{{ if match "^haproxy" .Path }}
<ul>
{{ template "_menuItem" (args . "haproxy-frontends.html" "Frontends") }}
{{ if .Params.frontend }}
<li>
<ul>
<li>
<a href="haproxy-frontend.html?frontend={{ .Params.frontend }}">{{ .Params.frontend }}</a></li>
</ul>
</li>
{{ end }}
{{ template "_menuItem" (args . "haproxy-backends.html" "Backends") }}
{{ if .Params.backend }}
<li>
<ul>
<li>
<a href="haproxy-backend.html?backend={{ .Params.backend }}">{{ .Params.backend }}</a></li>
</ul>
</li>
{{ end }}
</ul>
{{ end }}
{{ end }}
{{ if query "up{job='cassandra'}" }}
{{ template "_menuItem" (args . "cassandra.html" "Cassandra") }}
{{ end }}
{{ if query "up{job='node'}" }}
{{ template "_menuItem" (args . "node.html" "Node") }}
{{ if match "^node" .Path }}
{{ if .Params.instance }}
<ul>
<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>
</ul>
{{ end }}
{{ end }}
{{ end }}
{{ if query "up{job='snmp'}" }}
{{ template "_menuItem" (args . "snmp.html" "SNMP") }}
{{ if match "^snmp" .Path }}
{{ if .Params.instance }}
<ul>
<li {{ if eq .Path "snmp-overview.html" }}class="prom_lhs_menu_selected"{{ end }}>
<a href="snmp-overview.html?instance={{ .Params.instance }}">{{.Params.instance }}</a>
</li>
</ul>
{{ end }}
{{ end }}
{{ end }}
{{ if query "up{job='cloudwatch'}" }}
{{ template "_menuItem" (args . "cloudwatch.html" "CloudWatch") }}
{{ end }}
{{ if query "aws_elasticache_cpuutilization_average{job='aws_elasticache'}" }}
{{ template "_menuItem" (args . "aws_elasticache.html" "ElastiCache") }}
{{ end }}
{{ if query "aws_elb_healthy_host_count_average{job='aws_elb'}" }}
{{ template "_menuItem" (args . "aws_elb.html" "ELB") }}
{{ end }}
{{ if query "aws_redshift_health_status_average{job='aws_redshift'}" }}
{{ template "_menuItem" (args . "aws_redshift.html" "Redshift") }}
{{ if and (eq "aws_redshift-cluster.html" .Path) .Params.cluster_identifier }}
<ul>
<li class="prom_lhs_menu_selected">
{{ reReplaceAll "^(.{8}).{8,}(.{8})$" "$1...$2" .Params.cluster_identifier }}
</li>
</ul>
{{ end }}
{{ 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 }}