Commit fb57e05c authored by Sergio Gonzalez Diaz's avatar Sergio Gonzalez Diaz
Browse files

Clean comments and update monitoringservice.yaml

parent a268a8c8
Loading
Loading
Loading
Loading
+25 −14
Original line number Diff line number Diff line
@@ -29,19 +29,23 @@ spec:
      terminationGracePeriodSeconds: 5
      restartPolicy: Always
      containers:
      - name: influxdb
        image: influxdb:1.8
      - name: metricsdb
        image: questdb/questdb
        ports:
        - containerPort: 8086
        envFrom:
          - secretRef:
              name: influxdb-secrets
        - containerPort: 9000
        - containerPort: 9009
        - containerPort: 9003
        env:
        - name: QDB_CAIRO_COMMIT_LAG
          value: "1000"
        - name: QDB_CAIRO_MAX_UNCOMMITTED_ROWS
          value: "100000"
        readinessProbe:
          exec:
            command: ["curl", "-XGET", "localhost:8086/health"]
            command: ["curl", "-XGET", "localhost:9000"]
        livenessProbe:
          exec:
            command: ["curl", "-XGET", "localhost:8086/health"]
            command: ["curl", "-XGET", "localhost:9003/metrics"]
        resources:
          requests:
            cpu: 250m
@@ -54,9 +58,15 @@ spec:
        imagePullPolicy: Always
        ports:
        - containerPort: 7070
        envFrom:
          - secretRef:
              name: monitoring-secrets
        env:
        - name: METRICSDB_HOSTNAME
          value: "localhost"
        - name: METRICSDB_ILP_PORT
          value: "9009"
        - name: METRICSDB_REST_PORT
          value: "9000"
        - name: METRICSDB_TABLE
          value: "monitoring"
        readinessProbe:
          exec:
            command: ["/bin/grpc_health_probe", "-addr=:7070"]
@@ -70,6 +80,7 @@ spec:
          limits:
            cpu: 700m
            memory: 1024Mi

---
apiVersion: v1
kind: Service
@@ -84,7 +95,7 @@ spec:
    protocol: TCP
    port: 7070
    targetPort: 7070
  - name: influxdb
  - name: questdb
    protocol: TCP
    port: 8086
    targetPort: 8086
    port: 9000
    targetPort: 9000
 No newline at end of file
+0 −5
Original line number Diff line number Diff line
@@ -49,17 +49,13 @@ unit test monitoring:
  before_script:
    - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
    - if docker network list | grep teraflowbridge; then echo "teraflowbridge is already created"; else docker network create -d bridge teraflowbridge; fi
    # - if docker container ls | grep influxdb; then docker rm -f influxdb; else echo "influxdb image is not in the system"; fi
    - if docker container ls | grep questdb; then docker rm -f questdb; else echo "questdb image is not in the system"; fi
    - if docker container ls | grep $IMAGE_NAME; then docker rm -f $IMAGE_NAME; else echo "$IMAGE_NAME image is not in the system"; fi
  script:
    - docker pull "$CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG"
    # - docker pull "influxdb:1.8"
    - docker pull questdb/questdb
    # - docker run --name influxdb -d -p 8086:8086 -e INFLUXDB_DB=$INFLUXDB_DATABASE -e INFLUXDB_ADMIN_USER=$INFLUXDB_USER -e INFLUXDB_ADMIN_PASSWORD=$INFLUXDB_PASSWORD -e INFLUXDB_HTTP_AUTH_ENABLED=True --network=teraflowbridge influxdb:1.8
    - docker run --name questdb -d -p 9000:9000  -p 9009:9009  -p 8812:8812  -p 9003:9003  -e QDB_CAIRO_COMMIT_LAG=1000 -e QDB_CAIRO_MAX_UNCOMMITTED_ROWS=100000 --network=teraflowbridge --rm questdb/questdb
    - sleep 10
    # - docker run --name $IMAGE_NAME -d -p 7070:7070 --env INFLUXDB_USER=$INFLUXDB_USER --env INFLUXDB_PASSWORD=$INFLUXDB_PASSWORD --env INFLUXDB_DATABASE=$INFLUXDB_DATABASE --env INFLUXDB_HOSTNAME=influxdb --env INFLUXDB_PORT=8086 -v "$PWD/src/$IMAGE_NAME/tests:/opt/results" --network=teraflowbridge $CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG
    - docker run --name $IMAGE_NAME -d -p 7070:7070 --env METRICSDB_HOSTNAME=localhost --env METRICSDB_ILP_PORT=9009 --env METRICSDB_REST_PORT=9000 --env METRICSDB_TABLE=monitoring -v "$PWD/src/$IMAGE_NAME/tests:/opt/results" --network=teraflowbridge $CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG
    - sleep 30
    - docker ps -a
@@ -69,7 +65,6 @@ unit test monitoring:
  coverage: '/TOTAL\s+\d+\s+\d+\s+(\d+%)/'
  after_script:
    - docker rm -f $IMAGE_NAME
    # - docker rm -f  influxdb
    - docker rm -f  questdb
    - docker network rm teraflowbridge
  rules:
+1 −9
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@ from common.proto.monitoring_pb2 import AlarmResponse, AlarmDescriptor, AlarmIDL
    BundleKpiDescriptor, MonitorKpiRequest, Kpi
from common.rpc_method_wrapper.ServiceExceptions import ServiceException

from monitoring.service import SqliteTools, MetricsDBTools#, InfluxTools
from monitoring.service import SqliteTools, MetricsDBTools
from device.client.DeviceClient import DeviceClient

from prometheus_client import Counter, Summary
@@ -38,11 +38,6 @@ MONITORING_GETINSTANTKPI_REQUEST_TIME = Summary(
    'monitoring_getinstantkpi_processing_seconds', 'Time spent processing monitoring instant kpi request')
