<!DOCTYPE html>
{{/*
Copyright 2014 The Prometheus Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/}}
<html lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<meta name="robots" content="noindex,nofollow">
	<title>Prometheus Pushgateway</title>
	
	<link rel="shortcut icon" href="{{.PathPrefix}}/static/favicon.ico?v={{.BuildInfo.revision}}">
	
	<script src="{{.PathPrefix}}/static/jquery-3.7.1.min.js?v={{.BuildInfo.revision}}"></script>
	<script src="{{.PathPrefix}}/static/bootstrap-4.3.1-dist/js/bootstrap.min.js?v={{.BuildInfo.revision}}"></script>
	<script src="{{.PathPrefix}}/static/functions.js?v={{.BuildInfo.revision}}"></script>
	
	<link type="text/css" rel="stylesheet" href="{{.PathPrefix}}/static/bootstrap-4.3.1-dist/css/bootstrap.min.css?v={{.BuildInfo.revision}}">
	<link type="text/css" rel="stylesheet" href="{{.PathPrefix}}/static/prometheus.css?v={{.BuildInfo.revision}}">
	<link type="text/css" rel="stylesheet" href="{{.PathPrefix}}/static/bootstrap4-glyphicons/css/bootstrap-glyphicons.min.css?v={{.BuildInfo.revision}}">
</head>

<body>
	<nav class="navbar fixed-top navbar-expand-sm navbar-dark bg-dark">
		<div class="container-fluid">
			<button type="button" class="navbar-toggler" data-toggle="collapse" data-target="#nav-content" aria-expanded="false" aria-controls="nav-content" aria-label="Toggle navigation">
				<span class="navbar-toggler-icon"></span>
			</button>
			<a class="navbar-brand" href="#">Pushgateway</a>
			<!-- Collect the nav links, forms, and other content for toggling -->
			<div id="nav-content" class="navbar-collapse collapse">
				<ul class="navbar-nav">
					<li class="nav-item active" onclick="pushgateway.switchToMetrics()" id="metrics-li">
						<a class="nav-link" href="#">Metrics</a>
					</li>
					<li class="nav-item" onclick="pushgateway.switchToStatus()" id="status-li">
						<a class="nav-link" href="#">Status</a>
					</li>
					<li class="nav-item" >
						<a class ="nav-link" href="https://github.com/prometheus/pushgateway/blob/master/README.md" target="_blank">Help</a>
					</li>
				</ul>
			</div>
		</div>
	</nav>
	<div class="container-fluid" id="metrics-div">
		{{- $data := .}}
		{{- if eq (index .Flags "web.enable-admin-api") "true"}}
		<div class="blank-card">
			<button class="btn btn-xs btn-danger float-right {{if le (len .MetricGroups) 0}}disabled{{end}}" onclick="pushgateway.showDelAllModal()" id="del-all">Delete All <span class="badge badge-warning" id="del-all-counter">{{.MetricGroups | len}}</span> Groups</button>
		</div>
		{{- end}}
		<div class="accordion" id="job-accordion">
	{{- range .MetricGroups}}
	{{- $gCount := $data.Count}}
	<div class="card">
		<div class="card-header" id="group-panel-{{$gCount}}">
			<h2 class="mb-0">
				<button class="btn btn-secondary collapsed" type="button" data-toggle="collapse" data-target="#j-{{$gCount}}" aria-expanded="false" aria-controls="j-{{$gCount}}">
					<span class="toggle-icon glyphicon glyphicon-collapse-down"></span>
					{{- $metricGroup := .}}
					{{- range $i, $ln := .SortedLabels}}
					<span class="badge {{if eq $ln "job"}}badge-warning{{else if eq $ln "instance"}}badge-primary{{else}}badge-info{{end}}">{{formatLabelName $ln}}="{{index $metricGroup.Labels $ln}}"</span>
					{{- end}}
				</button>
				{{- if not $metricGroup.LastPushSuccess}}<span class="badge badge-pill badge-danger" role="alert">Last push failed!</span>{{end}}
				<button class="btn btn-xs btn-danger float-right" onclick="pushgateway.showDelModal({ {{range $i, $ln := .SortedLabels}}{{if $i}}, {{end}}'{{$ln}}': '{{index $metricGroup.Labels $ln}}'{{end}} }, { {{range $i, $ln := .SortedLabels}}{{if $i}}, {{end}}'{{$ln}}': '{{index $metricGroup.Labels $ln | base64}}'{{end}} }, 'group-panel-{{$gCount}}', event)">Delete Group</button>
			</h2>
		</div>
		<div id="j-{{$gCount}}" class="collapse" aria-labelledby="group-panel-{{$gCount}}" data-parent="#job-accordion">
			<div class="card-body">
				<div class="accordion" id="metric-accordion-{{$gCount}}">
	{{- range $name, $tmf := .Metrics }}
	{{- $mCount := $data.Count}}
	<div class="card">
		<div class="card-header" id="metric-panel-{{$mCount}}">
			<h2 class="mb-0">
				<button class="btn btn-secondary collapsed" type="button" data-toggle="collapse" data-target="#m-{{$mCount}}" aria-expanded="false" aria-controls="#m-{{$mCount}}" style="text-align:left">
					<span class="toggle-icon glyphicon glyphicon-collapse-down"></span>
					{{- $name}}
					<span class="badge badge-light">{{$tmf.GetMetricFamily.GetHelp}}</span>
					<span class="badge badge-success">{{$tmf.GetMetricFamily.GetType}}</span>
					last pushed: {{$tmf.Timestamp | timeFormat }}
				</button>
			</h2>
		</div>
		<div id="m-{{$mCount}}" class="collapse" aria-labelledby="metric-panel-{{$mCount}}" data-parent="#metric-accordion-{{$gCount}}" >
			<div class="card-body" style="max-width: 100%; overflow-x: auto">
				<table class="table table-striped table-bordered">
					<thead>
						<tr>
							<th>Labels</th>
							<th>Value</th>
						</tr>
					</thead>
					<tbody>
	{{- range $tmf.GetMetricFamily.Metric}}
	<tr>
		<td>
			{{- range .Label}}
			<span class="badge {{if eq .GetName "job"}}badge-warning{{else if eq .GetName "instance"}}badge-primary{{else}}badge-info{{end}}">{{formatLabelName .Name}}="{{.GetValue}}"</span>
			{{- end}}
		</td>
		<td>
			{{- with .Gauge}}
			{{- value .GetValue}}
			{{- else}}
			{{- with .Counter}}
			{{- value .GetValue}}
			{{- else}}
			{{- with .Untyped}}
			{{- value .GetValue}}
			{{- else}}
			{{- with .Summary}}
			<table class="table table-striped table-bordered">
				{{- range .Quantile}}
				<tr>
					<th scope="row">Quantile {{.GetQuantile}}</th>
					<td>{{value .GetValue}}</td>
				</tr>
				{{- end}}
				<tr>
					<th scope="row">Sample Count</th>
					<td>{{.GetSampleCount}}</td>
				</tr>
				<tr>
					<th scope="row">Sample Sum</th>
					<td>{{value .GetSampleSum}}</td>
				</tr>
			</table>
			{{- else}}
                        {{- $h := .Histogram}}
			{{- with .Histogram}}
                        {{- $numBuckets := len .Bucket}}
                        {{- $numNBuckets := add (len .PositiveSpan) (len .NegativeSpan)}}
			<table class="table table-striped table-bordered">
                                {{- if gt $numNBuckets 0}}
				<tr>
                                    <th scope="row">Native Histogram representation</th>
                                    <td>{{formatHistogram $h}}</td>
				</tr>
                                {{- end}}
                                {{- if gt $numBuckets 0}}
                                        {{- range .Bucket}}
                                        <tr>
                                                <th scope="row">Sample values &le; {{value .GetUpperBound}}</th>
                                                <td>{{.GetCumulativeCount}}</td>
                                        </tr>
                                        {{- end}}
                                        <tr>
                                                <th scope="row">Total sample Count</th>
                                                <td>{{.GetSampleCount}}</td>
                                        </tr>
                                        <tr>
                                                <th scope="row">Sample Sum</th>
                                                <td>{{value .GetSampleSum}}</td>
                                        </tr>
                                {{- end}}
                                {{- if eq (add $numNBuckets $numBuckets) 0}}
                                        <tr>
                                                <th scope="row">Total sample Count</th>
                                                <td>{{.GetSampleCount}}</td>
                                        </tr>
                                        <tr>
                                                <th scope="row">Sample Sum</th>
                                                <td>{{value .GetSampleSum}}</td>
                                        </tr>
                                {{- end}}
			</table>
			{{- end}}
			{{- end}}
			{{- end}}
			{{- end}}
			{{- end}}
		</td>
	</tr>
	{{- end}}
	</tbody>
				</table>
			</div>
		</div>
	</div>
	{{- end}}
				</div>
			</div>
		</div>
	</div>
	{{- end}}
		</div>
	</div>

	<div class="container-fluid" id="status-div" style="display: none;">
		<h2>Runtime Information</h2>
		<table class="table table-condensed table-bordered table-striped">
			<tbody>
				<tr>
					<th>Started</th>
					<td>{{.Birth}}</td>
				</tr>
			</tbody>
		</table>
		
		<h2>Build Information</h2>
		<table class="table table-condensed table-bordered table-striped">
			<tbody>
				{{- range $key, $value := .BuildInfo}}
				<tr>
					<th scope="row">{{$key}}</th>
					<td>{{$value}}</td>
				</tr>
				{{- end}}
			</tbody>
		</table>
		
		<h2>Startup Flags</h2>
		<table class="table table-condensed table-bordered table-striped">
			<tbody>
				{{- range $key, $value := .Flags}}
				<tr>
					<th scope="row">{{$key}}</th>
					<td>{{$value}}</td>
				</tr>
				{{- end}}
			</tbody>
		</table>
	</div>
	
	<!-- del modal -->
	<div id="del-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="del-header" aria-hidden="true">
		<div class="modal-dialog modal-sm">
			<div class="modal-content">
				<div class="modal-header">
					<h5 class="modal-title">Deletion Confirmation</h5>
					<button type="button" class="close" data-dismiss="modal" aria-label="Close">
						<span aria-hidden="true">&times;</span>
					</button>
				</div>
				<div class="modal-body">
					<p id="del-modal-msg"><!-- To be filled dynamically. --></p>
				</div>
				<div class="modal-footer">
					<button class="btn btn-secondary" data-dismiss="modal">Cancel</button>
					<button class="btn btn-primary btn-danger" onclick="pushgateway.deleteGroup()">Delete</button>
				</div>
			</div>
		</div>
	</div>
	
	<!-- del ALL modal -->
	<div id="del-all-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="del-header" aria-hidden="true">
		<div class="modal-dialog modal-sm">
			<div class="modal-content">
				<div class="modal-header">
					<h5 class="modal-title">Deletion Confirmation</h5>
					<button type="button" class="close" data-dismiss="modal" aria-label="Close">
						<span aria-hidden="true">&times;</span>
					</button>
				</div>
				<div class="modal-body">
					<p id="del-modal-all-msg"><!-- To be filled dynamically. --></p>
				</div>
				<div class="modal-footer">
					<button class="btn btn-secondary" data-dismiss="modal">Cancel</button>
					<button class="btn btn-primary btn-danger" onclick="pushgateway.deleteAllGroup()">Delete All</button>
				</div>
			</div>
		</div>
	</div>
	
</body>
</html>
