From: Mohamed Abukar Date: Tue, 9 Mar 2021 06:27:31 +0000 (+0200) Subject: Add interface to read metrics X-Git-Tag: v0.7.3^0 X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=060448c051013852d463bc13bfc5f0aa3696ac9c;p=ric-plt%2Fxapp-frame.git Add interface to read metrics Change-Id: Ic6644e8132b53da0f300690ae0b31f9df57846b5 Signed-off-by: Mohamed Abukar --- 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