|
@@ -415,12 +415,14 @@ func (a *Accesses) OutofClusterCosts(w http.ResponseWriter, r *http.Request, ps
|
|
|
end := r.URL.Query().Get("end")
|
|
end := r.URL.Query().Get("end")
|
|
|
aggregator := r.URL.Query().Get("aggregator")
|
|
aggregator := r.URL.Query().Get("aggregator")
|
|
|
customAggregation := r.URL.Query().Get("customAggregation")
|
|
customAggregation := r.URL.Query().Get("customAggregation")
|
|
|
|
|
+ filterType := r.URL.Query().Get("filterType")
|
|
|
|
|
+ filterValue := r.URL.Query().Get("filterValue")
|
|
|
var data []*costAnalyzerCloud.OutOfClusterAllocation
|
|
var data []*costAnalyzerCloud.OutOfClusterAllocation
|
|
|
var err error
|
|
var err error
|
|
|
if customAggregation != "" {
|
|
if customAggregation != "" {
|
|
|
- data, err = a.Cloud.ExternalAllocations(start, end, customAggregation)
|
|
|
|
|
|
|
+ data, err = a.Cloud.ExternalAllocations(start, end, customAggregation, filterType, filterValue)
|
|
|
} else {
|
|
} else {
|
|
|
- data, err = a.Cloud.ExternalAllocations(start, end, "kubernetes_"+aggregator)
|
|
|
|
|
|
|
+ data, err = a.Cloud.ExternalAllocations(start, end, "kubernetes_"+aggregator, "kubernetes_"+filterType, filterValue)
|
|
|
}
|
|
}
|
|
|
w.Write(WrapData(data, err))
|
|
w.Write(WrapData(data, err))
|
|
|
}
|
|
}
|
|
@@ -444,7 +446,11 @@ func (a *Accesses) OutOfClusterCostsWithCache(w http.ResponseWriter, r *http.Req
|
|
|
// then recompute and cache the requested data
|
|
// then recompute and cache the requested data
|
|
|
clearCache := r.URL.Query().Get("clearCache") == "true"
|
|
clearCache := r.URL.Query().Get("clearCache") == "true"
|
|
|
|
|
|
|
|
|
|
+ filterType := r.URL.Query().Get("filterType")
|
|
|
|
|
+ filterValue := r.URL.Query().Get("filterValue")
|
|
|
|
|
+
|
|
|
aggregation := "kubernetes_" + kubernetesAggregation
|
|
aggregation := "kubernetes_" + kubernetesAggregation
|
|
|
|
|
+ filterType = "kubernetes_" + filterType
|
|
|
if customAggregation != "" {
|
|
if customAggregation != "" {
|
|
|
aggregation = customAggregation
|
|
aggregation = customAggregation
|
|
|
}
|
|
}
|
|
@@ -456,7 +462,7 @@ func (a *Accesses) OutOfClusterCostsWithCache(w http.ResponseWriter, r *http.Req
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// attempt to retrieve cost data from cache
|
|
// attempt to retrieve cost data from cache
|
|
|
- key := fmt.Sprintf(`%s:%s:%s`, start, end, aggregation)
|
|
|
|
|
|
|
+ key := fmt.Sprintf(`%s:%s:%s:%s:%s`, start, end, aggregation, filterType, filterValue)
|
|
|
if value, found := a.OutOfClusterCache.Get(key); found && !disableCache {
|
|
if value, found := a.OutOfClusterCache.Get(key); found && !disableCache {
|
|
|
if data, ok := value.([]*costAnalyzerCloud.OutOfClusterAllocation); ok {
|
|
if data, ok := value.([]*costAnalyzerCloud.OutOfClusterAllocation); ok {
|
|
|
w.Write(WrapDataWithMessage(data, nil, fmt.Sprintf("out of cluser cache hit: %s", key)))
|
|
w.Write(WrapDataWithMessage(data, nil, fmt.Sprintf("out of cluser cache hit: %s", key)))
|
|
@@ -465,7 +471,7 @@ func (a *Accesses) OutOfClusterCostsWithCache(w http.ResponseWriter, r *http.Req
|
|
|
klog.Errorf("caching error: failed to type cast data: %s", key)
|
|
klog.Errorf("caching error: failed to type cast data: %s", key)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- data, err := a.Cloud.ExternalAllocations(start, end, aggregation)
|
|
|
|
|
|
|
+ data, err := a.Cloud.ExternalAllocations(start, end, aggregation, filterType, filterValue)
|
|
|
if err == nil {
|
|
if err == nil {
|
|
|
a.OutOfClusterCache.Set(key, data, cache.DefaultExpiration)
|
|
a.OutOfClusterCache.Set(key, data, cache.DefaultExpiration)
|
|
|
}
|
|
}
|