Expose Prometheus metrics for monitoring 41/122541/6
authorputhuparambil.aditya <aditya.puthuparambil@bell.ca>
Fri, 9 Jul 2021 11:51:10 +0000 (12:51 +0100)
committerputhuparambil.aditya <aditya.puthuparambil@bell.ca>
Wed, 14 Jul 2021 14:54:48 +0000 (15:54 +0100)
Issue-ID: CPS-492
Signed-off-by: puthuparambil.aditya <aditya.puthuparambil@bell.ca>
Change-Id: I264066bd543daf2a45f2ec9a6b8cdf8012927828

cps-application/pom.xml
cps-application/src/main/resources/application.yml
csit/plans/default/setup.sh
csit/tests/actuator/actuator.robot
csit/tests/cps-admin/cps-admin.robot
csit/tests/cps-data/cps-data.robot
docker-compose/docker-compose.yml

index f656215..d8b626a 100755 (executable)
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-actuator</artifactId>
         </dependency>
+        <dependency>
+            <groupId>io.micrometer</groupId>
+            <artifactId>micrometer-registry-prometheus</artifactId>
+        </dependency>
         <dependency>
             <groupId>org.springframework.cloud</groupId>
             <artifactId>spring-cloud-starter-sleuth</artifactId>
index 4f3072e..9d52164 100644 (file)
@@ -73,26 +73,26 @@ notification:
 \r
 security:\r
     # comma-separated uri patterns which do not require authorization\r
