Add interface to read metrics 40/5740/2 v0.7.3
authorMohamed Abukar <abukar.mohamed@nokia.com>
Tue, 9 Mar 2021 06:27:31 +0000 (08:27 +0200)
committerMohamed Abukar <abukar.mohamed@nokia.com>
Tue, 9 Mar 2021 06:41:08 +0000 (08:41 +0200)
Change-Id: Ic6644e8132b53da0f300690ae0b31f9df57846b5
Signed-off-by: Mohamed Abukar <abukar.mohamed@nokia.com>
pkg/xapp/restapi.go
pkg/xapp/types.go

index 40ad8d2..24755fa 100755 (executable)
@@ -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
 }
index fa88de7..b517ff3 100755 (executable)
@@ -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