VictoriaMetrics/lib/promscrape/targets_response.qtpl.go
Nikolay ce8c2dd1f1
Changes targets api (#961)
* changes /targets api
adds html response if requester accepts text/html,
adds quick template for /targets api,
fixes pathPrefix for / requests

* changes namings

* renamed targets file

* Update app/victoria-metrics/main.go

Co-authored-by: Aliaksandr Valialkin <valyala@gmail.com>

* adds trimspace to qtpl,
moves content-type for targets response closer to writer

* fixes bug with prefix

Co-authored-by: Aliaksandr Valialkin <valyala@gmail.com>
2020-12-14 13:36:48 +02:00

343 lines
14 KiB
Go

// Code generated by qtc from "targets_response.qtpl". DO NOT EDIT.
// See https://github.com/valyala/quicktemplate for details.
//line lib/promscrape/targets_response.qtpl:1
package promscrape
//line lib/promscrape/targets_response.qtpl:1
import "github.com/VictoriaMetrics/VictoriaMetrics/lib/prompbmarshal"
//line lib/promscrape/targets_response.qtpl:6
import (
qtio422016 "io"
qt422016 "github.com/valyala/quicktemplate"
)
//line lib/promscrape/targets_response.qtpl:6
var (
_ = qtio422016.Copy
_ = qt422016.AcquireByteBuffer
)
//line lib/promscrape/targets_response.qtpl:6
func StreamTargetsResponsePlain(qw422016 *qt422016.Writer, jts []jobTargetsStatuses, showOriginLabels bool) {
//line lib/promscrape/targets_response.qtpl:8
for _, js := range jts {
//line lib/promscrape/targets_response.qtpl:8
qw422016.N().S(`job=`)
//line lib/promscrape/targets_response.qtpl:9
qw422016.N().Q(js.job)
//line lib/promscrape/targets_response.qtpl:9
qw422016.N().S(` `)
//line lib/promscrape/targets_response.qtpl:9
qw422016.N().S(`(`)
//line lib/promscrape/targets_response.qtpl:9
qw422016.N().D(js.upCount)
//line lib/promscrape/targets_response.qtpl:9
qw422016.N().S(`/`)
//line lib/promscrape/targets_response.qtpl:9
qw422016.N().D(js.targetsTotal)
//line lib/promscrape/targets_response.qtpl:9
qw422016.N().S(` `)
//line lib/promscrape/targets_response.qtpl:9
qw422016.N().S(`up)`)
//line lib/promscrape/targets_response.qtpl:10
qw422016.N().S(`
`)
//line lib/promscrape/targets_response.qtpl:11
for _, ts := range js.targetsStatus {
//line lib/promscrape/targets_response.qtpl:13
labels := promLabelsString(ts.labels)
ol := promLabelsString(ts.originalLabels)
//line lib/promscrape/targets_response.qtpl:16
qw422016.N().S("\t")
//line lib/promscrape/targets_response.qtpl:16
qw422016.N().S(`state=`)
//line lib/promscrape/targets_response.qtpl:16
if ts.up {
//line lib/promscrape/targets_response.qtpl:16
qw422016.N().S(`up`)
//line lib/promscrape/targets_response.qtpl:16
} else {
//line lib/promscrape/targets_response.qtpl:16
qw422016.N().S(`down`)
//line lib/promscrape/targets_response.qtpl:16
}
//line lib/promscrape/targets_response.qtpl:16
qw422016.N().S(`,`)
//line lib/promscrape/targets_response.qtpl:17
qw422016.N().S(` `)
//line lib/promscrape/targets_response.qtpl:17
qw422016.N().S(`endpoint=`)
//line lib/promscrape/targets_response.qtpl:17
qw422016.N().S(ts.endpoint)
//line lib/promscrape/targets_response.qtpl:17
qw422016.N().S(`,`)
//line lib/promscrape/targets_response.qtpl:18
qw422016.N().S(` `)
//line lib/promscrape/targets_response.qtpl:18
qw422016.N().S(`labels=`)
//line lib/promscrape/targets_response.qtpl:18
qw422016.N().S(labels)
//line lib/promscrape/targets_response.qtpl:19
if showOriginLabels {
//line lib/promscrape/targets_response.qtpl:19
qw422016.N().S(`,`)
//line lib/promscrape/targets_response.qtpl:19
qw422016.N().S(` `)
//line lib/promscrape/targets_response.qtpl:19
qw422016.N().S(`originalLabels=`)
//line lib/promscrape/targets_response.qtpl:19
qw422016.N().S(ol)
//line lib/promscrape/targets_response.qtpl:19
}
//line lib/promscrape/targets_response.qtpl:19
qw422016.N().S(`,`)
//line lib/promscrape/targets_response.qtpl:20
qw422016.N().S(` `)
//line lib/promscrape/targets_response.qtpl:20
qw422016.N().S(`last_scrape=`)
//line lib/promscrape/targets_response.qtpl:20
qw422016.N().FPrec(ts.lastScrapeTime.Seconds(), 3)
//line lib/promscrape/targets_response.qtpl:20
qw422016.N().S(`s ago,`)
//line lib/promscrape/targets_response.qtpl:21
qw422016.N().S(` `)
//line lib/promscrape/targets_response.qtpl:21
qw422016.N().S(`scrape_duration=`)
//line lib/promscrape/targets_response.qtpl:21
qw422016.N().FPrec(float64(ts.scrapeDuration.Seconds()), 3)
//line lib/promscrape/targets_response.qtpl:21
qw422016.N().S(`s,`)
//line lib/promscrape/targets_response.qtpl:22
qw422016.N().S(` `)
//line lib/promscrape/targets_response.qtpl:22
qw422016.N().S(`error=`)
//line lib/promscrape/targets_response.qtpl:22
qw422016.N().Q(ts.error)
//line lib/promscrape/targets_response.qtpl:23
qw422016.N().S(`
`)
//line lib/promscrape/targets_response.qtpl:24
}
//line lib/promscrape/targets_response.qtpl:25
}
//line lib/promscrape/targets_response.qtpl:26
qw422016.N().S(`
`)
//line lib/promscrape/targets_response.qtpl:28
}
//line lib/promscrape/targets_response.qtpl:28
func WriteTargetsResponsePlain(qq422016 qtio422016.Writer, jts []jobTargetsStatuses, showOriginLabels bool) {
//line lib/promscrape/targets_response.qtpl:28
qw422016 := qt422016.AcquireWriter(qq422016)
//line lib/promscrape/targets_response.qtpl:28
StreamTargetsResponsePlain(qw422016, jts, showOriginLabels)
//line lib/promscrape/targets_response.qtpl:28
qt422016.ReleaseWriter(qw422016)
//line lib/promscrape/targets_response.qtpl:28
}
//line lib/promscrape/targets_response.qtpl:28
func TargetsResponsePlain(jts []jobTargetsStatuses, showOriginLabels bool) string {
//line lib/promscrape/targets_response.qtpl:28
qb422016 := qt422016.AcquireByteBuffer()
//line lib/promscrape/targets_response.qtpl:28
WriteTargetsResponsePlain(qb422016, jts, showOriginLabels)
//line lib/promscrape/targets_response.qtpl:28
qs422016 := string(qb422016.B)
//line lib/promscrape/targets_response.qtpl:28
qt422016.ReleaseByteBuffer(qb422016)
//line lib/promscrape/targets_response.qtpl:28
return qs422016
//line lib/promscrape/targets_response.qtpl:28
}
//line lib/promscrape/targets_response.qtpl:30
func StreamTargetsResponseHTML(qw422016 *qt422016.Writer, jts []jobTargetsStatuses, redirectPath string, onlyUnhealthy bool) {
//line lib/promscrape/targets_response.qtpl:30
qw422016.N().S(`<!DOCTYPE html><style>.border{border-collapse: collapse;border: 1px solid black;}.table-row:hover{background-color: #f5f5f5;}</style><html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>VictoriaMetrics Database</title></head><body><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='`)
//line lib/promscrape/targets_response.qtpl:50
qw422016.N().S(redirectPath)
//line lib/promscrape/targets_response.qtpl:50
qw422016.N().S(`';"`)
//line lib/promscrape/targets_response.qtpl:50
if !onlyUnhealthy {
//line lib/promscrape/targets_response.qtpl:50
qw422016.N().S(`checked`)
//line lib/promscrape/targets_response.qtpl:50
}
//line lib/promscrape/targets_response.qtpl:50
qw422016.N().S(`> All</label><label class="btn"><input type="radio" name="targets" id="unhealthy-targets" autocomplete="off" onclick="location.href='`)
//line lib/promscrape/targets_response.qtpl:53
qw422016.N().S(redirectPath)
//line lib/promscrape/targets_response.qtpl:53
qw422016.N().S(`?show_only_unhealthy=true';"`)
//line lib/promscrape/targets_response.qtpl:53
if onlyUnhealthy {
//line lib/promscrape/targets_response.qtpl:53
qw422016.N().S(`checked`)
//line lib/promscrape/targets_response.qtpl:53
}
//line lib/promscrape/targets_response.qtpl:53
qw422016.N().S(`> Unhealthy</label><br /></div>`)
//line lib/promscrape/targets_response.qtpl:57
for _, js := range jts {
//line lib/promscrape/targets_response.qtpl:57
qw422016.N().S(`<div class="table-container"><h2 class="job_header danger"><a id="job-`)
//line lib/promscrape/targets_response.qtpl:60
qw422016.N().Q(js.job)
//line lib/promscrape/targets_response.qtpl:60
qw422016.N().S(`" >`)
//line lib/promscrape/targets_response.qtpl:60
qw422016.N().Q(js.job)
//line lib/promscrape/targets_response.qtpl:60
qw422016.N().S(`(`)
//line lib/promscrape/targets_response.qtpl:60
qw422016.N().D(js.upCount)
//line lib/promscrape/targets_response.qtpl:60
qw422016.N().S(`/`)
//line lib/promscrape/targets_response.qtpl:60
qw422016.N().D(js.targetsTotal)
//line lib/promscrape/targets_response.qtpl:60
qw422016.N().S(`up)</a></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>`)
//line lib/promscrape/targets_response.qtpl:74
for _, ts := range js.targetsStatus {
//line lib/promscrape/targets_response.qtpl:75
if onlyUnhealthy && ts.up {
//line lib/promscrape/targets_response.qtpl:75
continue
//line lib/promscrape/targets_response.qtpl:75
}
//line lib/promscrape/targets_response.qtpl:75
qw422016.N().S(`<tr class="table-row border"><td class="endpoint border"><a href="`)
//line lib/promscrape/targets_response.qtpl:78
qw422016.N().S(ts.endpoint)
//line lib/promscrape/targets_response.qtpl:78
qw422016.N().S(`">`)
//line lib/promscrape/targets_response.qtpl:78
qw422016.N().S(ts.endpoint)
//line lib/promscrape/targets_response.qtpl:78
qw422016.N().S(`</a><br></td><td class="state border"><span class="state_indicator">`)
//line lib/promscrape/targets_response.qtpl:81
if ts.up {
//line lib/promscrape/targets_response.qtpl:81
qw422016.N().S(`UP`)
//line lib/promscrape/targets_response.qtpl:81
} else {
//line lib/promscrape/targets_response.qtpl:81
qw422016.N().S(`DOWN`)
//line lib/promscrape/targets_response.qtpl:81
}
//line lib/promscrape/targets_response.qtpl:81
qw422016.N().S(`</span></td><td class="labels border", title="Original`)
//line lib/promscrape/targets_response.qtpl:83
qw422016.N().S(` `)
//line lib/promscrape/targets_response.qtpl:83
qw422016.N().S(`labels:`)
//line lib/promscrape/targets_response.qtpl:83
qw422016.N().S(` `)
//line lib/promscrape/targets_response.qtpl:83
streamformatLabel(qw422016, ts.originalLabels)
//line lib/promscrape/targets_response.qtpl:83
qw422016.N().S(`">`)
//line lib/promscrape/targets_response.qtpl:84
streamformatLabel(qw422016, ts.labels)
//line lib/promscrape/targets_response.qtpl:84
qw422016.N().S(`</td><td class="last-scrape border">`)
//line lib/promscrape/targets_response.qtpl:86
qw422016.E().S(ts.lastScrapeTime.String())
//line lib/promscrape/targets_response.qtpl:86
qw422016.N().S(`ago</td><td class="scrape-duration border">`)
//line lib/promscrape/targets_response.qtpl:87
qw422016.E().S(ts.scrapeDuration.String())
//line lib/promscrape/targets_response.qtpl:87
qw422016.N().S(`</td><td class="errors border"><span class="alert alert-danger state_indicator">`)
//line lib/promscrape/targets_response.qtpl:88
qw422016.N().S(ts.error)
//line lib/promscrape/targets_response.qtpl:88
qw422016.N().S(`</span></td></tr>`)
//line lib/promscrape/targets_response.qtpl:90
}
//line lib/promscrape/targets_response.qtpl:90
qw422016.N().S(`</tbody></table></div>`)
//line lib/promscrape/targets_response.qtpl:94
}
//line lib/promscrape/targets_response.qtpl:94
qw422016.N().S(`</body></html>`)
//line lib/promscrape/targets_response.qtpl:97
}
//line lib/promscrape/targets_response.qtpl:97
func WriteTargetsResponseHTML(qq422016 qtio422016.Writer, jts []jobTargetsStatuses, redirectPath string, onlyUnhealthy bool) {
//line lib/promscrape/targets_response.qtpl:97
qw422016 := qt422016.AcquireWriter(qq422016)
//line lib/promscrape/targets_response.qtpl:97
StreamTargetsResponseHTML(qw422016, jts, redirectPath, onlyUnhealthy)
//line lib/promscrape/targets_response.qtpl:97
qt422016.ReleaseWriter(qw422016)
//line lib/promscrape/targets_response.qtpl:97
}
//line lib/promscrape/targets_response.qtpl:97
func TargetsResponseHTML(jts []jobTargetsStatuses, redirectPath string, onlyUnhealthy bool) string {
//line lib/promscrape/targets_response.qtpl:97
qb422016 := qt422016.AcquireByteBuffer()
//line lib/promscrape/targets_response.qtpl:97
WriteTargetsResponseHTML(qb422016, jts, redirectPath, onlyUnhealthy)
//line lib/promscrape/targets_response.qtpl:97
qs422016 := string(qb422016.B)
//line lib/promscrape/targets_response.qtpl:97
qt422016.ReleaseByteBuffer(qb422016)
//line lib/promscrape/targets_response.qtpl:97
return qs422016
//line lib/promscrape/targets_response.qtpl:97
}
//line lib/promscrape/targets_response.qtpl:99
func streamformatLabel(qw422016 *qt422016.Writer, labels []prompbmarshal.Label) {
//line lib/promscrape/targets_response.qtpl:100
for _, label := range labels {
//line lib/promscrape/targets_response.qtpl:101
qw422016.N().S(` `)
//line lib/promscrape/targets_response.qtpl:101
qw422016.E().S(label.Name)
//line lib/promscrape/targets_response.qtpl:101
qw422016.N().S(`=`)
//line lib/promscrape/targets_response.qtpl:101
qw422016.E().Q(label.Value)
//line lib/promscrape/targets_response.qtpl:101
qw422016.N().S(` `)
//line lib/promscrape/targets_response.qtpl:102
}
//line lib/promscrape/targets_response.qtpl:103
}
//line lib/promscrape/targets_response.qtpl:103
func writeformatLabel(qq422016 qtio422016.Writer, labels []prompbmarshal.Label) {
//line lib/promscrape/targets_response.qtpl:103
qw422016 := qt422016.AcquireWriter(qq422016)
//line lib/promscrape/targets_response.qtpl:103
streamformatLabel(qw422016, labels)
//line lib/promscrape/targets_response.qtpl:103
qt422016.ReleaseWriter(qw422016)
//line lib/promscrape/targets_response.qtpl:103
}
//line lib/promscrape/targets_response.qtpl:103
func formatLabel(labels []prompbmarshal.Label) string {
//line lib/promscrape/targets_response.qtpl:103
qb422016 := qt422016.AcquireByteBuffer()
//line lib/promscrape/targets_response.qtpl:103
writeformatLabel(qb422016, labels)
//line lib/promscrape/targets_response.qtpl:103
qs422016 := string(qb422016.B)
//line lib/promscrape/targets_response.qtpl:103
qt422016.ReleaseByteBuffer(qb422016)
//line lib/promscrape/targets_response.qtpl:103
return qs422016
//line lib/promscrape/targets_response.qtpl:103
}