mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-26 20:30:10 +01:00
125 lines
4.4 KiB
Plaintext
125 lines
4.4 KiB
Plaintext
{% import "github.com/VictoriaMetrics/VictoriaMetrics/lib/prompbmarshal"
|
|
%}
|
|
|
|
{% stripspace %}
|
|
|
|
{% func TargetsResponsePlain(jts []jobTargetsStatuses, emptyJobs []string, showOriginLabels bool) %}
|
|
|
|
{% for _, js := range jts %}
|
|
job={%q= js.job %} ({%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 %}, originalLabels={%s= ol %}{% endif %},{% space %}
|
|
last_scrape={%f.3 ts.lastScrapeTime.Seconds() %}s ago,{% space %}
|
|
scrape_duration={%f.3 ts.scrapeDuration.Seconds() %}s,{% space %}
|
|
samples_scraped={%d ts.samplesScraped %},{% space %}
|
|
error={%q= ts.errMsg %}
|
|
{% newline %}
|
|
{% endfor %}
|
|
{% endfor %}
|
|
|
|
{% for _, jobName := range emptyJobs %}
|
|
job={%q= jobName %} (0/0 up)
|
|
{% newline %}
|
|
{% endfor %}
|
|
|
|
{% endfunc %}
|
|
|
|
{% func TargetsResponseHTML(jts []jobTargetsStatuses, emptyJobs []string, redirectPath string, onlyUnhealthy bool) %}
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
|
|
<title>Scrape targets</title>
|
|
</head>
|
|
<body class="m-3">
|
|
<h1>Scrape targets</h1>
|
|
<div>
|
|
<button type="button" class="btn{% space %} {% if !onlyUnhealthy %}btn-primary{% else %}btn-secondary{% endif %}"
|
|
{% if onlyUnhealthy %}onclick="location.href='{%s redirectPath %}'"{% endif %}>
|
|
All
|
|
</button>
|
|
<button type="button" class="btn{% space %}{% if onlyUnhealthy %}btn-primary{% else %}btn-secondary{% endif %}"
|
|
{% if !onlyUnhealthy %}onclick="location.href='{%s= redirectPath %}?show_only_unhealthy=true'"{% endif %}>
|
|
Unhealthy
|
|
</button>
|
|
</div>
|
|
{% for _, js := range jts %}
|
|
{% 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">Samples Scraped</th>
|
|
<th scope="col">Error</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{% for _, ts := range js.targetsStatus %}
|
|
{% if onlyUnhealthy && ts.up %}{% continue %}{% endif %}
|
|
<tr {% if !ts.up %}{%space%}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>{%d ts.samplesScraped %}</td>
|
|
<td>{%s ts.errMsg %}</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
{% endfor %}
|
|
|
|
{% for _, jobName := range emptyJobs %}
|
|
<div>
|
|
<h4>
|
|
<a>{%s jobName %} (0/0 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">Samples Scraped</th>
|
|
<th scope="col">Error</th>
|
|
</tr>
|
|
</thead>
|
|
</table>
|
|
</div>
|
|
{% endfor %}
|
|
</body>
|
|
</html>
|
|
{% endfunc %}
|
|
|
|
{% func formatLabel(labels []prompbmarshal.Label) %}
|
|
{% for _, label := range labels %}
|
|
{%s label.Name %}={%q label.Value %} {% space %}
|
|
{% endfor %}
|
|
{% endfunc %}
|
|
|
|
{% endstripspace %}
|