diff --git a/prometheus/adapter.yaml b/prometheus/adapter.yaml index e954f7e55..fa374f3d9 100644 --- a/prometheus/adapter.yaml +++ b/prometheus/adapter.yaml @@ -13,3 +13,39 @@ rules: matches: "^(.*)_total$" as: "${1}_rate_per_second" metricsQuery: 'sum(increase(vertica_query_requests_attempted_total[5m])) by (namespace, pod)' + # Aggregate CPU usage, expressed as a percentage of total CPU capacity. Type: gauge + - seriesQuery: 'vertica_cpu_aggregate_usage_percentage{namespace!="", pod!=""}' + resources: + overrides: + namespace: + resource: namespace + pod: + resource: pod + metricsQuery: 'avg_over_time(vertica_cpu_aggregate_usage_percentage[60m])' + # Total Vertica process memory usage, expressed as a percentage of total usable RAM. Type: gauge + - seriesQuery: 'vertica_process_memory_usage_percent{namespace!="", pod!=""}' + resources: + overrides: + namespace: + resource: namespace + pod: + resource: pod + metricsQuery: 'avg_over_time(vertica_process_memory_usage_percent[60m])' + # # Number of active sessions. Type: guage + # - seriesQuery: 'vertica_sessions_running_counter{namespace!="", pod!=""}' + # resources: + # overrides: + # namespace: + # resource: namespace + # pod: + # resource: pod + # metricsQuery: 'sum(increase(vertica_sessions_running_counter[1m])) by (namespace, pod)' + # # Number of requests that are queued in the resource pool. Type: guage + # - seriesQuery: 'vertica_queued_requests_total{namespace!="", pod!=""}' + # resources: + # overrides: + # namespace: + # resource: namespace + # pod: + # resource: pod + # metricsQuery: 'sum(increase(vertica_queued_requests_total[1m])) by (namespace, pod)' diff --git a/tests/e2e-leg-12/prometheus-sanity/35-verify-custom-metrics.yaml b/tests/e2e-leg-12/prometheus-sanity/35-verify-custom-metrics.yaml new file mode 100644 index 000000000..f2ddd0648 --- /dev/null +++ b/tests/e2e-leg-12/prometheus-sanity/35-verify-custom-metrics.yaml @@ -0,0 +1,52 @@ +# (c) Copyright [2021-2024] Open Text. +# 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. + +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +commands: + - script: | + NAMESPACE=$(kubectl get pod v-prometheus-pri1-0 -o=jsonpath='{.metadata.namespace}') + RESULT=$(kubectl get --raw /apis/custom.metrics.k8s.io/v1beta1/namespaces/$NAMESPACE/pods/v-prometheus-pri1-0/vertica_cpu_aggregate_usage_percentage) + OUTPUT=$(echo $RESULT | jq -r '.items[0].value') + # verify the metrics result + if [[ "$OUTPUT" == "" ]]; then + echo "empty custom metrics result on vertica_cpu_aggregate_usage_percentage. Result: $RESULT" + exit 1 + fi + - script: | + NAMESPACE=$(kubectl get pod v-prometheus-pri1-0 -o=jsonpath='{.metadata.namespace}') + RESULT=$(kubectl get --raw /apis/custom.metrics.k8s.io/v1beta1/namespaces/$NAMESPACE/pods/v-prometheus-pri1-0/vertica_process_memory_usage_percent) + OUTPUT=$(echo $RESULT | jq -r '.items[0].value') + # verify the metrics result + if [[ "$OUTPUT" == "" ]]; then + echo "empty custom metrics result on vertica_process_memory_usage_percent. Result: $RESULT" + exit 1 + fi + # - script: | + # NAMESPACE=$(kubectl get pod v-prometheus-pri1-0 -o=jsonpath='{.metadata.namespace}') + # RESULT=$(kubectl get --raw /apis/custom.metrics.k8s.io/v1beta1/namespaces/$NAMESPACE/pods/v-prometheus-pri1-0/vertica_sessions_running_counter) + # OUTPUT=$(echo $RESULT | jq -r '.items[0].value') + # # verify the metrics result + # if [[ "$OUTPUT" == "" ]]; then + # echo "empty custom metrics result on vertica_sessions_running_counter. Result: $RESULT" + # exit 1 + # fi + # - script: | + # NAMESPACE=$(kubectl get pod v-prometheus-pri1-0 -o=jsonpath='{.metadata.namespace}') + # RESULT=$(kubectl get --raw /apis/custom.metrics.k8s.io/v1beta1/namespaces/$NAMESPACE/pods/v-prometheus-pri1-0/vertica_queued_requests_total) + # OUTPUT=$(echo $RESULT | jq -r '.items[0].value') + # # verify the metrics result + # if [[ "$OUTPUT" == "" ]]; then + # echo "empty custom metrics result on vertica_queued_requests_total. Result: $RESULT" + # exit 1 + # fi