mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-20 23:46:23 +01:00
2ac5f00d98
Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/891 This commit also adds `"isPartial":{true|false}` field to `/api/v1/*` responses. `"isPartial":true` is set when the response is based on a partial data because some of vmstorage nodes weren't available during query processing.
35 lines
855 B
Plaintext
35 lines
855 B
Plaintext
{% 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
|
|
{% func QueryRangeResponse(isPartial bool, rs []netstorage.Result) %}
|
|
{
|
|
"status":"success",
|
|
"isPartial":{% if isPartial %}true{% else %}false{% endif %},
|
|
"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 %}
|