diff --git a/gateway/metrics/add_metrics.go b/gateway/metrics/add_metrics.go index 4490cd2ae..2171db239 100644 --- a/gateway/metrics/add_metrics.go +++ b/gateway/metrics/add_metrics.go @@ -88,7 +88,7 @@ func mixIn(functions *[]types.FunctionStatus, metrics *VectorQueryResponse) { for i, function := range *functions { 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] switch metricValue.(type) { case string: diff --git a/gateway/metrics/add_metrics_test.go b/gateway/metrics/add_metrics_test.go index 3389565f9..a3ebff567 100644 --- a/gateway/metrics/add_metrics_test.go +++ b/gateway/metrics/add_metrics_test.go @@ -14,7 +14,7 @@ type FakePrometheusQueryFetcher struct { } 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{} err := json.Unmarshal(val, &queryRes) return &queryRes, err @@ -84,8 +84,9 @@ func makeFunctionsHandler() http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { functions := []types.FunctionStatus{ types.FunctionStatus{ - Name: "func_echoit", - Replicas: 0, + Name: "func_echoit", + Replicas: 0, + Namespace: "openfaas-fn", }, } bytesOut, marshalErr := json.Marshal(&functions)