2019-05-22 23:16:55 +02:00
|
|
|
{% import (
|
|
|
|
"github.com/VictoriaMetrics/VictoriaMetrics/app/vmselect/netstorage"
|
|
|
|
) %}
|
|
|
|
|
|
|
|
{% stripspace %}
|
|
|
|
QueryRangeResponse generates response for /api/v1/query_range.
|
|
|
|
See https://prometheus.io/docs/prometheus/latest/querying/api/#range-queries
|
2020-11-14 11:36:21 +01:00
|
|
|
{% func QueryRangeResponse(isPartial bool, rs []netstorage.Result) %}
|
2019-05-22 23:16:55 +02:00
|
|
|
{
|
|
|
|
"status":"success",
|
2020-11-14 11:36:21 +01:00
|
|
|
"isPartial":{% if isPartial %}true{% else %}false{% endif %},
|
2019-05-22 23:16:55 +02:00
|
|
|
"data":{
|
|
|
|
"resultType":"matrix",
|
|
|
|
"result":[
|
|
|
|
{% if len(rs) > 0 %}
|
|
|
|
{%= queryRangeLine(&rs[0]) %}
|
|
|
|
{% code rs = rs[1:] %}
|
|
|
|
{% for i := range rs %}
|
|
|
|
,{%= queryRangeLine(&rs[i]) %}
|
|
|
|
{% endfor %}
|
|
|
|
{% endif %}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
{% endfunc %}
|
|
|
|
|
|
|
|
{% func queryRangeLine(r *netstorage.Result) %}
|
|
|
|
{
|
|
|
|
"metric": {%= metricNameObject(&r.MetricName) %},
|
|
|
|
"values": {%= valuesWithTimestamps(r.Values, r.Timestamps) %}
|
|
|
|
}
|
|
|
|
{% endfunc %}
|
|
|
|
|
|
|
|
{% endstripspace %}
|