mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
app/vmselect: small cleanup after 4f3f9950d0
Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/3807
This commit is contained in:
parent
1db9b78b88
commit
ec3943d14a
6 changed files with 41 additions and 37 deletions
|
@ -468,7 +468,6 @@ func RequestHandler(w http.ResponseWriter, r *http.Request) bool {
|
|||
return true
|
||||
case "/metric-relabel-debug":
|
||||
promscrapeMetricRelabelDebugRequests.Inc()
|
||||
httpserver.EnableCORS(w, r)
|
||||
promscrape.WriteMetricRelabelDebug(w, r)
|
||||
return true
|
||||
case "/target-relabel-debug":
|
||||
|
|
|
@ -67,11 +67,11 @@ textarea { margin: 1em }
|
|||
{% code expr, err := metricsql.Parse(q) %}
|
||||
{% if err != nil %}
|
||||
"status": "error",
|
||||
"error": {%q fmt.Sprintf("Cannot parse query: %s", err) %}
|
||||
"error": {%q= fmt.Sprintf("Cannot parse query: %s", err) %}
|
||||
{% else %}
|
||||
{% code expr = metricsql.Optimize(expr) %}
|
||||
"status": "success",
|
||||
"expr": {%qz expr.AppendString(nil) %}
|
||||
"expr": {%qz= expr.AppendString(nil) %}
|
||||
{% endif %}
|
||||
}
|
||||
{% endfunc %}
|
||||
|
|
|
@ -145,7 +145,7 @@ func StreamExpandWithExprsJSONResponse(qw422016 *qt422016.Writer, q string) {
|
|||
//line app/vmselect/prometheus/expand-with-exprs.qtpl:68
|
||||
qw422016.N().S(`"status": "error","error":`)
|
||||
//line app/vmselect/prometheus/expand-with-exprs.qtpl:70
|
||||
qw422016.E().Q(fmt.Sprintf("Cannot parse query: %s", err))
|
||||
qw422016.N().Q(fmt.Sprintf("Cannot parse query: %s", err))
|
||||
//line app/vmselect/prometheus/expand-with-exprs.qtpl:71
|
||||
} else {
|
||||
//line app/vmselect/prometheus/expand-with-exprs.qtpl:72
|
||||
|
@ -154,7 +154,7 @@ func StreamExpandWithExprsJSONResponse(qw422016 *qt422016.Writer, q string) {
|
|||
//line app/vmselect/prometheus/expand-with-exprs.qtpl:72
|
||||
qw422016.N().S(`"status": "success","expr":`)
|
||||
//line app/vmselect/prometheus/expand-with-exprs.qtpl:74
|
||||
qw422016.E().QZ(expr.AppendString(nil))
|
||||
qw422016.N().QZ(expr.AppendString(nil))
|
||||
//line app/vmselect/prometheus/expand-with-exprs.qtpl:75
|
||||
}
|
||||
//line app/vmselect/prometheus/expand-with-exprs.qtpl:75
|
||||
|
|
|
@ -145,8 +145,8 @@ function submitRelabelDebugForm(e) {
|
|||
{% else %}
|
||||
"status": "success",
|
||||
{% if len(dss) > 0 %}
|
||||
"originalLabels": {%q= string(mustFormatLabels(dss[0].In)) %},
|
||||
"resultingLabels": {%q= string(mustFormatLabels(dss[len(dss)-1].Out)) %},
|
||||
"originalLabels": {%q= mustFormatLabels(dss[0].In) %},
|
||||
"resultingLabels": {%q= mustFormatLabels(dss[len(dss)-1].Out) %},
|
||||
{% endif %}
|
||||
"steps": [
|
||||
{% for i, ds := range dss %}
|
||||
|
|
|
@ -354,11 +354,11 @@ func StreamRelabelDebugStepsJSON(qw422016 *qt422016.Writer, targetURL, targetID
|
|||
//line lib/promrelabel/debug.qtpl:147
|
||||
qw422016.N().S(`"originalLabels":`)
|
||||
//line lib/promrelabel/debug.qtpl:148
|
||||
qw422016.N().Q(string(mustFormatLabels(dss[0].In)))
|
||||
qw422016.N().Q(mustFormatLabels(dss[0].In))
|
||||
//line lib/promrelabel/debug.qtpl:148
|
||||
qw422016.N().S(`,"resultingLabels":`)
|
||||
//line lib/promrelabel/debug.qtpl:149
|
||||
qw422016.N().Q(string(mustFormatLabels(dss[len(dss)-1].Out)))
|
||||
qw422016.N().Q(mustFormatLabels(dss[len(dss)-1].Out))
|
||||
//line lib/promrelabel/debug.qtpl:149
|
||||
qw422016.N().S(`,`)
|
||||
//line lib/promrelabel/debug.qtpl:150
|
||||
|
|
|
@ -4,6 +4,7 @@ import (
|
|||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/VictoriaMetrics/VictoriaMetrics/lib/httpserver"
|
||||
"github.com/VictoriaMetrics/VictoriaMetrics/lib/promrelabel"
|
||||
)
|
||||
|
||||
|
@ -15,10 +16,6 @@ func WriteMetricRelabelDebug(w http.ResponseWriter, r *http.Request) {
|
|||
format := r.FormValue("format")
|
||||
var err error
|
||||
|
||||
if format == "json" {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
}
|
||||
|
||||
if metric == "" && relabelConfigs == "" && targetID != "" {
|
||||
pcs, labels, ok := getMetricRelabelContextByTargetID(targetID)
|
||||
if !ok {
|
||||
|
@ -29,6 +26,10 @@ func WriteMetricRelabelDebug(w http.ResponseWriter, r *http.Request) {
|
|||
relabelConfigs = pcs.String()
|
||||
}
|
||||
}
|
||||
if format == "json" {
|
||||
httpserver.EnableCORS(w, r)
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
}
|
||||
promrelabel.WriteMetricRelabelDebug(w, targetID, metric, relabelConfigs, format, err)
|
||||
}
|
||||
|
||||
|
@ -50,5 +51,9 @@ func WriteTargetRelabelDebug(w http.ResponseWriter, r *http.Request) {
|
|||
relabelConfigs = pcs.String()
|
||||
}
|
||||
}
|
||||
if format == "json" {
|
||||
httpserver.EnableCORS(w, r)
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
}
|
||||
promrelabel.WriteTargetRelabelDebug(w, targetID, metric, relabelConfigs, format, err)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue