Change metering exported format to csv.

Signed-off-by: Rao Yunkun <yunkunrao@yunify.com>
This commit is contained in:
Rao Yunkun
2021-03-02 10:27:53 +08:00
parent e9073f0486
commit 5bddda51e7
7 changed files with 133 additions and 28 deletions

View File

@@ -19,8 +19,8 @@ package v1alpha3
import (
"bytes"
"context"
"encoding/json"
"fmt"
"github.com/jszwec/csvutil"
"io"
"strconv"
"strings"
@@ -388,7 +388,7 @@ func ExportMetrics(resp *restful.Response, metrics model.Metrics) {
}
}
resBytes, err := json.MarshalIndent(metrics, "", " ")
resBytes, err := csvutil.Marshal(metrics.Results)
if err != nil {
api.HandleBadRequest(resp, nil, err)
return