diff --git a/deploy/tfs.sh b/deploy/tfs.sh index 8565077c390534a197e75b194e2ed3e22605c6ac..b8e1f883793cf627391117cc4ceb2fe85ae8468d 100755 --- a/deploy/tfs.sh +++ b/deploy/tfs.sh @@ -146,6 +146,17 @@ kubectl create secret generic crdb-data --namespace ${TFS_K8S_NAMESPACE} --type= --from-literal=CRDB_SSLMODE=require printf "\n" +echo "Create secret with CockroachDB data for KPI Management" +CRDB_SQL_PORT=$(kubectl --namespace ${CRDB_NAMESPACE} get service cockroachdb-public -o 'jsonpath={.spec.ports[?(@.name=="sql")].port}') +kubectl create secret generic crdb-kpi-data --namespace ${TFS_K8S_NAMESPACE} --type='Opaque' \ + --from-literal=CRDB_NAMESPACE=${CRDB_NAMESPACE} \ + --from-literal=CRDB_SQL_PORT=${CRDB_SQL_PORT} \ + --from-literal=CRDB_DATABASE=${CRDB_DATABASE} \ + --from-literal=CRDB_USERNAME=${CRDB_USERNAME} \ + --from-literal=CRDB_PASSWORD=${CRDB_PASSWORD} \ + --from-literal=CRDB_SSLMODE=require +printf "\n" + echo "Create secret with NATS data" NATS_CLIENT_PORT=$(kubectl --namespace ${NATS_NAMESPACE} get service ${NATS_NAMESPACE} -o 'jsonpath={.spec.ports[?(@.name=="client")].port}') if [ -z "$NATS_CLIENT_PORT" ]; then diff --git a/manifests/kpi_managerservice.yaml b/manifests/kpi_managerservice.yaml index 3e106fd92c4ccb51cc1a695fc0083c6ee475502b..984d783a9de7ed3c0c02e87d82ec673dc19c9508 100644 --- a/manifests/kpi_managerservice.yaml +++ b/manifests/kpi_managerservice.yaml @@ -41,7 +41,7 @@ spec: value: "INFO" envFrom: - secretRef: - name: crdb-data + name: crdb-kpi-data readinessProbe: exec: command: ["/bin/grpc_health_probe", "-addr=:30010"] diff --git a/scripts/show_logs_kpi_value_api.sh b/scripts/show_logs_kpi_value_api.sh new file mode 100755 index 0000000000000000000000000000000000000000..041ad7f1ffb1a218af00d5d142024a5063d109c3 --- /dev/null +++ b/scripts/show_logs_kpi_value_api.sh @@ -0,0 +1,27 @@ +#!/bin/bash +# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/) +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +######################################################################################################################## +# Define your deployment settings here +######################################################################################################################## + +# If not already set, set the name of the Kubernetes namespace to deploy to. +export TFS_K8S_NAMESPACE=${TFS_K8S_NAMESPACE:-"tfs"} + +######################################################################################################################## +# Automated steps start here +######################################################################################################################## + +kubectl --namespace $TFS_K8S_NAMESPACE logs deployment/kpi-value-apiservice -c server diff --git a/scripts/show_logs_kpi_value_writer.sh b/scripts/show_logs_kpi_value_writer.sh new file mode 100755 index 0000000000000000000000000000000000000000..d62f3ea0a1a6961be4a5b6f4841c9ba4e1a89316 --- /dev/null +++ b/scripts/show_logs_kpi_value_writer.sh @@ -0,0 +1,27 @@ +#!/bin/bash +# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/) +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +######################################################################################################################## +# Define your deployment settings here +######################################################################################################################## + +# If not already set, set the name of the Kubernetes namespace to deploy to. +export TFS_K8S_NAMESPACE=${TFS_K8S_NAMESPACE:-"tfs"} + +######################################################################################################################## +# Automated steps start here +######################################################################################################################## + +kubectl --namespace $TFS_K8S_NAMESPACE logs deployment/kpi-value-writerservice -c server diff --git a/src/common/tools/kafka/Variables.py b/src/common/tools/kafka/Variables.py index e01b33896f439204eaf770cf58c7d9852a797611..bdb6708f3fa5496997240698ab126462c0776546 100644 --- a/src/common/tools/kafka/Variables.py +++ b/src/common/tools/kafka/Variables.py @@ -21,7 +21,8 @@ from confluent_kafka.admin import AdminClient, NewTopic LOGGER = logging.getLogger(__name__) class KafkaConfig(Enum): - SERVER_IP = "127.0.0.1:9092" + # SERVER_IP = "127.0.0.1:9092" + SERVER_IP = "kafka-service:9092" ADMIN_CLIENT = AdminClient({'bootstrap.servers': SERVER_IP}) class KafkaTopic(Enum): diff --git a/src/kpi_value_writer/service/KpiValueWriter.py b/src/kpi_value_writer/service/KpiValueWriter.py index aa0f2cf79128e962801fda457edb8256ee4735b1..a4b10ed6391c4ff0b0ee45a287ce9f12d77e2dea 100644 --- a/src/kpi_value_writer/service/KpiValueWriter.py +++ b/src/kpi_value_writer/service/KpiValueWriter.py @@ -67,24 +67,17 @@ class KpiValueWriter: kpi_value.ParseFromString(raw_kpi.value()) LOGGER.info("Received KPI : {:}".format(kpi_value)) print("Received KPI : {:}".format(kpi_value)) - KpiValueWriter.get_kpi_descriptor(kpi_value.kpi_id.kpi_id.uuid, kpi_manager_client) - # -------- Testing section --------------- - # test_kpi_descriptor_obj = create_kpi_descriptor_request() - # metric_writer_to_prom.create_and_expose_cooked_kpi( - # test_kpi_descriptor_obj, kpi_value - # ) - # -------- Testing section --------------- - + KpiValueWriter.get_kpi_descriptor(kpi_value, kpi_manager_client) except Exception as e: print("Error detail: {:}".format(e)) continue @staticmethod - def get_kpi_descriptor(kpi_value_uuid: str, kpi_manager_client ): + def get_kpi_descriptor(kpi_value: str, kpi_manager_client ): print("--- START -----") kpi_id = KpiId() - kpi_id.kpi_id.uuid = kpi_value_uuid + kpi_id.kpi_id.uuid = kpi_value.kpi_id.kpi_id.uuid print("KpiId generated: {:}".format(kpi_id)) # print("Kpi manger client created: {:}".format(kpi_manager_client)) @@ -96,6 +89,7 @@ class KpiValueWriter: if isinstance (kpi_descriptor_object, KpiDescriptor): LOGGER.info("Extracted KpiDescriptor: {:}".format(kpi_descriptor_object)) print("Extracted KpiDescriptor: {:}".format(kpi_descriptor_object)) + MetricWriterToPrometheus.create_and_expose_cooked_kpi(kpi_descriptor_object, kpi_value) else: LOGGER.info("Error in extracting KpiDescriptor {:}".format(kpi_descriptor_object)) print("Error in extracting KpiDescriptor {:}".format(kpi_descriptor_object)) diff --git a/src/kpi_value_writer/service/__main__.py b/src/kpi_value_writer/service/__main__.py index 028585575c65874658d3d29efaf0dee0ce4deaae..aa67540fb899781297d1235dc2e15bcbb2c38585 100644 --- a/src/kpi_value_writer/service/__main__.py +++ b/src/kpi_value_writer/service/__main__.py @@ -13,9 +13,8 @@ # limitations under the License. import logging, signal, sys, threading -from prometheus_client import start_http_server -from .KpiValueWriter import KpiValueWriter -from common.Settings import get_log_level, get_metrics_port +from kpi_value_writer.service.KpiValueWriter import KpiValueWriter +from common.Settings import get_log_level terminate = threading.Event() LOGGER = None