From 10deafd1e133e37706c235b7fa902fe4b7c0f6ea Mon Sep 17 00:00:00 2001 From: sgayangi Date: Wed, 28 Feb 2024 12:33:16 +0530 Subject: [PATCH] Update configurations for Prometheus --- .../internal/config/default_config.go | 2 +- .../config-deployer/config-ds-deployment.yaml | 12 ++--- .../config-ds-prometheus-jmx-configmap.yaml | 18 +------ .../config-deployer/config-ds-service.yaml | 8 --- .../adapter/adapter-service.yaml | 5 -- .../common-controller-deployment.yaml | 2 +- .../common-controller-service.yaml | 5 -- .../gateway-runtime/enforcer-service.yaml | 5 -- .../prometheus-jmx-configmap.yaml | 16 ++++++ .../gateway-runtime/router-service.yaml | 31 ----------- .../docker/config-deployer/config.sh | 53 ++++++++++--------- 11 files changed, 52 insertions(+), 105 deletions(-) delete mode 100644 helm-charts/templates/data-plane/gateway-components/gateway-runtime/router-service.yaml diff --git a/common-controller/internal/config/default_config.go b/common-controller/internal/config/default_config.go index 37a8105f94..833be5dcb4 100644 --- a/common-controller/internal/config/default_config.go +++ b/common-controller/internal/config/default_config.go @@ -46,7 +46,7 @@ var defaultConfig = &Config{ Metrics: metrics{ Enabled: true, Type: "prometheus", - Port: 18009, + Port: 18010, CollectionInterval: 5, }, }, diff --git a/helm-charts/templates/data-plane/config-deployer/config-ds-deployment.yaml b/helm-charts/templates/data-plane/config-deployer/config-ds-deployment.yaml index acef543582..e4d5206008 100644 --- a/helm-charts/templates/data-plane/config-deployer/config-ds-deployment.yaml +++ b/helm-charts/templates/data-plane/config-deployer/config-ds-deployment.yaml @@ -45,7 +45,7 @@ spec: {{ if and .Values.wso2.apk.metrics .Values.wso2.apk.metrics.enabled }} - containerPort: 18008 protocol: "TCP" - - containerPort: 18010 + - containerPort: 18009 protocol: "TCP" {{ end }} readinessProbe: @@ -67,6 +67,9 @@ spec: - mountPath: /home/wso2apk/config-deployer/conf/Config.toml name: config-toml-volume subPath: Config.toml + - name: prometheus-jmx-config-volume + mountPath: /tmp/metrics/prometheus-jmx-config-configds.yml + subPath: prometheus-jmx-config-configds.yml - name: config-ds-tls-volume mountPath: /home/wso2apk/config-deployer/security/config.key {{- if and .Values.wso2.apk.dp.configdeployer.configs .Values.wso2.apk.dp.configdeployer.configs.tls }} @@ -74,9 +77,6 @@ spec: {{- else }} subPath: tls.key {{- end }} - - name: prometheus-jmx-config-volume - mountPath: /tmp/metrics/prometheus-jmx-config-configds.yml - subPath: prometheus-jmx-config-configds.yml - name: config-ds-tls-volume mountPath: /home/wso2apk/config-deployer/security/config.pem {{- if and .Values.wso2.apk.dp.configdeployer.configs .Values.wso2.apk.dp.configdeployer.configs.tls }} @@ -114,8 +114,8 @@ spec: - name: config-toml-volume configMap: name: {{ template "apk-helm.resource.prefix" . }}-config-ds-configmap - - name: prometheus-jmx-config-volume - configMap: + - name: prometheus-jmx-config-volume + configMap: name: prometheus-jmx-config-configds - name: config-ds-tls-volume secret: diff --git a/helm-charts/templates/data-plane/config-deployer/config-ds-prometheus-jmx-configmap.yaml b/helm-charts/templates/data-plane/config-deployer/config-ds-prometheus-jmx-configmap.yaml index 610f358ecc..de27313096 100644 --- a/helm-charts/templates/data-plane/config-deployer/config-ds-prometheus-jmx-configmap.yaml +++ b/helm-charts/templates/data-plane/config-deployer/config-ds-prometheus-jmx-configmap.yaml @@ -23,25 +23,9 @@ data: lowercaseOutputName: true lowercaseOutputLabelNames: true rules: - # WSO2 APK related metrics - - pattern: 'org.wso2.apk.config<>total_request_count: (.*)' - name: org_wso2_apk_config_request_count_total - help: "WSO2 APK config total request count." - attrNameSnakeCase: true - type: COUNTER - - pattern: 'org.wso2.apk.config<>(average_response_time_millis|max_response_time_millis|min_response_time_millis|request_count_in_last_five_minute_window|request_count_window_start_time_millis): (.*)' - name: org_wso2_apk_config_$1 - help: "WSO2 APK config $1." - attrNameSnakeCase: true - type: GAUGE - - pattern: 'org.wso2.apk.config<>(\w+): (.*)' - name: org_wso2_apk_config_thread_pool_$1 - help: "WSO2 APK config thread pool $1." - attrNameSnakeCase: true - type: GAUGE # OS related metrics - pattern: 'java.lang<>(\w+): (.*)' name: os_$1 help: Operating System $1 attrNameSnakeCase: true - type: GAUGE \ No newline at end of file + type: GAUGE diff --git a/helm-charts/templates/data-plane/config-deployer/config-ds-service.yaml b/helm-charts/templates/data-plane/config-deployer/config-ds-service.yaml index ffd488cb42..b19708a7f6 100644 --- a/helm-charts/templates/data-plane/config-deployer/config-ds-service.yaml +++ b/helm-charts/templates/data-plane/config-deployer/config-ds-service.yaml @@ -28,12 +28,4 @@ spec: - name: servlet-https protocol: TCP port: 9443 - {{ if and .Values.wso2.apk.metrics .Values.wso2.apk.metrics.enabled }} - - name: prometheus-config-ds-port-lang - protocol: TCP - port: 18008 - - name: prometheus-config-ds-port-system - protocol: TCP - port: 18010 - {{ end }} {{- end -}} diff --git a/helm-charts/templates/data-plane/gateway-components/adapter/adapter-service.yaml b/helm-charts/templates/data-plane/gateway-components/adapter/adapter-service.yaml index c0c8e0c7ca..8c78ff45c0 100644 --- a/helm-charts/templates/data-plane/gateway-components/adapter/adapter-service.yaml +++ b/helm-charts/templates/data-plane/gateway-components/adapter/adapter-service.yaml @@ -41,9 +41,4 @@ spec: - name: profile-port protocol: TCP port: 6060 - {{ if and .Values.wso2.apk.metrics .Values.wso2.apk.metrics.enabled}} - - name: prometheus-adapter-port - port: 18006 - protocol: "TCP" - {{ end }} {{- end -}} diff --git a/helm-charts/templates/data-plane/gateway-components/common-controller/common-controller-deployment.yaml b/helm-charts/templates/data-plane/gateway-components/common-controller/common-controller-deployment.yaml index ef35c6424d..133cd8441a 100644 --- a/helm-charts/templates/data-plane/gateway-components/common-controller/common-controller-deployment.yaml +++ b/helm-charts/templates/data-plane/gateway-components/common-controller/common-controller-deployment.yaml @@ -49,7 +49,7 @@ spec: - containerPort: 18003 protocol: TCP {{ if and .Values.wso2.apk.metrics .Values.wso2.apk.metrics.enabled }} - - containerPort: 18009 + - containerPort: 18010 protocol: "TCP" {{ end }} {{ include "apk-helm.deployment.resources" .Values.wso2.apk.dp.commonController.deployment.resources | indent 10 }} diff --git a/helm-charts/templates/data-plane/gateway-components/common-controller/common-controller-service.yaml b/helm-charts/templates/data-plane/gateway-components/common-controller/common-controller-service.yaml index debcb579f3..e5adf645f4 100644 --- a/helm-charts/templates/data-plane/gateway-components/common-controller/common-controller-service.yaml +++ b/helm-charts/templates/data-plane/gateway-components/common-controller/common-controller-service.yaml @@ -38,9 +38,4 @@ spec: - name: https-internal-api protocol: TCP port: 18003 - {{ if and .Values.wso2.apk.metrics .Values.wso2.apk.metrics.enabled }} - - name: prometheus-common-controller-port - protocol: TCP - port: 18009 - {{ end }} {{- end -}} diff --git a/helm-charts/templates/data-plane/gateway-components/gateway-runtime/enforcer-service.yaml b/helm-charts/templates/data-plane/gateway-components/gateway-runtime/enforcer-service.yaml index a8355ce99d..e88b6d8612 100644 --- a/helm-charts/templates/data-plane/gateway-components/gateway-runtime/enforcer-service.yaml +++ b/helm-charts/templates/data-plane/gateway-components/gateway-runtime/enforcer-service.yaml @@ -28,9 +28,4 @@ spec: - name: servlet-https protocol: TCP port: 9092 - {{- if and .Values.wso2.apk.metrics .Values.wso2.apk.metrics.enabled }} - - name: prometheus-enforcer-port - protocol: TCP - port: 18007 - {{- end }} {{- end -}} diff --git a/helm-charts/templates/data-plane/gateway-components/gateway-runtime/prometheus-jmx-configmap.yaml b/helm-charts/templates/data-plane/gateway-components/gateway-runtime/prometheus-jmx-configmap.yaml index dc1849b2d4..4f45e2d4f7 100644 --- a/helm-charts/templates/data-plane/gateway-components/gateway-runtime/prometheus-jmx-configmap.yaml +++ b/helm-charts/templates/data-plane/gateway-components/gateway-runtime/prometheus-jmx-configmap.yaml @@ -1,3 +1,19 @@ +# Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com) All Rights Reserved. +# +# WSO2 LLC. licenses this file to you 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. + apiVersion: v1 kind: ConfigMap metadata: diff --git a/helm-charts/templates/data-plane/gateway-components/gateway-runtime/router-service.yaml b/helm-charts/templates/data-plane/gateway-components/gateway-runtime/router-service.yaml deleted file mode 100644 index 8450a504d1..0000000000 --- a/helm-charts/templates/data-plane/gateway-components/gateway-runtime/router-service.yaml +++ /dev/null @@ -1,31 +0,0 @@ -# Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com) All Rights Reserved. -# -# WSO2 LLC. licenses this file to you 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. - -{{- if and .Values.wso2.apk.dp.enabled .Values.wso2.apk.metrics .Values.wso2.apk.metrics.enabled}} -apiVersion: v1 -kind: Service -metadata: - name: {{ template "apk-helm.resource.prefix" . }}-router-service - namespace : {{ .Release.Namespace }} -spec: - # label keys and values that must match in order to receive traffic for this service - selector: -{{ include "apk-helm.pod.selectorLabels" (dict "root" . "app" "gateway" ) | indent 4}} - ports: - - name: prometheus-router-port - protocol: TCP - port: 9000 -{{- end -}} diff --git a/runtime/config-deployer-service/docker/config-deployer/config.sh b/runtime/config-deployer-service/docker/config-deployer/config.sh index acac82f1b9..9cc37c02d9 100644 --- a/runtime/config-deployer-service/docker/config-deployer/config.sh +++ b/runtime/config-deployer-service/docker/config-deployer/config.sh @@ -2,23 +2,26 @@ PRG="$0" while [ -h "$PRG" ]; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '.*/.*' > /dev/null; then + ls=$(ls -ld "$PRG") + link=$(expr "$ls" : '.*-> \(.*\)$') + if expr "$link" : '.*/.*' >/dev/null; then PRG="$link" else - PRG=`dirname "$PRG"`/"$link" + PRG=$(dirname "$PRG")/"$link" fi done # Get standard environment variables -PRGDIR=`dirname "$PRG"` +PRGDIR=$(dirname "$PRG") -[ -z "$RUNTIME_HOME" ] && RUNTIME_HOME=`cd "$PRGDIR" ; pwd` +[ -z "$RUNTIME_HOME" ] && RUNTIME_HOME=$( + cd "$PRGDIR" + pwd +) -if [ -z "$JAVACMD" ] ; then - if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then +if [ -z "$JAVACMD" ]; then + if [ -n "$JAVA_HOME" ]; then + if [ -x "$JAVA_HOME/jre/sh/java" ]; then # IBM's JDK on AIX uses strange locations for the executables JAVACMD="$JAVA_HOME/jre/sh/java" else @@ -29,7 +32,7 @@ if [ -z "$JAVACMD" ] ; then fi fi -if [ ! -x "$JAVACMD" ] ; then +if [ ! -x "$JAVACMD" ]; then echo "Error: JAVA_HOME is not defined correctly." echo " Admin cannot execute $JAVACMD" exit 1 @@ -42,16 +45,15 @@ if [ -z "$JAVA_HOME" ]; then fi # ----- Process the input command ---------------------------------------------- args="" -for c in $* -do - if [ "$c" = "--debug" ] || [ "$c" = "-debug" ] || [ "$c" = "debug" ]; then - CMD="--debug" - continue - elif [ "$CMD" = "--debug" ]; then - if [ -z "$PORT" ]; then - PORT=$c - fi +for c in $*; do + if [ "$c" = "--debug" ] || [ "$c" = "-debug" ] || [ "$c" = "debug" ]; then + CMD="--debug" + continue + elif [ "$CMD" = "--debug" ]; then + if [ -z "$PORT" ]; then + PORT=$c fi + fi done if [ "$CMD" = "--debug" ]; then @@ -69,11 +71,10 @@ fi CLASSPATH="" if [ -e "$JAVA_HOME/lib/tools.jar" ]; then - CLASSPATH="$JAVA_HOME/lib/tools.jar" + CLASSPATH="$JAVA_HOME/lib/tools.jar" fi -for t in "$RUNTIME_HOME"/lib/*.jar -do - CLASSPATH="$CLASSPATH":$t +for t in "$RUNTIME_HOME"/lib/*.jar; do + CLASSPATH="$CLASSPATH":$t done # ----- Execute The Requested Command ----------------------------------------- @@ -85,15 +86,15 @@ cd "$RUNTIME_HOME" TMP_DIR="$RUNTIME_HOME"/tmp if [ -d "$TMP_DIR" ]; then -rm -rf "$TMP_DIR"/* + rm -rf "$TMP_DIR"/* fi START_EXIT_STATUS=121 status=$START_EXIT_STATUS if [ -z "$JVM_MEM_OPTS" ]; then - java_version=$("$JAVACMD" -version 2>&1 | awk -F '"' '/version/ {print $2}') - JVM_MEM_OPTS="-Xms256m -Xmx1024m" + java_version=$("$JAVACMD" -version 2>&1 | awk -F '"' '/version/ {print $2}') + JVM_MEM_OPTS="-Xms256m -Xmx1024m" fi echo "Using Java memory options: $JVM_MEM_OPTS"