mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
32 lines
687 B
Text
32 lines
687 B
Text
{% import (
|
|
"github.com/VictoriaMetrics/VictoriaMetrics/lib/logstorage"
|
|
) %}
|
|
|
|
{% stripspace %}
|
|
|
|
// ValuesWithHitsJSON generates JSON from the given values.
|
|
{% func ValuesWithHitsJSON(values []logstorage.ValueWithHits) %}
|
|
{
|
|
"values":{%= valuesWithHitsJSONArray(values) %}
|
|
}
|
|
{% endfunc %}
|
|
|
|
{% func valuesWithHitsJSONArray(values []logstorage.ValueWithHits) %}
|
|
[
|
|
{% if len(values) > 0 %}
|
|
{%= valueWithHitsJSON(values[0]) %}
|
|
{% for _, v := range values[1:] %}
|
|
,{%= valueWithHitsJSON(v) %}
|
|
{% endfor %}
|
|
{% endif %}
|
|
]
|
|
{% endfunc %}
|
|
|
|
{% func valueWithHitsJSON(v logstorage.ValueWithHits) %}
|
|
{
|
|
"value":{%q= v.Value %},
|
|
"hits":{%dul= v.Hits %}
|
|
}
|
|
{% endfunc %}
|
|
|
|
{% endstripspace %}
|