2020-12-14 11:36:48 +00:00
|
|
|
{% import "github.com/VictoriaMetrics/VictoriaMetrics/lib/prompbmarshal"
|
|
|
|
%}
|
|
|
|
|
2020-12-15 10:37:19 +00:00
|
|
|
{% collapsespace %}
|
2020-12-14 11:36:48 +00:00
|
|
|
|
|
|
|
{% func TargetsResponsePlain (jts []jobTargetsStatuses, showOriginLabels bool) -%}
|
|
|
|
|
|
|
|
{% for _, js := range jts %}
|
2020-12-15 10:37:19 +00:00
|
|
|
job={%q= js.job %} ({%d js.upCount %}/{%d js.targetsTotal %} up)
|
2020-12-14 11:36:48 +00:00
|
|
|
{% 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 %},
|
2020-12-15 10:37:19 +00:00
|
|
|
endpoint={%s= ts.endpoint %},
|
|
|
|
labels={%s= labels %}
|
|
|
|
{% if showOriginLabels %}, originalLabels={%s= ol %}{% endif %},
|
|
|
|
last_scrape={%f.3 ts.lastScrapeTime.Seconds() %}s ago,
|
|
|
|
scrape_duration={%f.3 ts.scrapeDuration.Seconds() %}s,
|
|
|
|
error={%q= ts.error %}
|
2020-12-14 11:36:48 +00:00
|
|
|
{% newline %}
|
|
|
|
{% endfor %}
|
|
|
|
{% endfor %}
|
|
|
|
{% newline %}
|
|
|
|
|
|
|
|
{% endfunc %}
|
|
|
|
|
|
|
|
{% func TargetsResponseHTML(jts []jobTargetsStatuses, redirectPath string, onlyUnhealthy bool) %}
|
|
|
|
<!DOCTYPE html>
|
2020-12-15 09:58:53 +00:00
|
|
|
<html lang="en">
|
|
|
|
<head>
|
2020-12-15 10:37:19 +00:00
|
|
|
<meta charset="utf-8">
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-giJF6kkoqNQ00vy+HMDP7azOuL0xtbfIcaT9wjKHr8RbDVddVHyTfAAsrekwKmP1" crossorigin="anonymous">
|
2020-12-15 09:58:53 +00:00
|
|
|
<title>Scrape targets</title>
|
|
|
|
</head>
|
2020-12-15 10:37:19 +00:00
|
|
|
<body class="m-3">
|
|
|
|
<h1>Scrape targets</h1>
|
|
|
|
<div>
|
|
|
|
<button type="button" class="btn {% if !onlyUnhealthy %}btn-primary{% else %}btn-secondary{% endif %}"
|
|
|
|
{% if onlyUnhealthy %}onclick="location.href='{%s redirectPath %}'"{% endif %}>
|
|
|
|
All
|
|
|
|
</button>
|
|
|
|
<button type="button" class="btn {% if onlyUnhealthy %}btn-primary{% else %}btn-secondary{% endif %}"
|
|
|
|
{% if !onlyUnhealthy %}onclick="location.href='{%s= redirectPath %}?show_only_unhealthy=true'"{% endif %}>
|
|
|
|
Unhealthy
|
|
|
|
</button>
|
2020-12-14 11:36:48 +00:00
|
|
|
</div>
|
|
|
|
{% for _,js :=range jts %}
|
2020-12-15 10:37:19 +00:00
|
|
|
{% if onlyUnhealthy && js.upCount == js.targetsTotal %}{% continue %}{% endif %}
|
|
|
|
<div>
|
|
|
|
<h4>
|
|
|
|
<a>{%s js.job %} ({%d js.upCount %}/{%d js.targetsTotal %} up)</a>
|
|
|
|
</h4>
|
|
|
|
<table class="table table-striped table-hover table-bordered table-sm">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th scope="col">Endpoint</th>
|
|
|
|
<th scope="col">State</th>
|
|
|
|
<th scope="col">Labels</th>
|
|
|
|
<th scope="col">Last Scrape</th>
|
|
|
|
<th scope="col">Scrape Duration</th>
|
|
|
|
<th scope="col">Error</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
{% for _, ts := range js.targetsStatus %}
|
|
|
|
{% if onlyUnhealthy && ts.up %}{% continue %}{% endif %}
|
|
|
|
<tr {% if !ts.up %}class="alert alert-danger" role="alert"{% endif %}>
|
|
|
|
<td><a href="{%s ts.endpoint %}">{%s ts.endpoint %}</a><br></td>
|
|
|
|
<td>{% if ts.up %}UP{% else %}DOWN{% endif %}</td>
|
|
|
|
<td title="Original labels: {%= formatLabel(ts.originalLabels) %}">
|
|
|
|
{%= formatLabel(ts.labels) %}
|
|
|
|
</td>
|
|
|
|
<td>{%f.3 ts.lastScrapeTime.Seconds() %}s ago</td>
|
|
|
|
<td>{%f.3 ts.scrapeDuration.Seconds() %}s</td>
|
|
|
|
<td>{%s ts.error %}</td>
|
|
|
|
</tr>
|
|
|
|
{% endfor %}
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</div>
|
2020-12-14 11:36:48 +00:00
|
|
|
{% endfor %}
|
2020-12-15 09:58:53 +00:00
|
|
|
</body>
|
2020-12-14 11:36:48 +00:00
|
|
|
</html>
|
|
|
|
{% endfunc %}
|
|
|
|
|
|
|
|
{% func formatLabel(labels []prompbmarshal.Label) %}
|
|
|
|
{% for _, label := range labels %}
|
2020-12-15 10:37:19 +00:00
|
|
|
{%s label.Name %}={%q label.Value %} {% space %}
|
2020-12-14 11:36:48 +00:00
|
|
|
{% endfor %}
|
|
|
|
{% endfunc %}
|
2020-12-15 09:58:53 +00:00
|
|
|
|
2020-12-15 10:37:19 +00:00
|
|
|
{% endcollapsespace %}
|