Commit 56089f19 authored by Waleed Akbar's avatar Waleed Akbar
Browse files

Changes in Kpi_value_api and added new monitoring namespace

- Added Prometheus monitoring deployment and update test configurations
- Updated KPI VALUE API (writer and promWriter)
parent af6688ba
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -215,6 +215,9 @@ export GRAF_EXT_PORT_HTTP=${GRAF_EXT_PORT_HTTP:-"3000"}
# Deploy Apache Kafka
./deploy/kafka.sh

#Deploy Monitoring (Prometheus, Mimir, Grafana)
./deploy/monitoring.sh

# Expose Dashboard
./deploy/expose_dashboard.sh

deploy/monitoring.sh

0 → 100644
+53 −0
Original line number Diff line number Diff line
#!/bin/bash
# Copyright 2022-2024 ETSI 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.

RELEASE_NAME="mon-prometheus"          
NAMESPACE="monitoring"                 
CHART_REPO_NAME="prometheus-community"
CHART_REPO_URL="https://prometheus-community.github.io/helm-charts"
CHART_NAME="prometheus"                # Chart name within the repo
VALUES_FILE="manifests/prometheus/prometheus.yaml"   

echo ">>> Deploying Prometheus with the following configuration:"
echo "Adding/updating Helm repo: $CHART_REPO_NAME -> $CHART_REPO_URL"
helm repo add "$CHART_REPO_NAME" "$CHART_REPO_URL" || true
helm repo update

echo "Creating namespace '$NAMESPACE' if it doesn't exist..."
kubectl get namespace "$NAMESPACE" >/dev/null 2>&1 || kubectl create namespace "$NAMESPACE"

#------------------------------------------------------------------------------
# 3. Install or upgrade the Prometheus chart
#    - If 'VALUES_FILE' is set, it will use it for custom configuration.
#    - Otherwise, it will deploy with the chart defaults.
#------------------------------------------------------------------------------
if [ -n "$VALUES_FILE" ] && [ -f "$VALUES_FILE" ]; then
    echo "Installing/Upgrading Prometheus with custom values from $VALUES_FILE..."
    helm upgrade --install "$RELEASE_NAME" "$CHART_REPO_NAME/$CHART_NAME" \
      --namespace "$NAMESPACE" \
      --values "$VALUES_FILE"
else
    echo "Installing/Upgrading Prometheus with default chart values..."
    helm upgrade --install "$RELEASE_NAME" "$CHART_REPO_NAME/$CHART_NAME" \
      --namespace "$NAMESPACE"
fi

echo "Waiting for Prometheus pods to be ready..."
kubectl rollout status deployment/"$RELEASE_NAME"-server -n "$NAMESPACE" || true

# echo "Listing deployed resources in namespace '$NAMESPACE':"
# kubectl get all -n "$NAMESPACE"

echo "<<< Prometheus deployment completed successfully!"
+2 −0
Original line number Diff line number Diff line
@@ -39,6 +39,8 @@ spec:
          env:
            - name: LOG_LEVEL
              value: "INFO"
            - name: PUSHGATEWAY_URL
              value: "http://mon-prometheus-prometheus-pushgateway.monitoring.svc.cluster.local:9091"
          envFrom:
            - secretRef:
                name: kfk-kpi-data
+52 −0
Original line number Diff line number Diff line
# Copyright 2022-2024 ETSI 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.

# Configuration for Prometheus components and server settings
# Global Prometheus configuration
alertmanager:
  enabled: false        # Default is true
kube-state-metrics:
  enabled: false        # Default is true
prometheus-node-exporter:
  enabled: false        # Default is true
prometheus-pushgateway:
  enabled: true         # Default is true

# Prometheus server-specific configuration
server:
  retention: "30d"
  logLevel: "debug"
  resources:
    requests:
      cpu: "250m"
      memory: "256Mi"
    limits:
      cpu: "1"
      memory: "1Gi"

  # Expose the Prometheus server via a Kubernetes service
  service:
    type: NodePort
    nodePort: 30090

  extraScrapeConfigs:
    - job_name: 'pushgateway'
      static_configs:
        - targets:
            - 'prometheus-pushgateway.monitoring.svc.cluster.local:9091'  # Push Gateway endpoint

  # Global Prometheus settings:
  global:
    scrape_interval: 10s
    evaluation_interval: 10s
+1 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ PROJECTDIR=`pwd`
cd $PROJECTDIR/src

export KFK_SERVER_ADDRESS='127.0.0.1:9092'

RCFILE=$PROJECTDIR/coverage/.coveragerc
python3 -m pytest --log-level=DEBUG --log-cli-level=DEBUG --verbose \
    kpi_value_writer/tests/test_kpi_value_writer.py
Loading