MONITORING_INCLUDEKPI_COUNTER = Counter('monitoring_includekpi_counter', 'Monitoring include kpi request counter')

# INFLUXDB_HOSTNAME = os.environ.get("INFLUXDB_HOSTNAME")
# INFLUXDB_USER = os.environ.get("INFLUXDB_USER")
# INFLUXDB_PASSWORD = os.environ.get("INFLUXDB_PASSWORD")
# INFLUXDB_DATABASE = os.environ.get("INFLUXDB_DATABASE")

METRICSDB_HOSTNAME = os.environ.get("METRICSDB_HOSTNAME")
METRICSDB_ILP_PORT = os.environ.get("METRICSDB_ILP_PORT")
METRICSDB_REST_PORT = os.environ.get("METRICSDB_REST_PORT")
@@ -61,8 +56,6 @@ class MonitoringServiceServicerImpl(MonitoringServiceServicer):
        self.sql_db = SqliteTools.SQLite('monitoring.db')
        self.deviceClient = DeviceClient(host=DEVICESERVICE_SERVICE_HOST, port=DEVICESERVICE_SERVICE_PORT_GRPC)  # instantiate the client

        # Create influx_db client
        # self.influx_db = InfluxTools.Influx(INFLUXDB_HOSTNAME,"8086",INFLUXDB_USER,INFLUXDB_PASSWORD,INFLUXDB_DATABASE)
        # Create metrics_db client
        self.metrics_db = MetricsDBTools.MetricsDB(METRICSDB_HOSTNAME,METRICSDB_ILP_PORT,METRICSDB_REST_PORT,METRICSDB_TABLE)

@@ -196,7 +189,6 @@ class MonitoringServiceServicerImpl(MonitoringServiceServicer):
            kpi_value       = getattr(request.kpi_value, request.kpi_value.WhichOneof('value'))

            # Build the structure to be included as point in the MetricsDB
            # self.influx_db.write_KPI(time_stamp,kpiId,kpiSampleType,deviceId,endpointId,serviceId,kpi_value)
            self.metrics_db.write_KPI(time_stamp,kpiId,kpiSampleType,deviceId,endpointId,serviceId,kpi_value)

            #self.influx_db.read_KPI_points()
+1 −15
Original line number Diff line number Diff line
@@ -36,7 +36,7 @@ from device.service.drivers import DRIVERS
from monitoring.client.MonitoringClient import MonitoringClient
from common.proto import context_pb2, monitoring_pb2
from common.proto.kpi_sample_types_pb2 import KpiSampleType
from monitoring.service import SqliteTools, MetricsDBTools #, InfluxTools
from monitoring.service import SqliteTools, MetricsDBTools
from monitoring.service.MonitoringService import MonitoringService
from monitoring.service.EventTools import EventsDeviceCollector
from monitoring.tests.Messages import create_kpi_request, include_kpi_request, kpi, kpi_id, monitor_kpi_request
@@ -64,11 +64,6 @@ MONITORING_SERVICE_PORT = 10000 + get_service_port_grpc(ServiceNameEnum.MONITORI
os.environ[get_env_var_name(ServiceNameEnum.MONITORING, ENVVAR_SUFIX_SERVICE_HOST     )] = str(LOCAL_HOST)
os.environ[get_env_var_name(ServiceNameEnum.MONITORING, ENVVAR_SUFIX_SERVICE_PORT_GRPC)] = str(MONITORING_SERVICE_PORT)

# INFLUXDB_HOSTNAME   = os.environ.get("INFLUXDB_HOSTNAME")
# INFLUXDB_PORT       = os.environ.get("INFLUXDB_PORT")
# INFLUXDB_USER       = os.environ.get("INFLUXDB_USER")
# INFLUXDB_PASSWORD   = os.environ.get("INFLUXDB_PASSWORD")
# INFLUXDB_DATABASE   = os.environ.get("INFLUXDB_DATABASE")
METRICSDB_HOSTNAME = os.environ.get("METRICSDB_HOSTNAME")
METRICSDB_ILP_PORT = os.environ.get("METRICSDB_ILP_PORT")
METRICSDB_REST_PORT = os.environ.get("METRICSDB_REST_PORT")
@@ -154,11 +149,6 @@ def sql_db():
    _sql_db = SqliteTools.SQLite('monitoring.db')
    return _sql_db

# @pytest.fixture(scope='session')
# def influx_db():
#     _influx_db = InfluxTools.Influx(
#         INFLUXDB_HOSTNAME, INFLUXDB_PORT, INFLUXDB_USER, INFLUXDB_PASSWORD, INFLUXDB_DATABASE)
#     return _influx_db
@pytest.fixture(scope='session')
def metrics_db():
    _metrics_db = MetricsDBTools.MetricsDB(
@@ -312,14 +302,10 @@ def test_sqlitedb_tools_delete_kpid_id(sql_db): # pylint: disable=redefined-oute
    assert response


# def test_influxdb_tools_write_kpi(influx_db): # pylint: disable=redefined-outer-name
#     LOGGER.warning('test_influxdb_tools_write_kpi begin')
def test_metrics_db_tools_write_kpi(metrics_db): # pylint: disable=redefined-outer-name
    LOGGER.warning('test_metric_sdb_tools_write_kpi begin')


# def test_influxdb_tools_read_kpi_points(influx_db): # pylint: disable=redefined-outer-name
#     LOGGER.warning('test_influxdb_tools_read_kpi_points begin')
def test_metrics_db_tools_read_kpi_points(metrics_db): # pylint: disable=redefined-outer-name
    LOGGER.warning('test_metrics_db_tools_read_kpi_points begin')