Compare commits

...

1 Commits

Author SHA1 Message Date
Zakhar Bessarab
c188d5cf08 lib/promrelabel/debug: make metric name easier to distinguish from labels
Previously, users could get confused in cases when metric name which is valid for MetricsQL but not valid for Prom was used in relabeling debug. See #8584 for example.

This adds highlight to a metric name and prints empty labels set in order to explicitly show metric name and set of labels.

Signed-off-by: Zakhar Bessarab <z.bessarab@victoriametrics.com>
2025-03-27 15:41:55 +04:00
2 changed files with 5 additions and 3 deletions

View File

@@ -185,7 +185,7 @@ function submitRelabelDebugForm(e) {
{% else %}
{%s metricName %}
{% endif %}
{% if len(labelsList) == 0 %}{% return %}{% endif %}
{% if len(labelsList) == 0 %}{}{% return %}{% endif %}
{% endif %}
{
{% for i, label := range labelsList %}
@@ -201,7 +201,7 @@ function submitRelabelDebugForm(e) {
{% func mustFormatLabels(s string) %}
{% code labels := promutil.MustNewLabelsFromString(s) %}
{%= labelsWithHighlight(labels, nil, "") %}
{%= labelsWithHighlight(labels, map[string]struct{}{"__name__": {}}, "") %}
{% endfunc %}
{% endstripspace %}

View File

@@ -464,6 +464,8 @@ func streamlabelsWithHighlight(qw422016 *qt422016.Writer, labels *promutil.Label
}
//line lib/promrelabel/debug.qtpl:188
if len(labelsList) == 0 {
//line lib/promrelabel/debug.qtpl:188
qw422016.N().S(`{}`)
//line lib/promrelabel/debug.qtpl:188
return
//line lib/promrelabel/debug.qtpl:188
@@ -547,7 +549,7 @@ func streammustFormatLabels(qw422016 *qt422016.Writer, s string) {
labels := promutil.MustNewLabelsFromString(s)
//line lib/promrelabel/debug.qtpl:204
streamlabelsWithHighlight(qw422016, labels, nil, "")
streamlabelsWithHighlight(qw422016, labels, map[string]struct{}{"__name__": {}}, "")
//line lib/promrelabel/debug.qtpl:205
}