-    permit-uri: /manage/health/**,/manage/info,/swagger-ui/**,/swagger-resources/**,/v3/api-docs\r
+    permit-uri: /manage/**,/swagger-ui/**,/swagger-resources/**,/v3/api-docs\r
     auth:\r
         username: ${CPS_USERNAME}\r
         password: ${CPS_PASSWORD}\r
 \r
 # Actuator\r
 management:\r
+    server:\r
+        port: 8081\r
     endpoints:\r
         web:\r
             base-path: /manage\r
-        exposure:\r
-            include: info,health,loggers\r
+            exposure:\r
+                include: info,health,loggers,prometheus\r
     endpoint:\r
         health:\r
             show-details: always\r
             # kubernetes probes: liveness and readiness\r
             probes:\r
                 enabled: true\r
-        loggers:\r
-            enabled: true\r
 \r
 logging:\r
     level:\r
index 4d5d1c8..cf29b53 100755 (executable)
@@ -17,6 +17,7 @@
 # Modifications copyright (c) 2017 AT&T Intellectual Property
 # Modifications copyright (c) 2020-2021 Samsung Electronics Co., Ltd.
 # Modifications Copyright (C) 2021 Pantheon.tech
+# Modifications Copyright (C) 2021 Bell Canada.
 #
 # Branched from ccsdk/distribution to this repository Feb 23, 2021
 #
@@ -66,8 +67,11 @@ if [ "$TIME" -gt "$TIME_OUT" ]; then
 fi
 
 # The CPS host according to docker-compose.yml
-CPS_HOST="http://localhost:8883"
+CPS_HOST="localhost"
+CPS_PORT="8883"
+
+MANAGEMENT_PORT="8887"
 
 # Pass variables required for Robot test suites in ROBOT_VARIABLES
-ROBOT_VARIABLES="-v CPS_HOST:$CPS_HOST -v DATADIR:$WORKSPACE/data"
+ROBOT_VARIABLES="-v CPS_HOST:$CPS_HOST -v CPS_PORT:$CPS_PORT -v MANAGEMENT_PORT:$MANAGEMENT_PORT -v DATADIR:$WORKSPACE/data"
 
index 3a0493d..55ff40e 100644 (file)
@@ -1,5 +1,6 @@
 # ============LICENSE_START=======================================================
 # Copyright (c) 2021 Pantheon.tech.
+# Modifications Copyright (c) 2021 Bell Canada.
 # ================================================================================
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -22,16 +23,17 @@ Documentation         CPS - Actuator endpoints
 Library               Collections
 Library               RequestsLibrary
 
-Suite Setup           Create Session    CPS_HOST    ${CPS_HOST}
+Suite Setup           Create Session    MANAGEMENT_URL    http://${CPS_HOST}:${MANAGEMENT_PORT}/manage
 
 *** Variables ***
 
 
 *** Test Cases ***
 Test Liveness Probe Endpoint
-    ${response}=      GET On Session    CPS_HOST     /manage/health/liveness     expected_status=200
+    ${response}=      GET On Session    MANAGEMENT_URL     health/liveness     expected_status=200
     Should Be Equal As Strings          ${response.json()['status']}      UP
 
 Test Readiness Probe Endpoint
-    ${response}=      GET On Session    CPS_HOST     /manage/health/readiness    expected_status=200
+    ${response}=      GET On Session    MANAGEMENT_URL     health/readiness    expected_status=200
     Should Be Equal As Strings          ${response.json()['status']}      UP
+
index 7e944ec..43a46d3 100644 (file)
@@ -23,7 +23,7 @@ Library               Collections
 Library               OperatingSystem
 Library               RequestsLibrary
 
-Suite Setup           Create Session      CPS_HOST    ${CPS_HOST}
+Suite Setup           Create Session      CPS_URL    http://${CPS_HOST}:${CPS_PORT}
 
 *** Variables ***
 
@@ -40,7 +40,7 @@ Create Dataspace
     ${uri}=             Set Variable        ${basePath}/v1/dataspaces
     ${params}=          Create Dictionary   dataspace-name=${dataspaceName}
     ${headers}=         Create Dictionary   Authorization=${auth}
-    ${response}=        POST On Session     CPS_HOST   ${uri}   params=${params}   headers=${headers}
+    ${response}=        POST On Session     CPS_URL   ${uri}   params=${params}   headers=${headers}
     Should Be Equal As Strings              ${response.status_code}   201
 
 Create Schema Set from YANG file
@@ -50,7 +50,7 @@ Create Schema Set from YANG file
     ${fileTuple}=       Create List         test.yang   ${fileData}   application/zip
     &{files}=           Create Dictionary   file=${fileTuple}
     ${headers}=         Create Dictionary   Authorization=${auth}
-    ${response}=        POST On Session     CPS_HOST   ${uri}   files=${files}   params=${params}   headers=${headers}
+    ${response}=        POST On Session     CPS_URL   ${uri}   files=${files}   params=${params}   headers=${headers}
     Should Be Equal As Strings              ${response.status_code}   201
 
 Create Schema Set from ZIP file
@@ -60,13 +60,13 @@ Create Schema Set from ZIP file
     ${fileTuple}=       Create List         test.zip   ${fileData}   application/zip
     &{files}=           Create Dictionary   file=${fileTuple}
     ${headers}=         Create Dictionary   Authorization=${auth}
-    ${response}=        POST On Session     CPS_HOST   ${uri}   files=${files}   params=${params}   headers=${headers}
+    ${response}=        POST On Session     CPS_URL   ${uri}   files=${files}   params=${params}   headers=${headers}
     Should Be Equal As Strings              ${response.status_code}   201
 
 Get Schema Set info
     ${uri}=             Set Variable        ${basePath}/v1/dataspaces/${dataspaceName}/schema-sets/${schemaSetName}
     ${headers}=         Create Dictionary   Authorization=${auth}
-    ${response}=        Get On Session      CPS_HOST   ${uri}   headers=${headers}   expected_status=200
+    ${response}=        Get On Session      CPS_URL   ${uri}   headers=${headers}   expected_status=200
     ${responseJson}=    Set Variable        ${response.json()}
     Should Be Equal As Strings              ${responseJson['name']}   ${schemaSetName}
     Should Be Equal As Strings              ${responseJson['dataspaceName']}   ${dataspaceName}
@@ -75,13 +75,13 @@ Create Anchor
     ${uri}=             Set Variable        ${basePath}/v1/dataspaces/${dataspaceName}/anchors
     ${params}=          Create Dictionary   schema-set-name=${schemaSetName}   anchor-name=${anchorName}
     ${headers}=         Create Dictionary   Authorization=${auth}
-    ${response}=        POST On Session     CPS_HOST   ${uri}   params=${params}   headers=${headers}
+    ${response}=        POST On Session     CPS_URL   ${uri}   params=${params}   headers=${headers}
     Should Be Equal As Strings              ${response.status_code}   201
 
 Get CPS RAN Schema Set info
     ${uri}=              Set Variable       ${basePath}/v1/dataspaces/${ranDataspaceName}/schema-sets/${ranSchemaSetName}
     ${headers}=          Create Dictionary  Authorization=${auth}
-    ${response}=         Get On Session     CPS_HOST   ${uri}   headers=${headers}   expected_status=200
+    ${response}=         Get On Session     CPS_URL   ${uri}   headers=${headers}   expected_status=200
     ${responseJson}=     Set Variable       ${response.json()}
     Should Be Equal As Strings              ${responseJson['name']}   ${ranSchemaSetName}
     Should Be Equal As Strings              ${responseJson['dataspaceName']}   ${ranDataspaceName}
index 9fd8451..e7334ae 100644 (file)
@@ -23,7 +23,7 @@ Library               Collections
 Library               OperatingSystem
 Library               RequestsLibrary
 
-Suite Setup           Create Session      CPS_HOST    ${CPS_HOST}
+Suite Setup           Create Session      CPS_URL    http://${CPS_HOST}:${CPS_PORT}
 
 *** Variables ***
 
@@ -37,14 +37,14 @@ Create Data Node
     ${uri}=             Set Variable        ${basePath}/v1/dataspaces/${dataspaceName}/anchors/${anchorName}/nodes
     ${headers}          Create Dictionary   Content-Type=application/json   Authorization=${auth}
     ${jsonData}=        Get Binary File     ${DATADIR}${/}test-tree.json
-    ${response}=        POST On Session     CPS_HOST   ${uri}   headers=${headers}   data=${jsonData}
+    ${response}=        POST On Session     CPS_URL   ${uri}   headers=${headers}   data=${jsonData}
     Should Be Equal As Strings              ${response.status_code}   201
 
 Get Data Node by XPath
     ${uri}=             Set Variable        ${basePath}/v1/dataspaces/${dataspaceName}/anchors/${anchorName}/node
     ${params}=          Create Dictionary   xpath=/test-tree/branch[@name='Left']/nest
     ${headers}=         Create Dictionary   Authorization=${auth}
-    ${response}=        Get On Session      CPS_HOST   ${uri}   params=${params}   headers=${headers}   expected_status=200
+    ${response}=        Get On Session      CPS_URL   ${uri}   params=${params}   headers=${headers}   expected_status=200
     ${responseJson}=    Set Variable        ${response.json()}
     Should Be Equal As Strings              ${responseJson['name']}   Small
 
index 51bb162..f8ca81b 100755 (executable)
@@ -24,6 +24,7 @@ services:
   #  image: ${DOCKER_REPO:-nexus3.onap.org:10003}/onap/cps-service:${VERSION:-latest}
   #  ports:
   #    - "8881:8080"
+  #    - "8887:8081"
   #  environment:
   #    CPS_USERNAME: ${CPS_USERNAME:-cpsuser}
   #    CPS_PASSWORD: ${CPS_PASSWORD:-cpsr0cks!}
@@ -41,6 +42,7 @@ services:
   #  image: ${DOCKER_REPO:-nexus3.onap.org:10003}/onap/cps-ncmp:${VERSION:-latest}
   #  ports:
   #    - "8882:8080"
+  #    - "8887:8081"
   #  environment:
   #    CPS_USERNAME: ${CPS_USERNAME:-cpsuser}
   #    CPS_PASSWORD: ${CPS_PASSWORD:-cpsr0cks!}
@@ -58,6 +60,7 @@ services:
     image: ${DOCKER_REPO:-nexus3.onap.org:10003}/onap/cps-and-ncmp:${VERSION:-latest}
     ports:
       - "8883:8080"
+      - "8887:8081"
     environment:
       CPS_USERNAME: ${CPS_USERNAME:-cpsuser}
       CPS_PASSWORD: ${CPS_PASSWORD:-cpsr0cks!}