VictoriaMetrics/app/vmselect/prometheus/series_response.qtpl

39 lines
982 B
Text
Raw Normal View History

2019-05-22 21:16:55 +00:00
{% import (
"github.com/valyala/quicktemplate"
"github.com/VictoriaMetrics/VictoriaMetrics/lib/querytracer"
2019-05-22 21:16:55 +00:00
) %}
{% stripspace %}
SeriesResponse generates response for /api/v1/series.
See https://prometheus.io/docs/prometheus/latest/querying/api/#finding-series-by-label-matchers
{% func SeriesResponse(isPartial bool, resultsCh <-chan *quicktemplate.ByteBuffer, qt *querytracer.Tracer, qtDone func()) %}
2019-05-22 21:16:55 +00:00
{
{% code seriesCount := 0 %}
2019-05-22 21:16:55 +00:00
"status":"success",
"isPartial":{% if isPartial %}true{% else %}false{% endif %},
2019-05-22 21:16:55 +00:00
"data":[
{% code bb, ok := <-resultsCh %}
{% if ok %}
{%z= bb.B %}
{% code
quicktemplate.ReleaseByteBuffer(bb)
seriesCount++
%}
2019-05-22 21:16:55 +00:00
{% for bb := range resultsCh %}
,{%z= bb.B %}
{% code
quicktemplate.ReleaseByteBuffer(bb)
seriesCount++
%}
2019-05-22 21:16:55 +00:00
{% endfor %}
{% endif %}
]
{% code
qt.Printf("generate response: series=%d", seriesCount)
qtDone()
%}
{%= dumpQueryTrace(qt) %}
2019-05-22 21:16:55 +00:00
}
{% endfunc %}
{% endstripspace %}