app/vmselect: properly generate response for /api/v1/series

The response has been broken in 7d5d33fd71
This commit is contained in:
Aliaksandr Valialkin 2022-07-06 01:33:35 +03:00
parent b4489028f3
commit cdd89d9cc2
No known key found for this signature in database
GPG key ID: A72BEC6CD3D0DED1
3 changed files with 3 additions and 3 deletions

View file

@ -1217,7 +1217,7 @@ func SearchMetricNames(qt *querytracer.Tracer, denyPartialResponse bool, sq *sto
return nil, isPartial, fmt.Errorf("cannot fetch metric names from vmstorage nodes: %w", err) return nil, isPartial, fmt.Errorf("cannot fetch metric names from vmstorage nodes: %w", err)
} }
metricNames := make([]string, len(metricNamesMap)) metricNames := make([]string, 0, len(metricNamesMap))
for metricName := range metricNamesMap { for metricName := range metricNamesMap {
metricNames = append(metricNames, metricName) metricNames = append(metricNames, metricName)
} }

View file

@ -15,7 +15,7 @@ See https://prometheus.io/docs/prometheus/latest/querying/api/#finding-series-by
{% for i, metricName := range metricNames %} {% for i, metricName := range metricNames %}
{% code err := mn.UnmarshalString(metricName) %} {% code err := mn.UnmarshalString(metricName) %}
{% if err != nil %} {% if err != nil %}
{%q= err.Error() %} {%q= "cannot unmarshal metricName: " + err.Error() %}
{% else %} {% else %}
{%= metricNameObject(&mn) %} {%= metricNameObject(&mn) %}
{% endif %} {% endif %}

View file

@ -52,7 +52,7 @@ func StreamSeriesResponse(qw422016 *qt422016.Writer, isPartial bool, metricNames
//line app/vmselect/prometheus/series_response.qtpl:17 //line app/vmselect/prometheus/series_response.qtpl:17
if err != nil { if err != nil {
//line app/vmselect/prometheus/series_response.qtpl:18 //line app/vmselect/prometheus/series_response.qtpl:18
qw422016.N().Q(err.Error()) qw422016.N().Q("cannot unmarshal metricName: " + err.Error())
//line app/vmselect/prometheus/series_response.qtpl:19 //line app/vmselect/prometheus/series_response.qtpl:19
} else { } else {
//line app/vmselect/prometheus/series_response.qtpl:20 //line app/vmselect/prometheus/series_response.qtpl:20