2020-12-14 12:36:48 +01:00
|
|
|
{% import "github.com/VictoriaMetrics/VictoriaMetrics/lib/prompbmarshal"
|
|
|
|
%}
|
|
|
|
|
|
|
|
{% stripspace %}
|
|
|
|
|
|
|
|
{% func TargetsResponsePlain (jts []jobTargetsStatuses, showOriginLabels bool) -%}
|
|
|
|
|
|
|
|
{% for _, js := range jts %}
|
|
|
|
job={%q= js.job %}{% space %} ({%d js.upCount %}/{%d js.targetsTotal %} {% space %} up)
|
|
|
|
{% newline %}
|
|
|
|
{% for _, ts := range js.targetsStatus %}
|
|
|
|
{% code
|
|
|
|
labels := promLabelsString(ts.labels)
|
|
|
|
ol := promLabelsString(ts.originalLabels)
|
|
|
|
%}
|
|
|
|
{%s= "\t" %}state={% if ts.up %}up{% else %}down{% endif %},
|
|
|
|
{% space %} endpoint={%s= ts.endpoint %},
|
|
|
|
{% space %} labels={%s= labels %}
|
|
|
|
{% if showOriginLabels %},{% space %} originalLabels={%s= ol %}{% endif %},
|
2020-12-14 13:19:58 +01:00
|
|
|
{% space %} last_scrape={%f.3 ts.lastScrapeTime.Seconds() %}s {% space %} ago,
|
2020-12-15 10:24:18 +01:00
|
|
|
{% space %} scrape_duration={%f.3 ts.scrapeDuration.Seconds() %}s,
|
2020-12-14 12:36:48 +01:00
|
|
|
{% space %} error={%q= ts.error %}
|
|
|
|
{% newline %}
|
|
|
|
{% endfor %}
|
|
|
|
{% endfor %}
|
|
|
|
{% newline %}
|
|
|
|
|
|
|
|
{% endfunc %}
|
|
|
|
|
|
|
|
{% func TargetsResponseHTML(jts []jobTargetsStatuses, redirectPath string, onlyUnhealthy bool) %}
|
|
|
|
<!DOCTYPE html>
|
2020-12-15 10:58:53 +01:00
|
|
|
<html lang="en">
|
|
|
|
<head>
|
2020-12-14 12:36:48 +01:00
|
|
|
<style>
|
|
|
|
.border{
|
|
|
|
border-collapse: collapse;
|
|
|
|
border: 1px solid black;
|
|
|
|
}
|
|
|
|
.table-row:hover{
|
|
|
|
background-color: #f5f5f5;
|
|
|
|
}
|
|
|
|
</style>
|
2020-12-15 10:58:53 +01:00
|
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
|
|
<title>Scrape targets</title>
|
|
|
|
</head>
|
|
|
|
<body>
|
2020-12-14 12:36:48 +01:00
|
|
|
<h1>Targets</h1>
|
|
|
|
<div id="showTargets" class="btn-group btn-group-toggle" data-toggle="buttons">
|
|
|
|
<label class="btn">
|
|
|
|
<input type="radio" name="targets" id="all-targets" autocomplete="off" onclick="location.href='{%s= redirectPath %}';" {% if !onlyUnhealthy %}checked {% endif %}> All
|
|
|
|
</label>
|
|
|
|
<label class="btn">
|
|
|
|
<input type="radio" name="targets" id="unhealthy-targets" autocomplete="off" onclick="location.href='{%s= redirectPath %}?show_only_unhealthy=true';" {% if onlyUnhealthy %}checked {% endif %}> Unhealthy
|
|
|
|
</label>
|
|
|
|
<br />
|
|
|
|
</div>
|
|
|
|
{% for _,js :=range jts %}
|
|
|
|
<div class="table-container">
|
|
|
|
<h2 class="job_header danger">
|
2020-12-15 10:24:18 +01:00
|
|
|
<a id="job-{%q js.job %}" >{%q js.job %} ({%d js.upCount %}/{%d js.targetsTotal %} up)</a>
|
2020-12-14 12:36:48 +01:00
|
|
|
</h2>
|
|
|
|
<table class="table-bordered table-hover border">
|
|
|
|
<thead class="job_details border">
|
|
|
|
<tr class="table-row border">
|
|
|
|
<th class="border">Endpoint</th>
|
|
|
|
<th class="border">State</th>
|
|
|
|
<th class="border">Labels</th>
|
|
|
|
<th class="border">Last Scrape</th>
|
|
|
|
<th class="border">Scrape Duration</th>
|
|
|
|
<th class="border">Error</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
{% for _, ts := range js.targetsStatus %}
|
|
|
|
{% if onlyUnhealthy && ts.up %} {% continue %} {% endif %}
|
|
|
|
<tr class="table-row border">
|
|
|
|
<td class="endpoint border">
|
2020-12-15 10:24:18 +01:00
|
|
|
<a href="{%s ts.endpoint %}">{%s ts.endpoint %}</a><br>
|
2020-12-14 12:36:48 +01:00
|
|
|
</td>
|
|
|
|
<td class="state border">
|
|
|
|
<span class="state_indicator">{% if ts.up %}UP{% else %}DOWN{% endif %}</span>
|
|
|
|
</td>
|
|
|
|
<td class="labels border", title="Original {% space %} labels: {% space %} {%= formatLabel(ts.originalLabels) %}">
|
|
|
|
{%= formatLabel(ts.labels) %}
|
|
|
|
</td>
|
2020-12-15 10:24:18 +01:00
|
|
|
<td class="last-scrape border">{%f.3 ts.lastScrapeTime.Seconds() %}s {% space %} ago</td>
|
|
|
|
<td class="scrape-duration border">{%f.3 ts.scrapeDuration.Seconds() %}s</td>
|
|
|
|
<td class="errors border"><span class="alert alert-danger state_indicator">{%s ts.error %}</span></td>
|
2020-12-14 12:36:48 +01:00
|
|
|
</tr>
|
|
|
|
{% endfor %}
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
{% endfor %}
|
2020-12-15 10:58:53 +01:00
|
|
|
</body>
|
2020-12-14 12:36:48 +01:00
|
|
|
</html>
|
|
|
|
{% endfunc %}
|
|
|
|
|
|
|
|
{% func formatLabel(labels []prompbmarshal.Label) %}
|
|
|
|
{% for _, label := range labels %}
|
2020-12-15 10:58:53 +01:00
|
|
|
{% space %} {%s label.Name %}={%q label.Value %} {% space %}
|
2020-12-14 12:36:48 +01:00
|
|
|
{% endfor %}
|
|
|
|
{% endfunc %}
|
2020-12-15 10:58:53 +01:00
|
|
|
|
2020-12-14 13:19:58 +01:00
|
|
|
{% endstripspace %}
|