{% import "github.com/VictoriaMetrics/VictoriaMetrics/lib/storage" %}

{% stripspace %}
TSDBStatusResponse generates response for /api/v1/status/tsdb .
{% func TSDBStatusResponse(isPartial bool, status *storage.TSDBStatus) %}
{
	"status":"success",
	"isPartial":{% if isPartial %}true{% else %}false{% endif %},
	"data":{
		"seriesCountByMetricName":{%= tsdbStatusEntries(status.SeriesCountByMetricName) %},
		"labelValueCountByLabelName":{%= tsdbStatusEntries(status.LabelValueCountByLabelName) %},
		"seriesCountByLabelValuePair":{%= tsdbStatusEntries(status.SeriesCountByLabelValuePair) %}
	}
}
{% endfunc %}

{% func tsdbStatusEntries(a []storage.TopHeapEntry) %}
[
	{% for i, e := range a %}
		{
			"name":{%q= e.Name %},
			"value":{%d= int(e.Count) %}
		}
		{% if i+1 < len(a) %},{% endif %}
	{% endfor %}
]
{% endfunc %}

{% endstripspace %}