about summary refs log tree commit diff
path: root/bundles/prometheus/files/console_libraries/prom.lib
blob: c00bb6b2809293aaab4aba3f72dea606020d3e4e (plain) (blame)
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
148
149
150
151
152
153
{{/* vim: set ft=gotmpl: */}}
{{/* Load Prometheus console library JS/CSS. Should go in head */}}

{{ define "prom_console_head" }}
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<meta name="title" content="Prometheus &mdash; Console">
<title>Prometheus &mdash; Console</title>
<!-- rickshaw -->
<script src="https://unpkg.com/rickshaw@1.7.1/vendor/d3.v3.js"></script>
<script src="https://unpkg.com/rickshaw@1.7.1/vendor/d3.layout.min.js"></script>
<link type="text/css" rel="stylesheet" href="https://unpkg.com/rickshaw@1.7.1/rickshaw.min.css">
<script src="https://unpkg.com/rickshaw@1.7.1/rickshaw.min.js"></script>
<!-- bootstrap -->
<script src="https://unpkg.com/jquery@3.5.1/dist/jquery.min.js"></script>
<link type="text/css" rel="stylesheet" href="https://unpkg.com/bootstrap@4.5.2/dist/css/bootstrap.min.css">
<script src="https://unpkg.com/bootstrap@4.5.2/dist/js/bootstrap.bundle.min.js"></script>
<!-- icons -->
<link type="text/css" rel="stylesheet" href="https://unpkg.com/bootstrap-icons@1.13.1/font/bootstrap-icons.min.css">
<!-- user assets -->
<link type="text/css" rel="stylesheet" href="{{ pathPrefix }}/user/prom_console.css">
<script src="{{ pathPrefix }}/user/prom_console.js"></script>
<style type="text/css">
  body {
    background-color: #191d21 !important;
    color: #fff !important;
  }
  .navbar {
    margin-bottom: unset !important;
    padding-left: 15px !important;
    padding-right: 15px !important;
  }
  .prom_console_content {
    padding-top: unset !important;
    margin-bottom: unset !important;
  }
  .prom_content_div {
    width: unset !important;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
  }
  @media (max-width: 768px) {
    .prom_content_div {
      grid-template-columns: 1fr;
    }
  }
  .prom_content_div > div {
    padding: 10px;
    border: 1px solid var(--gray);
  }
  .prom_content_div * {
    background-color: var(--light) !important;
    color: var(--dark) !important;
  }
  .prom_graph_table {
    overflow: hidden;
  }
</style>
<script>
  var PATH_PREFIX = "{{ pathPrefix }}";
</script>
{{ end }}

{{/* Top of all pages. */}}
{{ define "head" -}}
<!DOCTYPE html>
<html lang="en">
  <head>
    {{ template "prom_console_head" }}
  </head>
  <body>
    {{ template "navbar" . }}
    {{ template "menu" . }}
{{ end }}

{{ define "__prom_query_drilldown_noop" }}{{ . }}{{ end }}
{{ define "humanize" }}{{ humanize . }}{{ end }}
{{ define "humanizeNoSmallPrefix" }}{{ if and (lt . 1.0) (gt . -1.0) }}{{ printf "%.3g" . }}{{ else }}{{ humanize . }}{{ end }}{{ end }}
{{ define "humanize1024" }}{{ humanize1024 . }}{{ end }}
{{ define "humanizeDuration" }}{{ humanizeDuration . }}{{ end }}
{{ define "humanizePercentage" }}{{ humanizePercentage . }}{{ end }}
{{ define "humanizeTimestamp" }}{{ humanizeTimestamp . }}{{ end }}
{{ define "printf.1f" }}{{ printf "%.1f" . }}{{ end }}
{{ define "printf.3g" }}{{ printf "%.3g" . }}{{ end }}

{{/* prom_query_drilldown (args expr suffix? renderTemplate?)
Displays the result of the expression, with a link to /graph for it.

renderTemplate is the name of the template to use to render the value.
*/}}
{{ define "prom_query_drilldown" }}
{{ $expr := .arg0 }}{{ $suffix := (or .arg1 "") }}{{ $renderTemplate := (or .arg2 "__prom_query_drilldown_noop") }}
<a class="prom_query_drilldown" href="{{ pathPrefix }}{{ graphLink $expr }}"> {{ with query $expr }}{{tmpl $renderTemplate ( . | first | value )}}{{ $suffix }}{{ else }}-{{ end }}</a>
{{ end }}

{{ define "prom_path" }}/consoles/{{ .Path }}?{{ range $param, $value := .Params }}{{ $param }}={{ $value }}&amp;{{ end }}{{ end }}"

{{ define "prom_content_head" }}
    <div class="prom_console_content">
      {{ template "prom_graph_timecontrol" . }}
{{ end }}
{{ define "prom_content_tail" }}
    </div>
{{ end }}

{{ define "prom_graph_timecontrol" }}
    <div class="prom_graph_timecontrol">
      <div class="prom_graph_timecontrol_inner">
        <div class="prom_graph_timecontrol_group ">
          <button class="btn btn-light pull-left" type="button" id="prom_graph_duration_shrink" title="Shrink the time range.">
            <i class="bi bi-dash-lg"></i>
          </button><!-- Comments between elements to remove spaces
   --><input class="input pull-left align-middle" size="3" title="Time range of graph" type="text" id="prom_graph_duration"><!--
   --><button class="btn btn-light pull-left" type="button" id="prom_graph_duration_grow" title="Grow the time range.">
            <i class="bi bi-plus-lg"></i>
          </button>
        </div>
        <div class="prom_graph_timecontrol_group ">
          <button class="btn btn-light pull-left" type="button" id="prom_graph_time_back" title="Rewind the end time.">
            <i class="bi bi-arrow-left"></i>
          </button><!--
   --><input class="input pull-left align-middle" title="End time of graph" placeholder="Until" type="text" id="prom_graph_time_end" size="16" value=""><!--
    --><button class="btn btn-light pull-left" type="button" id="prom_graph_time_forward" title="Advance the end time.">
            <i class="bi bi-arrow-right"></i>
          </button>
        </div>
        <div class="prom_graph_timecontrol_group ">
          <div class="btn-group dropup prom_graph_timecontrol_refresh pull-left">
            <button type="button" class="btn btn-light pull-left" id="prom_graph_refresh_button" title="Refresh.">
              <i class="bi bi-arrow-clockwise"></i>
              <span class="icon-repeat"></span>
              (<span id="prom_graph_refresh_button_value">Off</span>)
            </button>
            <button type="button" class="btn btn-light pull-left" data-toggle="dropdown" title="Set autorefresh." aria-haspopup="true" aria-expanded="false">
              <i class="bi bi-caret-up-fill"></i>
            </button>
            <ul class="dropdown-menu" id="prom_graph_refresh_intervals" role="menu">
            </ul>
          </div>
        </div>
      </div>
      <script>
        new PromConsole.TimeControl();
      </script>
    </div>
{{ end }}

{{/* Bottom of all pages. */}}

{{ define "tail" }}
  </body>
</html>
{{ end }}