lib/promscrape: allow editing relabeling configs and labels at /target-relabel-debug page

Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/3407
This commit is contained in:
Aliaksandr Valialkin 2022-12-10 12:44:09 -08:00
parent 3e7276639e
commit a30ae502ef
No known key found for this signature in database
GPG key ID: A72BEC6CD3D0DED1
6 changed files with 347 additions and 252 deletions

View file

@ -332,11 +332,7 @@ func requestHandler(w http.ResponseWriter, r *http.Request) bool {
return true
case "/prometheus/target-relabel-debug", "/target-relabel-debug":
promscrapeTargetRelabelDebugRequests.Inc()
if err := promscrape.WriteTargetRelabelDebug(w, r); err != nil {
promscrapeTargetRelabelDebugErrors.Inc()
httpserver.Errorf(w, r, "%s", err)
return true
}
promscrape.WriteTargetRelabelDebug(w, r)
return true
case "/prometheus/api/v1/targets", "/api/v1/targets":
promscrapeAPIV1TargetsRequests.Inc()
@ -561,9 +557,7 @@ var (
promscrapeServiceDiscoveryRequests = metrics.NewCounter(`vmagent_http_requests_total{path="/service-discovery"}`)
promscrapeMetricRelabelDebugRequests = metrics.NewCounter(`vmagent_http_requests_total{path="/metric-relabel-debug"}`)
promscrapeTargetRelabelDebugRequests = metrics.NewCounter(`vmagent_http_requests_total{path="/target-relabel-debug"}`)
promscrapeTargetRelabelDebugErrors = metrics.NewCounter(`vmagent_http_request_errors_total{path="/target-relabel-debug"}`)
promscrapeAPIV1TargetsRequests = metrics.NewCounter(`vmagent_http_requests_total{path="/api/v1/targets"}`)

View file

@ -230,14 +230,6 @@ func RequestHandler(w http.ResponseWriter, r *http.Request) bool {
promscrapeServiceDiscoveryRequests.Inc()
promscrape.WriteServiceDiscovery(w, r)
return true
case "/prometheus/target-relabel-debug", "/target-relabel-debug":
promscrapeTargetRelabelDebugRequests.Inc()
if err := promscrape.WriteTargetRelabelDebug(w, r); err != nil {
promscrapeTargetRelabelDebugErrors.Inc()
httpserver.Errorf(w, r, "%s", err)
return true
}
return true
case "/prometheus/api/v1/targets", "/api/v1/targets":
promscrapeAPIV1TargetsRequests.Inc()
w.Header().Set("Content-Type", "application/json")
@ -342,9 +334,6 @@ var (
promscrapeTargetsRequests = metrics.NewCounter(`vm_http_requests_total{path="/targets"}`)
promscrapeServiceDiscoveryRequests = metrics.NewCounter(`vm_http_requests_total{path="/service-discovery"}`)
promscrapeTargetRelabelDebugRequests = metrics.NewCounter(`vm_http_requests_total{path="/target-relabel-debug"}`)
promscrapeTargetRelabelDebugErrors = metrics.NewCounter(`vm_http_request_errors_total{path="/target-relabel-debug"}`)
promscrapeAPIV1TargetsRequests = metrics.NewCounter(`vm_http_requests_total{path="/api/v1/targets"}`)
promscrapeTargetResponseRequests = metrics.NewCounter(`vm_http_requests_total{path="/target_response"}`)

View file

@ -428,6 +428,10 @@ func RequestHandler(w http.ResponseWriter, r *http.Request) bool {
promscrapeMetricRelabelDebugRequests.Inc()
promscrape.WriteMetricRelabelDebug(w, r)
return true
case "/target-relabel-debug":
promscrapeTargetRelabelDebugRequests.Inc()
promscrape.WriteTargetRelabelDebug(w, r)
return true
case "/api/v1/rules", "/rules":
rulesRequests.Inc()
if len(*vmalertProxyURL) > 0 {
@ -593,6 +597,7 @@ var (
graphiteTagsDelSeriesErrors = metrics.NewCounter(`vm_http_request_errors_total{path="/tags/delSeries"}`)
promscrapeMetricRelabelDebugRequests = metrics.NewCounter(`vm_http_requests_total{path="/metric-relabel-debug"}`)
promscrapeTargetRelabelDebugRequests = metrics.NewCounter(`vm_http_requests_total{path="/target-relabel-debug"}`)
graphiteFunctionsRequests = metrics.NewCounter(`vm_http_requests_total{path="/functions"}`)

View file

@ -12,6 +12,7 @@ import (
func WriteMetricRelabelDebug(w http.ResponseWriter, r *http.Request) {
metric := r.FormValue("metric")
relabelConfigs := r.FormValue("relabel_configs")
if metric == "" {
metric = "{}"
}
@ -21,7 +22,6 @@ func WriteMetricRelabelDebug(w http.ResponseWriter, r *http.Request) {
WriteMetricRelabelDebugSteps(w, nil, metric, relabelConfigs, err)
return
}
pcs, err := promrelabel.ParseRelabelConfigsData([]byte(relabelConfigs))
if err != nil {
err = fmt.Errorf("cannot parse relabel configs: %s", err)
@ -29,64 +29,74 @@ func WriteMetricRelabelDebug(w http.ResponseWriter, r *http.Request) {
return
}
// The metric relabeling below must be in sync with the code at scrapeWork.addRowToTimeseries
// Apply relabeling
labelsResult, dss := pcs.ApplyDebug(labels.GetLabels())
// Remove labels with __ prefix
inStr := promrelabel.LabelsToString(labelsResult)
labelsResult = promrelabel.FinalizeLabels(labelsResult[:0], labelsResult)
outStr := promrelabel.LabelsToString(labelsResult)
if inStr != outStr {
dss = append(dss, promrelabel.DebugStep{
Rule: "remove labels with __ prefix",
In: inStr,
Out: outStr,
})
}
// There is no need in labels' sorting, since promrelabel.LabelsToString() automatically sorts labels.
dss := newDebugRelabelSteps(pcs, labels, false)
WriteMetricRelabelDebugSteps(w, dss, metric, relabelConfigs, nil)
}
// WriteTargetRelabelDebug generates response for /target-relabel-debug page
func WriteTargetRelabelDebug(w http.ResponseWriter, r *http.Request) error {
func WriteTargetRelabelDebug(w http.ResponseWriter, r *http.Request) {
targetID := r.FormValue("id")
relabelConfigs, labels, ok := getRelabelContextByTargetID(targetID)
if !ok {
return fmt.Errorf("cannot find target for id=%s", targetID)
metric := r.FormValue("metric")
relabelConfigs := r.FormValue("relabel_configs")
if metric == "" && relabelConfigs == "" {
if targetID == "" {
metric = "{}"
WriteTargetRelabelDebugSteps(w, targetID, nil, metric, relabelConfigs, nil)
return
}
pcs, labels, ok := getRelabelContextByTargetID(targetID)
if !ok {
err := fmt.Errorf("cannot find target for id=%s", targetID)
targetID = ""
WriteTargetRelabelDebugSteps(w, targetID, nil, metric, relabelConfigs, err)
return
}
metric = labels.String()
relabelConfigs = pcs.String()
dss := newDebugRelabelSteps(pcs, labels, true)
WriteTargetRelabelDebugSteps(w, targetID, dss, metric, relabelConfigs, nil)
return
}
// The target relabeling below must be in sync with the code at scrapeWorkConfig.getScrapeWork
if metric == "" {
metric = "{}"
}
labels, err := promutils.NewLabelsFromString(metric)
if err != nil {
err = fmt.Errorf("cannot parse metric: %s", err)
WriteTargetRelabelDebugSteps(w, targetID, nil, metric, relabelConfigs, err)
return
}
pcs, err := promrelabel.ParseRelabelConfigsData([]byte(relabelConfigs))
if err != nil {
err = fmt.Errorf("cannot parse relabel configs: %s", err)
WriteTargetRelabelDebugSteps(w, targetID, nil, metric, relabelConfigs, err)
return
}
dss := newDebugRelabelSteps(pcs, labels, true)
WriteTargetRelabelDebugSteps(w, targetID, dss, metric, relabelConfigs, nil)
}
func newDebugRelabelSteps(pcs *promrelabel.ParsedConfigs, labels *promutils.Labels, isTargetRelabel bool) []promrelabel.DebugStep {
// The target relabeling below must be in sync with the code at scrapeWorkConfig.getScrapeWork if isTragetRelabeling=true
// and with the code at scrapeWork.addRowToTimeseries when isTargetRelabeling=false
// Prevent from modifying the original labels
labels = labels.Clone()
// Apply relabeling
labelsResult, dss := relabelConfigs.ApplyDebug(labels.GetLabels())
// Remove labels with __meta_ prefix
inStr := promrelabel.LabelsToString(labelsResult)
labelsResult, dss := pcs.ApplyDebug(labels.GetLabels())
labels.Labels = labelsResult
labels.RemoveMetaLabels()
outStr := promrelabel.LabelsToString(labels.Labels)
if inStr != outStr {
dss = append(dss, promrelabel.DebugStep{
Rule: "remove labels with __meta_ prefix",
In: inStr,
Out: outStr,
})
}
outStr := promrelabel.LabelsToString(labels.GetLabels())
// Add missing instance label
if labels.Get("instance") == "" {
if isTargetRelabel && labels.Get("instance") == "" {
address := labels.Get("__address__")
if address != "" {
inStr = outStr
inStr := outStr
labels.Add("instance", address)
outStr = promrelabel.LabelsToString(labels.Labels)
outStr = promrelabel.LabelsToString(labels.GetLabels())
dss = append(dss, promrelabel.DebugStep{
Rule: "add missing instance label from __address__ label",
In: inStr,
@ -96,9 +106,9 @@ func WriteTargetRelabelDebug(w http.ResponseWriter, r *http.Request) error {
}
// Remove labels with __ prefix
inStr = outStr
inStr := outStr
labels.RemoveLabelsWithDoubleUnderscorePrefix()
outStr = promrelabel.LabelsToString(labels.Labels)
outStr = promrelabel.LabelsToString(labels.GetLabels())
if inStr != outStr {
dss = append(dss, promrelabel.DebugStep{
Rule: "remove labels with __ prefix",
@ -108,9 +118,7 @@ func WriteTargetRelabelDebug(w http.ResponseWriter, r *http.Request) error {
}
// There is no need in labels' sorting, since promrelabel.LabelsToString() automatically sorts labels.
WriteTargetRelabelDebugSteps(w, dss)
return nil
return dss
}
func getChangedLabelNames(in, out *promutils.Labels) map[string]struct{} {

View file

@ -15,23 +15,18 @@
<body>
{%= navbar() %}
<div class="container-fluid">
<a href="https://docs.victoriametrics.com/relabeling.html" target="_blank">Relabeling docs</a><br/>
<a href="https://docs.victoriametrics.com/relabeling.html" target="_blank">Relabeling docs</a>{% space %}
<a href="target-relabel-debug">Target relabel debug</a>
<br>
{% if err != nil %}
{%= errorNotification(err) %}
{% endif %}
<div class="m-3">
<form method="POST">
<div>
Relabel configs:<br/>
<textarea name="relabel_configs" style="width: 50%; height: 10em">{%s relabelConfigs %}</textarea>
</div>
{%= relabelDebugFormInputs(metric, relabelConfigs) %}
<div>
Metric with labels:<br/>
<textarea name="metric" style="width: 50%">{%s metric %}</textarea>
</div>
<input type="submit" value="Submit" />
<input type="submit" value="Submit" class="btn btn-primary m-1" />
</form>
</div>
@ -45,7 +40,7 @@
</html>
{% endfunc %}
{% func TargetRelabelDebugSteps(dss []promrelabel.DebugStep) %}
{% func TargetRelabelDebugSteps(targetID string, dss []promrelabel.DebugStep, metric, relabelConfigs string, err error) %}
<!DOCTYPE html>
<html lang="en">
<head>
@ -55,7 +50,26 @@
<body>
{%= navbar() %}
<div class="container-fluid">
<a href="https://docs.victoriametrics.com/relabeling.html" target="_blank">Relabeling docs</a><br/>
<a href="https://docs.victoriametrics.com/relabeling.html" target="_blank">Relabeling docs</a>{% space %}
<a href="metric-relabel-debug">Metric relabel debug</a>
<br/>
{% if err != nil %}
{%= errorNotification(err) %}
{% endif %}
<div class="m-3">
<form method="POST">
{%= relabelDebugFormInputs(metric, relabelConfigs) %}
<input type="hidden" name="id" value="{%s targetID %}" />
<input type="submit" value="Submit" class="btn btn-primary m-1" />
{% if targetID != "" %}
<button type="button" onclick="location.href='target-relabel-debug?id={%s targetID %}'" class="btn btn-secondary m-1">Reset</button>
{% endif %}
</form>
</div>
<div class="row">
<main class="col-12">
{%= relabelDebugSteps(dss) %}
@ -66,6 +80,18 @@
</html>
{% endfunc %}
{% func relabelDebugFormInputs(metric, relabelConfigs string) %}
<div>
Relabel configs:<br/>
<textarea name="relabel_configs" style="width: 100%; height: 15em" class="m-1">{%s relabelConfigs %}</textarea>
</div>
<div>
Labels:<br/>
<textarea name="metric" style="width: 100%; height: 5em" class="m-1">{%s metric %}</textarea>
</div>
{% endfunc %}
{% func relabelDebugSteps(dss []promrelabel.DebugStep) %}
{% if len(dss) > 0 %}
<div class="m-3">

View file

@ -34,186 +34,259 @@ func StreamMetricRelabelDebugSteps(qw422016 *qt422016.Writer, dss []promrelabel.
//line lib/promscrape/relabel_debug.qtpl:16
streamnavbar(qw422016)
//line lib/promscrape/relabel_debug.qtpl:16
qw422016.N().S(`<div class="container-fluid"><a href="https://docs.victoriametrics.com/relabeling.html" target="_blank">Relabeling docs</a><br/>`)
//line lib/promscrape/relabel_debug.qtpl:19
qw422016.N().S(`<div class="container-fluid"><a href="https://docs.victoriametrics.com/relabeling.html" target="_blank">Relabeling docs</a>`)
//line lib/promscrape/relabel_debug.qtpl:18
qw422016.N().S(` `)
//line lib/promscrape/relabel_debug.qtpl:18
qw422016.N().S(`<a href="target-relabel-debug">Target relabel debug</a><br>`)
//line lib/promscrape/relabel_debug.qtpl:21
if err != nil {
//line lib/promscrape/relabel_debug.qtpl:20
//line lib/promscrape/relabel_debug.qtpl:22
streamerrorNotification(qw422016, err)
//line lib/promscrape/relabel_debug.qtpl:21
//line lib/promscrape/relabel_debug.qtpl:23
}
//line lib/promscrape/relabel_debug.qtpl:21
qw422016.N().S(`<div class="m-3"><form method="POST"><div>Relabel configs:<br/><textarea name="relabel_configs" style="width: 50%; height: 10em">`)
//line lib/promscrape/relabel_debug.qtpl:23
qw422016.N().S(`<div class="m-3"><form method="POST">`)
//line lib/promscrape/relabel_debug.qtpl:27
qw422016.E().S(relabelConfigs)
streamrelabelDebugFormInputs(qw422016, metric, relabelConfigs)
//line lib/promscrape/relabel_debug.qtpl:27
qw422016.N().S(`</textarea></div><div>Metric with labels:<br/><textarea name="metric" style="width: 50%">`)
//line lib/promscrape/relabel_debug.qtpl:32
qw422016.E().S(metric)
//line lib/promscrape/relabel_debug.qtpl:32
qw422016.N().S(`</textarea></div><input type="submit" value="Submit" /></form></div><div class="row"><main class="col-12">`)
//line lib/promscrape/relabel_debug.qtpl:40
qw422016.N().S(`<input type="submit" value="Submit" class="btn btn-primary m-1" /></form></div><div class="row"><main class="col-12">`)
//line lib/promscrape/relabel_debug.qtpl:35
streamrelabelDebugSteps(qw422016, dss)
//line lib/promscrape/relabel_debug.qtpl:40
//line lib/promscrape/relabel_debug.qtpl:35
qw422016.N().S(`</main></div></div></body></html>`)
//line lib/promscrape/relabel_debug.qtpl:46
//line lib/promscrape/relabel_debug.qtpl:41
}
//line lib/promscrape/relabel_debug.qtpl:46
//line lib/promscrape/relabel_debug.qtpl:41
func WriteMetricRelabelDebugSteps(qq422016 qtio422016.Writer, dss []promrelabel.DebugStep, metric, relabelConfigs string, err error) {
//line lib/promscrape/relabel_debug.qtpl:46
//line lib/promscrape/relabel_debug.qtpl:41
qw422016 := qt422016.AcquireWriter(qq422016)
//line lib/promscrape/relabel_debug.qtpl:46
//line lib/promscrape/relabel_debug.qtpl:41
StreamMetricRelabelDebugSteps(qw422016, dss, metric, relabelConfigs, err)
//line lib/promscrape/relabel_debug.qtpl:46
//line lib/promscrape/relabel_debug.qtpl:41
qt422016.ReleaseWriter(qw422016)
//line lib/promscrape/relabel_debug.qtpl:46
//line lib/promscrape/relabel_debug.qtpl:41
}
//line lib/promscrape/relabel_debug.qtpl:46
//line lib/promscrape/relabel_debug.qtpl:41
func MetricRelabelDebugSteps(dss []promrelabel.DebugStep, metric, relabelConfigs string, err error) string {
//line lib/promscrape/relabel_debug.qtpl:46
//line lib/promscrape/relabel_debug.qtpl:41
qb422016 := qt422016.AcquireByteBuffer()
//line lib/promscrape/relabel_debug.qtpl:46
//line lib/promscrape/relabel_debug.qtpl:41
WriteMetricRelabelDebugSteps(qb422016, dss, metric, relabelConfigs, err)
//line lib/promscrape/relabel_debug.qtpl:46
//line lib/promscrape/relabel_debug.qtpl:41
qs422016 := string(qb422016.B)
//line lib/promscrape/relabel_debug.qtpl:46
//line lib/promscrape/relabel_debug.qtpl:41
qt422016.ReleaseByteBuffer(qb422016)
//line lib/promscrape/relabel_debug.qtpl:46
//line lib/promscrape/relabel_debug.qtpl:41
return qs422016
//line lib/promscrape/relabel_debug.qtpl:46
//line lib/promscrape/relabel_debug.qtpl:41
}
//line lib/promscrape/relabel_debug.qtpl:48
func StreamTargetRelabelDebugSteps(qw422016 *qt422016.Writer, dss []promrelabel.DebugStep) {
//line lib/promscrape/relabel_debug.qtpl:48
//line lib/promscrape/relabel_debug.qtpl:43
func StreamTargetRelabelDebugSteps(qw422016 *qt422016.Writer, targetID string, dss []promrelabel.DebugStep, metric, relabelConfigs string, err error) {
//line lib/promscrape/relabel_debug.qtpl:43
qw422016.N().S(`<!DOCTYPE html><html lang="en"><head>`)
//line lib/promscrape/relabel_debug.qtpl:52
//line lib/promscrape/relabel_debug.qtpl:47
streamcommonHeader(qw422016)
//line lib/promscrape/relabel_debug.qtpl:52
//line lib/promscrape/relabel_debug.qtpl:47
qw422016.N().S(`<title>Target relabel debug</title></head><body>`)
//line lib/promscrape/relabel_debug.qtpl:56
//line lib/promscrape/relabel_debug.qtpl:51
streamnavbar(qw422016)
//line lib/promscrape/relabel_debug.qtpl:51
qw422016.N().S(`<div class="container-fluid"><a href="https://docs.victoriametrics.com/relabeling.html" target="_blank">Relabeling docs</a>`)
//line lib/promscrape/relabel_debug.qtpl:53
qw422016.N().S(` `)
//line lib/promscrape/relabel_debug.qtpl:53
qw422016.N().S(`<a href="metric-relabel-debug">Metric relabel debug</a><br/>`)
//line lib/promscrape/relabel_debug.qtpl:56
qw422016.N().S(`<div class="container-fluid"><a href="https://docs.victoriametrics.com/relabeling.html" target="_blank">Relabeling docs</a><br/><div class="row"><main class="col-12">`)
//line lib/promscrape/relabel_debug.qtpl:61
streamrelabelDebugSteps(qw422016, dss)
//line lib/promscrape/relabel_debug.qtpl:61
qw422016.N().S(`</main></div></div></body></html>`)
//line lib/promscrape/relabel_debug.qtpl:67
}
//line lib/promscrape/relabel_debug.qtpl:67
func WriteTargetRelabelDebugSteps(qq422016 qtio422016.Writer, dss []promrelabel.DebugStep) {
//line lib/promscrape/relabel_debug.qtpl:67
qw422016 := qt422016.AcquireWriter(qq422016)
//line lib/promscrape/relabel_debug.qtpl:67
StreamTargetRelabelDebugSteps(qw422016, dss)
//line lib/promscrape/relabel_debug.qtpl:67
qt422016.ReleaseWriter(qw422016)
//line lib/promscrape/relabel_debug.qtpl:67
}
//line lib/promscrape/relabel_debug.qtpl:67
func TargetRelabelDebugSteps(dss []promrelabel.DebugStep) string {
//line lib/promscrape/relabel_debug.qtpl:67
qb422016 := qt422016.AcquireByteBuffer()
//line lib/promscrape/relabel_debug.qtpl:67
WriteTargetRelabelDebugSteps(qb422016, dss)
//line lib/promscrape/relabel_debug.qtpl:67
qs422016 := string(qb422016.B)
//line lib/promscrape/relabel_debug.qtpl:67
qt422016.ReleaseByteBuffer(qb422016)
//line lib/promscrape/relabel_debug.qtpl:67
return qs422016
//line lib/promscrape/relabel_debug.qtpl:67
}
//line lib/promscrape/relabel_debug.qtpl:69
func streamrelabelDebugSteps(qw422016 *qt422016.Writer, dss []promrelabel.DebugStep) {
//line lib/promscrape/relabel_debug.qtpl:70
if len(dss) > 0 {
//line lib/promscrape/relabel_debug.qtpl:70
qw422016.N().S(`<div class="m-3"><b>Original labels:</b> <samp>`)
//line lib/promscrape/relabel_debug.qtpl:72
streammustFormatLabels(qw422016, dss[0].In)
//line lib/promscrape/relabel_debug.qtpl:72
qw422016.N().S(`</samp></div>`)
//line lib/promscrape/relabel_debug.qtpl:74
if err != nil {
//line lib/promscrape/relabel_debug.qtpl:57
streamerrorNotification(qw422016, err)
//line lib/promscrape/relabel_debug.qtpl:58
}
//line lib/promscrape/relabel_debug.qtpl:74
//line lib/promscrape/relabel_debug.qtpl:58
qw422016.N().S(`<div class="m-3"><form method="POST">`)
//line lib/promscrape/relabel_debug.qtpl:62
streamrelabelDebugFormInputs(qw422016, metric, relabelConfigs)
//line lib/promscrape/relabel_debug.qtpl:62
qw422016.N().S(`<input type="hidden" name="id" value="`)
//line lib/promscrape/relabel_debug.qtpl:64
qw422016.E().S(targetID)
//line lib/promscrape/relabel_debug.qtpl:64
qw422016.N().S(`" /><input type="submit" value="Submit" class="btn btn-primary m-1" />`)
//line lib/promscrape/relabel_debug.qtpl:67
if targetID != "" {
//line lib/promscrape/relabel_debug.qtpl:67
qw422016.N().S(`<button type="button" onclick="location.href='target-relabel-debug?id=`)
//line lib/promscrape/relabel_debug.qtpl:68
qw422016.E().S(targetID)
//line lib/promscrape/relabel_debug.qtpl:68
qw422016.N().S(`'" class="btn btn-secondary m-1">Reset</button>`)
//line lib/promscrape/relabel_debug.qtpl:69
}
//line lib/promscrape/relabel_debug.qtpl:69
qw422016.N().S(`</form></div><div class="row"><main class="col-12">`)
//line lib/promscrape/relabel_debug.qtpl:75
streamrelabelDebugSteps(qw422016, dss)
//line lib/promscrape/relabel_debug.qtpl:75
qw422016.N().S(`</main></div></div></body></html>`)
//line lib/promscrape/relabel_debug.qtpl:81
}
//line lib/promscrape/relabel_debug.qtpl:81
func WriteTargetRelabelDebugSteps(qq422016 qtio422016.Writer, targetID string, dss []promrelabel.DebugStep, metric, relabelConfigs string, err error) {
//line lib/promscrape/relabel_debug.qtpl:81
qw422016 := qt422016.AcquireWriter(qq422016)
//line lib/promscrape/relabel_debug.qtpl:81
StreamTargetRelabelDebugSteps(qw422016, targetID, dss, metric, relabelConfigs, err)
//line lib/promscrape/relabel_debug.qtpl:81
qt422016.ReleaseWriter(qw422016)
//line lib/promscrape/relabel_debug.qtpl:81
}
//line lib/promscrape/relabel_debug.qtpl:81
func TargetRelabelDebugSteps(targetID string, dss []promrelabel.DebugStep, metric, relabelConfigs string, err error) string {
//line lib/promscrape/relabel_debug.qtpl:81
qb422016 := qt422016.AcquireByteBuffer()
//line lib/promscrape/relabel_debug.qtpl:81
WriteTargetRelabelDebugSteps(qb422016, targetID, dss, metric, relabelConfigs, err)
//line lib/promscrape/relabel_debug.qtpl:81
qs422016 := string(qb422016.B)
//line lib/promscrape/relabel_debug.qtpl:81
qt422016.ReleaseByteBuffer(qb422016)
//line lib/promscrape/relabel_debug.qtpl:81
return qs422016
//line lib/promscrape/relabel_debug.qtpl:81
}
//line lib/promscrape/relabel_debug.qtpl:83
func streamrelabelDebugFormInputs(qw422016 *qt422016.Writer, metric, relabelConfigs string) {
//line lib/promscrape/relabel_debug.qtpl:83
qw422016.N().S(`<div>Relabel configs:<br/><textarea name="relabel_configs" style="width: 100%; height: 15em" class="m-1">`)
//line lib/promscrape/relabel_debug.qtpl:86
qw422016.E().S(relabelConfigs)
//line lib/promscrape/relabel_debug.qtpl:86
qw422016.N().S(`</textarea></div><div>Labels:<br/><textarea name="metric" style="width: 100%; height: 5em" class="m-1">`)
//line lib/promscrape/relabel_debug.qtpl:91
qw422016.E().S(metric)
//line lib/promscrape/relabel_debug.qtpl:91
qw422016.N().S(`</textarea></div>`)
//line lib/promscrape/relabel_debug.qtpl:93
}
//line lib/promscrape/relabel_debug.qtpl:93
func writerelabelDebugFormInputs(qq422016 qtio422016.Writer, metric, relabelConfigs string) {
//line lib/promscrape/relabel_debug.qtpl:93
qw422016 := qt422016.AcquireWriter(qq422016)
//line lib/promscrape/relabel_debug.qtpl:93
streamrelabelDebugFormInputs(qw422016, metric, relabelConfigs)
//line lib/promscrape/relabel_debug.qtpl:93
qt422016.ReleaseWriter(qw422016)
//line lib/promscrape/relabel_debug.qtpl:93
}
//line lib/promscrape/relabel_debug.qtpl:93
func relabelDebugFormInputs(metric, relabelConfigs string) string {
//line lib/promscrape/relabel_debug.qtpl:93
qb422016 := qt422016.AcquireByteBuffer()
//line lib/promscrape/relabel_debug.qtpl:93
writerelabelDebugFormInputs(qb422016, metric, relabelConfigs)
//line lib/promscrape/relabel_debug.qtpl:93
qs422016 := string(qb422016.B)
//line lib/promscrape/relabel_debug.qtpl:93
qt422016.ReleaseByteBuffer(qb422016)
//line lib/promscrape/relabel_debug.qtpl:93
return qs422016
//line lib/promscrape/relabel_debug.qtpl:93
}
//line lib/promscrape/relabel_debug.qtpl:95
func streamrelabelDebugSteps(qw422016 *qt422016.Writer, dss []promrelabel.DebugStep) {
//line lib/promscrape/relabel_debug.qtpl:96
if len(dss) > 0 {
//line lib/promscrape/relabel_debug.qtpl:96
qw422016.N().S(`<div class="m-3"><b>Original labels:</b> <samp>`)
//line lib/promscrape/relabel_debug.qtpl:98
streammustFormatLabels(qw422016, dss[0].In)
//line lib/promscrape/relabel_debug.qtpl:98
qw422016.N().S(`</samp></div>`)
//line lib/promscrape/relabel_debug.qtpl:100
}
//line lib/promscrape/relabel_debug.qtpl:100
qw422016.N().S(`<table class="table table-striped table-hover table-bordered table-sm"><thead><tr><th scope="col" style="width: 5%">Step</th><th scope="col" style="width: 25%">Relabeling Rule</th><th scope="col" style="width: 35%">Input Labels</th><th scope="col" stile="width: 35%">Output labels</a></tr></thead><tbody>`)
//line lib/promscrape/relabel_debug.qtpl:85
//line lib/promscrape/relabel_debug.qtpl:111
for i, ds := range dss {
//line lib/promscrape/relabel_debug.qtpl:87
//line lib/promscrape/relabel_debug.qtpl:113
inLabels := promutils.MustNewLabelsFromString(ds.In)
outLabels := promutils.MustNewLabelsFromString(ds.Out)
changedLabels := getChangedLabelNames(inLabels, outLabels)
//line lib/promscrape/relabel_debug.qtpl:90
//line lib/promscrape/relabel_debug.qtpl:116
qw422016.N().S(`<tr><td>`)
//line lib/promscrape/relabel_debug.qtpl:92
//line lib/promscrape/relabel_debug.qtpl:118
qw422016.N().D(i)
//line lib/promscrape/relabel_debug.qtpl:92
//line lib/promscrape/relabel_debug.qtpl:118
qw422016.N().S(`</td><td><b><pre class="m-2">`)
//line lib/promscrape/relabel_debug.qtpl:93
//line lib/promscrape/relabel_debug.qtpl:119
qw422016.E().S(ds.Rule)
//line lib/promscrape/relabel_debug.qtpl:93
//line lib/promscrape/relabel_debug.qtpl:119
qw422016.N().S(`</pre></b></td><td><div class="m-2" style="font-size: 0.9em" title="deleted and updated labels highlighted in red">`)
//line lib/promscrape/relabel_debug.qtpl:96
//line lib/promscrape/relabel_debug.qtpl:122
streamlabelsWithHighlight(qw422016, inLabels, changedLabels, "red")
//line lib/promscrape/relabel_debug.qtpl:96
//line lib/promscrape/relabel_debug.qtpl:122
qw422016.N().S(`</div></td><td><div class="m-2" style="font-size: 0.9em" title="added and updated labels highlighted in blue">`)
//line lib/promscrape/relabel_debug.qtpl:101
//line lib/promscrape/relabel_debug.qtpl:127
streamlabelsWithHighlight(qw422016, outLabels, changedLabels, "blue")
//line lib/promscrape/relabel_debug.qtpl:101
//line lib/promscrape/relabel_debug.qtpl:127
qw422016.N().S(`</div></td></tr>`)
//line lib/promscrape/relabel_debug.qtpl:105
//line lib/promscrape/relabel_debug.qtpl:131
}
//line lib/promscrape/relabel_debug.qtpl:105
//line lib/promscrape/relabel_debug.qtpl:131
qw422016.N().S(`</tbody></table>`)
//line lib/promscrape/relabel_debug.qtpl:108
//line lib/promscrape/relabel_debug.qtpl:134
if len(dss) > 0 {
//line lib/promscrape/relabel_debug.qtpl:108
//line lib/promscrape/relabel_debug.qtpl:134
qw422016.N().S(`<div class="m-3"><b>Resulting labels:</b> <samp>`)
//line lib/promscrape/relabel_debug.qtpl:110
//line lib/promscrape/relabel_debug.qtpl:136
streammustFormatLabels(qw422016, dss[len(dss)-1].Out)
//line lib/promscrape/relabel_debug.qtpl:110
//line lib/promscrape/relabel_debug.qtpl:136
qw422016.N().S(`</samp></div>`)
//line lib/promscrape/relabel_debug.qtpl:112
//line lib/promscrape/relabel_debug.qtpl:138
}
//line lib/promscrape/relabel_debug.qtpl:113
//line lib/promscrape/relabel_debug.qtpl:139
}
//line lib/promscrape/relabel_debug.qtpl:113
//line lib/promscrape/relabel_debug.qtpl:139
func writerelabelDebugSteps(qq422016 qtio422016.Writer, dss []promrelabel.DebugStep) {
//line lib/promscrape/relabel_debug.qtpl:113
//line lib/promscrape/relabel_debug.qtpl:139
qw422016 := qt422016.AcquireWriter(qq422016)
//line lib/promscrape/relabel_debug.qtpl:113
//line lib/promscrape/relabel_debug.qtpl:139
streamrelabelDebugSteps(qw422016, dss)
//line lib/promscrape/relabel_debug.qtpl:113
//line lib/promscrape/relabel_debug.qtpl:139
qt422016.ReleaseWriter(qw422016)
//line lib/promscrape/relabel_debug.qtpl:113
//line lib/promscrape/relabel_debug.qtpl:139
}
//line lib/promscrape/relabel_debug.qtpl:113
//line lib/promscrape/relabel_debug.qtpl:139
func relabelDebugSteps(dss []promrelabel.DebugStep) string {
//line lib/promscrape/relabel_debug.qtpl:113
//line lib/promscrape/relabel_debug.qtpl:139
qb422016 := qt422016.AcquireByteBuffer()
//line lib/promscrape/relabel_debug.qtpl:113
//line lib/promscrape/relabel_debug.qtpl:139
writerelabelDebugSteps(qb422016, dss)
//line lib/promscrape/relabel_debug.qtpl:113
//line lib/promscrape/relabel_debug.qtpl:139
qs422016 := string(qb422016.B)
//line lib/promscrape/relabel_debug.qtpl:113
//line lib/promscrape/relabel_debug.qtpl:139
qt422016.ReleaseByteBuffer(qb422016)
//line lib/promscrape/relabel_debug.qtpl:113
//line lib/promscrape/relabel_debug.qtpl:139
return qs422016
//line lib/promscrape/relabel_debug.qtpl:113
//line lib/promscrape/relabel_debug.qtpl:139
}
//line lib/promscrape/relabel_debug.qtpl:115
//line lib/promscrape/relabel_debug.qtpl:141
func streamlabelsWithHighlight(qw422016 *qt422016.Writer, labels *promutils.Labels, highlight map[string]struct{}, color string) {
//line lib/promscrape/relabel_debug.qtpl:117
//line lib/promscrape/relabel_debug.qtpl:143
labelsList := labels.GetLabels()
metricName := ""
for i, label := range labelsList {
@ -224,137 +297,137 @@ func streamlabelsWithHighlight(qw422016 *qt422016.Writer, labels *promutils.Labe
}
}
//line lib/promscrape/relabel_debug.qtpl:127
//line lib/promscrape/relabel_debug.qtpl:153
if metricName != "" {
//line lib/promscrape/relabel_debug.qtpl:128
//line lib/promscrape/relabel_debug.qtpl:154
if _, ok := highlight["__name__"]; ok {
//line lib/promscrape/relabel_debug.qtpl:128
//line lib/promscrape/relabel_debug.qtpl:154
qw422016.N().S(`<span style="font-weight:bold;color:`)
//line lib/promscrape/relabel_debug.qtpl:129
//line lib/promscrape/relabel_debug.qtpl:155
qw422016.E().S(color)
//line lib/promscrape/relabel_debug.qtpl:129
//line lib/promscrape/relabel_debug.qtpl:155
qw422016.N().S(`">`)
//line lib/promscrape/relabel_debug.qtpl:129
//line lib/promscrape/relabel_debug.qtpl:155
qw422016.E().S(metricName)
//line lib/promscrape/relabel_debug.qtpl:129
//line lib/promscrape/relabel_debug.qtpl:155
qw422016.N().S(`</span>`)
//line lib/promscrape/relabel_debug.qtpl:130
//line lib/promscrape/relabel_debug.qtpl:156
} else {
//line lib/promscrape/relabel_debug.qtpl:131
//line lib/promscrape/relabel_debug.qtpl:157
qw422016.E().S(metricName)
//line lib/promscrape/relabel_debug.qtpl:132
//line lib/promscrape/relabel_debug.qtpl:158
}
//line lib/promscrape/relabel_debug.qtpl:133
//line lib/promscrape/relabel_debug.qtpl:159
if len(labelsList) == 0 {
//line lib/promscrape/relabel_debug.qtpl:133
//line lib/promscrape/relabel_debug.qtpl:159
return
//line lib/promscrape/relabel_debug.qtpl:133
//line lib/promscrape/relabel_debug.qtpl:159
}
//line lib/promscrape/relabel_debug.qtpl:134
//line lib/promscrape/relabel_debug.qtpl:160
}
//line lib/promscrape/relabel_debug.qtpl:134
//line lib/promscrape/relabel_debug.qtpl:160
qw422016.N().S(`{`)
//line lib/promscrape/relabel_debug.qtpl:136
//line lib/promscrape/relabel_debug.qtpl:162
for i, label := range labelsList {
//line lib/promscrape/relabel_debug.qtpl:137
//line lib/promscrape/relabel_debug.qtpl:163
if _, ok := highlight[label.Name]; ok {
//line lib/promscrape/relabel_debug.qtpl:137
//line lib/promscrape/relabel_debug.qtpl:163
qw422016.N().S(`<span style="font-weight:bold;color:`)
//line lib/promscrape/relabel_debug.qtpl:138
//line lib/promscrape/relabel_debug.qtpl:164
qw422016.E().S(color)
//line lib/promscrape/relabel_debug.qtpl:138
//line lib/promscrape/relabel_debug.qtpl:164
qw422016.N().S(`">`)
//line lib/promscrape/relabel_debug.qtpl:138
//line lib/promscrape/relabel_debug.qtpl:164
qw422016.E().S(label.Name)
//line lib/promscrape/relabel_debug.qtpl:138
//line lib/promscrape/relabel_debug.qtpl:164
qw422016.N().S(`=`)
//line lib/promscrape/relabel_debug.qtpl:138
//line lib/promscrape/relabel_debug.qtpl:164
qw422016.E().Q(label.Value)
//line lib/promscrape/relabel_debug.qtpl:138
//line lib/promscrape/relabel_debug.qtpl:164
qw422016.N().S(`</span>`)
//line lib/promscrape/relabel_debug.qtpl:139
//line lib/promscrape/relabel_debug.qtpl:165
} else {
//line lib/promscrape/relabel_debug.qtpl:140
//line lib/promscrape/relabel_debug.qtpl:166
qw422016.E().S(label.Name)
//line lib/promscrape/relabel_debug.qtpl:140
//line lib/promscrape/relabel_debug.qtpl:166
qw422016.N().S(`=`)
//line lib/promscrape/relabel_debug.qtpl:140
//line lib/promscrape/relabel_debug.qtpl:166
qw422016.E().Q(label.Value)
//line lib/promscrape/relabel_debug.qtpl:141
//line lib/promscrape/relabel_debug.qtpl:167
}
//line lib/promscrape/relabel_debug.qtpl:142
//line lib/promscrape/relabel_debug.qtpl:168
if i < len(labelsList)-1 {
//line lib/promscrape/relabel_debug.qtpl:142
//line lib/promscrape/relabel_debug.qtpl:168
qw422016.N().S(`,`)
//line lib/promscrape/relabel_debug.qtpl:142
//line lib/promscrape/relabel_debug.qtpl:168
qw422016.N().S(` `)
//line lib/promscrape/relabel_debug.qtpl:142
//line lib/promscrape/relabel_debug.qtpl:168
}
//line lib/promscrape/relabel_debug.qtpl:143
//line lib/promscrape/relabel_debug.qtpl:169
}
//line lib/promscrape/relabel_debug.qtpl:143
//line lib/promscrape/relabel_debug.qtpl:169
qw422016.N().S(`}`)
//line lib/promscrape/relabel_debug.qtpl:145
//line lib/promscrape/relabel_debug.qtpl:171
}
//line lib/promscrape/relabel_debug.qtpl:145
//line lib/promscrape/relabel_debug.qtpl:171
func writelabelsWithHighlight(qq422016 qtio422016.Writer, labels *promutils.Labels, highlight map[string]struct{}, color string) {
//line lib/promscrape/relabel_debug.qtpl:145
//line lib/promscrape/relabel_debug.qtpl:171
qw422016 := qt422016.AcquireWriter(qq422016)
//line lib/promscrape/relabel_debug.qtpl:145
//line lib/promscrape/relabel_debug.qtpl:171
streamlabelsWithHighlight(qw422016, labels, highlight, color)
//line lib/promscrape/relabel_debug.qtpl:145
//line lib/promscrape/relabel_debug.qtpl:171
qt422016.ReleaseWriter(qw422016)
//line lib/promscrape/relabel_debug.qtpl:145
//line lib/promscrape/relabel_debug.qtpl:171
}
//line lib/promscrape/relabel_debug.qtpl:145
//line lib/promscrape/relabel_debug.qtpl:171
func labelsWithHighlight(labels *promutils.Labels, highlight map[string]struct{}, color string) string {
//line lib/promscrape/relabel_debug.qtpl:145
//line lib/promscrape/relabel_debug.qtpl:171
qb422016 := qt422016.AcquireByteBuffer()
//line lib/promscrape/relabel_debug.qtpl:145
//line lib/promscrape/relabel_debug.qtpl:171
writelabelsWithHighlight(qb422016, labels, highlight, color)
//line lib/promscrape/relabel_debug.qtpl:145
//line lib/promscrape/relabel_debug.qtpl:171
qs422016 := string(qb422016.B)
//line lib/promscrape/relabel_debug.qtpl:145
//line lib/promscrape/relabel_debug.qtpl:171
qt422016.ReleaseByteBuffer(qb422016)
//line lib/promscrape/relabel_debug.qtpl:145
//line lib/promscrape/relabel_debug.qtpl:171
return qs422016
//line lib/promscrape/relabel_debug.qtpl:145
//line lib/promscrape/relabel_debug.qtpl:171
}
//line lib/promscrape/relabel_debug.qtpl:147
//line lib/promscrape/relabel_debug.qtpl:173
func streammustFormatLabels(qw422016 *qt422016.Writer, s string) {
//line lib/promscrape/relabel_debug.qtpl:148
//line lib/promscrape/relabel_debug.qtpl:174
labels := promutils.MustNewLabelsFromString(s)
//line lib/promscrape/relabel_debug.qtpl:149
//line lib/promscrape/relabel_debug.qtpl:175
streamlabelsWithHighlight(qw422016, labels, nil, "")
//line lib/promscrape/relabel_debug.qtpl:150
//line lib/promscrape/relabel_debug.qtpl:176
}
//line lib/promscrape/relabel_debug.qtpl:150
//line lib/promscrape/relabel_debug.qtpl:176
func writemustFormatLabels(qq422016 qtio422016.Writer, s string) {
//line lib/promscrape/relabel_debug.qtpl:150
//line lib/promscrape/relabel_debug.qtpl:176
qw422016 := qt422016.AcquireWriter(qq422016)
//line lib/promscrape/relabel_debug.qtpl:150
//line lib/promscrape/relabel_debug.qtpl:176
streammustFormatLabels(qw422016, s)
//line lib/promscrape/relabel_debug.qtpl:150
//line lib/promscrape/relabel_debug.qtpl:176
qt422016.ReleaseWriter(qw422016)
//line lib/promscrape/relabel_debug.qtpl:150
//line lib/promscrape/relabel_debug.qtpl:176
}
//line lib/promscrape/relabel_debug.qtpl:150
//line lib/promscrape/relabel_debug.qtpl:176
func mustFormatLabels(s string) string {
//line lib/promscrape/relabel_debug.qtpl:150
//line lib/promscrape/relabel_debug.qtpl:176
qb422016 := qt422016.AcquireByteBuffer()
//line lib/promscrape/relabel_debug.qtpl:150
//line lib/promscrape/relabel_debug.qtpl:176
writemustFormatLabels(qb422016, s)
//line lib/promscrape/relabel_debug.qtpl:150
//line lib/promscrape/relabel_debug.qtpl:176
qs422016 := string(qb422016.B)
//line lib/promscrape/relabel_debug.qtpl:150
//line lib/promscrape/relabel_debug.qtpl:176
qt422016.ReleaseByteBuffer(qb422016)
//line lib/promscrape/relabel_debug.qtpl:150
//line lib/promscrape/relabel_debug.qtpl:176
return qs422016
//line lib/promscrape/relabel_debug.qtpl:150
//line lib/promscrape/relabel_debug.qtpl:176
}