Integate metering module and support metering data csv format export.
Signed-off-by: Rao Yunkun <yunkunrao@yunify.com>
This commit is contained in:
@@ -55,8 +55,7 @@ type tenantHandler struct {
|
||||
func newTenantHandler(factory informers.InformerFactory, k8sclient kubernetes.Interface, ksclient kubesphere.Interface,
|
||||
evtsClient events.Client, loggingClient logging.Client, auditingclient auditing.Client,
|
||||
am am.AccessManagementInterface, authorizer authorizer.Authorizer,
|
||||
monitoringclient monitoringclient.Interface,
|
||||
resourceGetter *resourcev1alpha3.ResourceGetter) *tenantHandler {
|
||||
monitoringclient monitoringclient.Interface, resourceGetter *resourcev1alpha3.ResourceGetter) *tenantHandler {
|
||||
|
||||
return &tenantHandler{
|
||||
tenant: tenant.New(factory, k8sclient, ksclient, evtsClient, loggingClient, auditingclient, am, authorizer, monitoringclient, resourceGetter),
|
||||
|
||||
@@ -64,25 +64,26 @@ func (h *tenantHandler) QueryMeteringsHierarchy(req *restful.Request, resp *rest
|
||||
|
||||
func (h *tenantHandler) HandlePriceInfoQuery(req *restful.Request, resp *restful.Response) {
|
||||
|
||||
var priceInfoResponse metering.PriceInfo
|
||||
priceInfoResponse.Init()
|
||||
var priceResponse metering.PriceResponse
|
||||
priceResponse.Init()
|
||||
|
||||
meterConfig, err := monitoring.LoadYaml()
|
||||
if err != nil {
|
||||
klog.Warning(err)
|
||||
resp.WriteAsJson(priceInfoResponse)
|
||||
resp.WriteAsJson(priceResponse)
|
||||
return
|
||||
}
|
||||
|
||||
priceInfo := meterConfig.GetPriceInfo()
|
||||
priceInfoResponse.Currency = priceInfo.CurrencyUnit
|
||||
priceInfoResponse.CpuPerCorePerHour = priceInfo.CpuPerCorePerHour
|
||||
priceInfoResponse.MemPerGigabytesPerHour = priceInfo.MemPerGigabytesPerHour
|
||||
priceInfoResponse.IngressNetworkTrafficPerGiagabytesPerHour = priceInfo.IngressNetworkTrafficPerGiagabytesPerHour
|
||||
priceInfoResponse.EgressNetworkTrafficPerGiagabytesPerHour = priceInfo.EgressNetworkTrafficPerGigabytesPerHour
|
||||
priceInfoResponse.PvcPerGigabytesPerHour = priceInfo.PvcPerGigabytesPerHour
|
||||
priceResponse.RetentionDay = meterConfig.RetentionDay
|
||||
priceResponse.Currency = priceInfo.CurrencyUnit
|
||||
priceResponse.CpuPerCorePerHour = priceInfo.CpuPerCorePerHour
|
||||
priceResponse.MemPerGigabytesPerHour = priceInfo.MemPerGigabytesPerHour
|
||||
priceResponse.IngressNetworkTrafficPerMegabytesPerHour = priceInfo.IngressNetworkTrafficPerMegabytesPerHour
|
||||
priceResponse.EgressNetworkTrafficPerMegabytesPerHour = priceInfo.EgressNetworkTrafficPerMegabytesPerHour
|
||||
priceResponse.PvcPerGigabytesPerHour = priceInfo.PvcPerGigabytesPerHour
|
||||
|
||||
resp.WriteAsJson(priceInfoResponse)
|
||||
resp.WriteAsJson(priceResponse)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@@ -334,6 +334,7 @@ func AddToContainer(c *restful.Container, factory informers.InformerFactory, k8s
|
||||
Param(ws.PathParameter("namespace", "Namespace name.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("metrics_filter", "The metric name filter consists of a regexp pattern. It specifies which metric data to return. For example, the following filter matches both workspace CPU usage and memory usage: `meter_pod_cpu_usage|meter_pod_memory_usage_wo_cache`.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("time", "A timestamp in Unix time format. Retrieve metric data at a single point in time. Defaults to now. Time and the combination of start, end, step are mutually exclusive.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("cluster", "Cluster name").DataType("string").Required(false)).
|
||||
Doc("get current metering hierarchies info in last one hour").
|
||||
Writes(metering.ResourceStatistic{}).
|
||||
Returns(http.StatusOK, api.StatusOK, metering.ResourceStatistic{}))
|
||||
|
||||
Reference in New Issue
Block a user