mirror of
https://github.com/openfaas/faas.git
synced 2025-06-13 02:36:46 +00:00
Use namespace while filtering metric result
Signed-off-by: Vivek Singh <vivekkmr45@yahoo.in>
This commit is contained in:
parent
c0ba41ce33
commit
c9c2b39601
@ -88,7 +88,7 @@ func mixIn(functions *[]types.FunctionStatus, metrics *VectorQueryResponse) {
|
|||||||
for i, function := range *functions {
|
for i, function := range *functions {
|
||||||
for _, v := range metrics.Data.Result {
|
for _, v := range metrics.Data.Result {
|
||||||
|
|
||||||
if v.Metric.FunctionName == function.Name {
|
if v.Metric.FunctionName == fmt.Sprintf("%s.%s", function.Name, function.Namespace) {
|
||||||
metricValue := v.Value[1]
|
metricValue := v.Value[1]
|
||||||
switch metricValue.(type) {
|
switch metricValue.(type) {
|
||||||
case string:
|
case string:
|
||||||
|
@ -14,7 +14,7 @@ type FakePrometheusQueryFetcher struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (q FakePrometheusQueryFetcher) Fetch(query string) (*VectorQueryResponse, error) {
|
func (q FakePrometheusQueryFetcher) Fetch(query string) (*VectorQueryResponse, error) {
|
||||||
val := []byte(`{"status":"success","data":{"resultType":"vector","result":[{"metric":{"code":"200","function_name":"func_echoit"},"value":[1509267827.752,"1"]}]}}`)
|
val := []byte(`{"status":"success","data":{"resultType":"vector","result":[{"metric":{"code":"200","function_name":"func_echoit.openfaas-fn"},"value":[1509267827.752,"1"]}]}}`)
|
||||||
queryRes := VectorQueryResponse{}
|
queryRes := VectorQueryResponse{}
|
||||||
err := json.Unmarshal(val, &queryRes)
|
err := json.Unmarshal(val, &queryRes)
|
||||||
return &queryRes, err
|
return &queryRes, err
|
||||||
@ -84,8 +84,9 @@ func makeFunctionsHandler() http.HandlerFunc {
|
|||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
functions := []types.FunctionStatus{
|
functions := []types.FunctionStatus{
|
||||||
types.FunctionStatus{
|
types.FunctionStatus{
|
||||||
Name: "func_echoit",
|
Name: "func_echoit",
|
||||||
Replicas: 0,
|
Replicas: 0,
|
||||||
|
Namespace: "openfaas-fn",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
bytesOut, marshalErr := json.Marshal(&functions)
|
bytesOut, marshalErr := json.Marshal(&functions)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user