forked from prometheus/prometheus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
menu.lib
148 lines (130 loc) · 4.57 KB
/
menu.lib
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
{{/* 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='blackbox'}" }}
{{ template "_menuItem" (args . "blackbox.html" "Blackbox") }}
{{ 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='prometheus'}" }}
{{ template "_menuItem" (args . "prometheus.html" "Prometheus") }}
{{ if match "^prometheus" .Path }}
{{ if .Params.instance }}
<ul>
<li {{ if eq .Path "prometheus-overview.html" }}class="prom_lhs_menu_selected"{{ end }}>
<a href="prometheus-overview.html?instance={{ .Params.instance }}">{{.Params.instance }}</a>
</li>
</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 }}