From 060448c051013852d463bc13bfc5f0aa3696ac9c Mon Sep 17 00:00:00 2001 From: Mohamed Abukar Date: Tue, 9 Mar 2021 08:27:31 +0200 Subject: [PATCH] Add interface to read metrics Change-Id: Ic6644e8132b53da0f300690ae0b31f9df57846b5 Signed-off-by: Mohamed Abukar --- pkg/xapp/restapi.go | 15 +++++++++++++++ pkg/xapp/types.go | 7 ++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/pkg/xapp/restapi.go b/pkg/xapp/restapi.go index 40ad8d2..24755fa 100755 --- a/pkg/xapp/restapi.go +++ b/pkg/xapp/restapi.go @@ -156,6 +156,21 @@ func (r *Router) SendSymptomDataError(w http.ResponseWriter, req *http.Request, http.Error(w, message, http.StatusInternalServerError) } +func (r *Router) GetLocalMetrics(port int) (string, error) { + resp, err := http.Get(fmt.Sprintf("http://localhost:%d/ric/v1/metrics", port)) + if err != nil { + return "", err + } + defer resp.Body.Close() + + metrics, err := ioutil.ReadAll(resp.Body) + if err != nil { + return "", err + } + + return string(metrics), nil +} + func IsHealthProbeReady() bool { return healthReady } diff --git a/pkg/xapp/types.go b/pkg/xapp/types.go index fa88de7..b517ff3 100755 --- a/pkg/xapp/types.go +++ b/pkg/xapp/types.go @@ -83,9 +83,10 @@ type PortData struct { } type SymptomDataParams struct { - Timeout uint64 - FromTime uint64 - ToTime uint64 + Timeout uint64 + FromTime uint64 + ToTime uint64 + importantOnly bool } // @todo: read these from config or somewhere else -- 2.16.6