{% 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, onlyUnhealthy bool) %}
Scrape targets
Scrape targets
{% for i, js := range jts %}
{% if onlyUnhealthy && js.upCount == js.targetsTotal %}{% continue %}{% endif %}
{%s js.job %}{% space %}({%d js.upCount %}/{%d js.targetsTotal %}{% space %}up)
Endpoint |
State |
Labels |
Last Scrape |
Scrape Duration |
Samples Scraped |
Error |
{% for j, ts := range js.targetsStatus %}
{% if onlyUnhealthy && ts.up %}{% continue %}{% endif %}
{%s ts.endpoint %}
|
{% if ts.up %}UP{% else %}DOWN{% endif %} |
{% space %}
{%= formatLabel(ts.labels) %}
{% space %}
{%= formatLabel(ts.originalLabels) %}
|
{%f.3 ts.lastScrapeTime.Seconds() %}s ago |
{%f.3 ts.scrapeDuration.Seconds() %}s |
{%d ts.samplesScraped %} |
{%s ts.errMsg %} |
{% endfor %}
{% endfor %}
{% for _, jobName := range emptyJobs %}
Endpoint |
State |
Labels |
Last Scrape |
Scrape Duration |
Samples Scraped |
Error |
{% endfor %}
{% endfunc %}
{% func formatLabel(labels []prompbmarshal.Label) %}
{
{% for i, label := range labels %}
{%s label.Name %}={%q label.Value %}
{% if i+1 < len(labels) %},{% space %}{% endif %}
{% endfor %}
}
{% endfunc %}
{% endstripspace %}