-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Define prometheus metrics to k8s #1021
Changes from 39 commits
c2d7603
b9e2bc9
f39bfb2
1c25379
6cf5e69
dd38f92
b8b2110
1682e71
5c3da03
4cd1754
593441a
b83799f
5d8c464
b0b6b88
aabad14
1006b9a
e878ad6
5e260c8
825cbbc
d1a9398
bbbe46b
cabbde9
1e4d33b
dd194a6
4e9ca4e
9aa2428
cfc65ca
1910af9
da6aea4
22e4958
e53300b
57ae07c
7df6b27
22c2a63
9756feb
a2c953a
ef8d289
b36b822
54fd909
f09b5af
b968fc2
4e2c141
afcecdf
d2b35d7
9b35e24
a498eba
a62288b
a6befdb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# Customize the adapter configuration to map Prometheus metrics to Kubernetes metrics | ||
rules: | ||
default: false | ||
custom: | ||
- seriesQuery: 'vertica_query_requests_attempted_total{namespace!="", pod!=""}' | ||
resources: | ||
overrides: | ||
namespace: | ||
resource: namespace | ||
pod: | ||
resource: pod | ||
name: | ||
matches: "^(.*)_total$" | ||
as: "${1}_rate_per_second" | ||
metricsQuery: 'sum(increase(vertica_query_requests_attempted_total[5m])) by (namespace, pod)' | ||
# curl -g 'http://localhost:9090/api/v1/series?' --data-urlencode 'match[]=vertica_cpu_aggregate_usage_percentage' | jq | ||
# curl --request GET -g 'http://localhost:9090/api/v1/query?query=avg_over_time(vertica_cpu_aggregate_usage_percentage[60m])' | jq | ||
# kubectl get --raw /apis/custom.metrics.k8s.io/v1beta1/namespaces/default/pods/verticadb-sample-sc1-0/vertica_cpu_aggregate_usage_percentage | ||
# curl --request GET -g --data-urlencode 'query=count(vertica_cpu_aggregate_usage_percentage[1m]) by (namespace, pod)' http://localhost:9090/api/v1/query? | jq -r '.data.result[]' | ||
|
||
- seriesQuery: 'vertica_cpu_aggregate_usage_percentage{namespace!="", pod!=""}' | ||
resources: | ||
overrides: | ||
namespace: | ||
resource: namespace | ||
pod: | ||
resource: pod | ||
# name: | ||
# matches: "^vertica_cpu_aggregate_usage_percentage$" | ||
# as: "vertica_cpu_aggregate_usage_percentage" # If rename needed | ||
metricsQuery: 'avg_over_time(vertica_cpu_aggregate_usage_percentage[60m])' # 10174m means 10.174% per hour in average Ref: https://github.com/kubernetes-sigs/prometheus-adapter/blob/master/docs/walkthrough.md#quantity-values | ||
# curl -g 'http://localhost:9090/api/v1/series?' --data-urlencode 'match[]=vertica_process_memory_usage_percent' | jq | ||
# curl --request GET -g 'http://localhost:9090/api/v1/query?query=avg_over_time(vertica_process_memory_usage_percent[60m])' | jq | ||
# kubectl get --raw /apis/custom.metrics.k8s.io/v1beta1/namespaces/default/pods/verticadb-sample-sc1-0/vertica_process_memory_usage_percent | ||
- seriesQuery: 'vertica_process_memory_usage_percent{namespace!="", pod!=""}' | ||
resources: | ||
overrides: | ||
namespace: | ||
resource: namespace | ||
pod: | ||
resource: pod | ||
# name: | ||
# matches: "^vertica_query_requests_attempted_total$" | ||
# as: "vertica_query_requests_attempted_total" | ||
metricsQuery: 'avg_over_time(vertica_process_memory_usage_percent[60m])' # 2058m means 2.058% per hour | ||
# curl -g 'http://localhost:9090/api/v1/series?' --data-urlencode 'match[]=vertica_sessions_running_counter' | jq | ||
# curl --request GET http://localhost:9090/api/v1/query?query=vertica_sessions_running_counter | jq | ||
# kubectl get --raw /apis/custom.metrics.k8s.io/v1beta1/namespaces/default/pods/verticadb-sample-sc1-0/vertica_sessions_running_counter | ||
- seriesQuery: 'vertica_sessions_running_counter{namespace!="", pod!=""}' | ||
resources: | ||
overrides: | ||
namespace: | ||
resource: namespace | ||
pod: | ||
resource: pod | ||
# name: | ||
# matches: "^vertica_sessions_running_counter$" | ||
# as: "vertica_sessions_running_counter" | ||
metricsQuery: 'sum(increase(vertica_sessions_running_counter[60m])) by (namespace, pod)' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Have you played around with these queries on prometheus to check if they make sense? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I ran the Vertica API to get the value and compared it with the Prometheus API result. For example, percentage value, like CPU/memory usage in an average of time, it gives for example 10174m means 10.174% per hour in average, using the avg_over_time function. I left the example in the code.
HaoYang0000 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# curl -g 'http://localhost:9090/api/v1/series?' --data-urlencode 'match[]=vertica_queued_requests_total' | jq | ||
# curl --request GET http://localhost:9090/api/v1/query?query=vertica_queued_requests_total | jq | ||
# kubectl get --raw /apis/custom.metrics.k8s.io/v1beta1/namespaces/default/pods/verticadb-sample-sc1-0/vertica_queued_requests_total | ||
- seriesQuery: 'vertica_queued_requests_total{namespace!="", pod!=""}' | ||
resources: | ||
overrides: | ||
namespace: | ||
resource: namespace | ||
pod: | ||
resource: pod | ||
# name: | ||
# matches: "^vertica_queued_requests_total$" | ||
# as: "vertica_queued_requests_total" | ||
metricsQuery: 'sum(increase(vertica_queued_requests_total[60m])) by (namespace, pod)' | ||
HaoYang0000 marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# (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: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: prometheus-adapter | ||
status: | ||
replicas: 1 | ||
readyReplicas: 1 | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: prometheus-adapter |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# (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: cd ../../.. && make deploy-prometheus-adapter PROMETHEUS_NAMESPACE=$NAMESPACE PROMETHEUS_ADAPTER_NAMESPACE=$NAMESPACE |
HaoYang0000 marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# (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: v1 | ||
kind: Pod | ||
metadata: | ||
name: script-verity-prometheus-adapter | ||
status: | ||
containerStatuses: | ||
- name: test | ||
state: | ||
terminated: | ||
exitCode: 0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# (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: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: script-verity-prometheus-adapter | ||
data: | ||
entrypoint.sh: |- | ||
#!/bin/bash | ||
set -o errexit | ||
set -o xtrace | ||
|
||
for i in {1..60}; do | ||
kubectl exec v-prometheus-pri1-0 -it -c server -- vsql -w 'topsecret' -c "select count(*) from nodes;" | ||
done | ||
|
||
NAMESPACE=$(kubectl get pod v-prometheus-pri1-0 -o=jsonpath='{.metadata.namespace}') | ||
CMD="kubectl get --raw /apis/custom.metrics.k8s.io/v1beta1/namespaces/${NAMESPACE}/pods/v-prometheus-pri1-0/vertica_query_requests_attempted_rate_per_second" | ||
RESULT=$(eval $CMD) | ||
VALUE=$(echo $RESULT | jq -r '.items[0].value') | ||
|
||
REQUESTS_COUNT=${VALUE::-4} | ||
if [[ "$REQUESTS_COUNT" == "" || "$REQUESTS_COUNT" -lt 60 ]]; then | ||
echo "Error: got $REQUESTS_COUNT. Expected requests no less than 60." | ||
exit 1 | ||
fi | ||
--- | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: script-verity-prometheus-adapter | ||
labels: | ||
stern: include | ||
spec: | ||
restartPolicy: Never | ||
containers: | ||
- name: test | ||
image: bitnami/kubectl:1.20.4 | ||
command: ["/bin/entrypoint.sh"] | ||
volumeMounts: | ||
- name: entrypoint-volume | ||
mountPath: /bin/entrypoint.sh | ||
readOnly: true | ||
subPath: entrypoint.sh | ||
volumes: | ||
- name: entrypoint-volume | ||
configMap: | ||
defaultMode: 0777 | ||
name: script-verity-prometheus-adapter |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# (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: cd ../../.. && make undeploy-prometheus-adapter PROMETHEUS_ADAPTER_NAMESPACE=$NAMESPACE |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# (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: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: prometheus-adapter | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: prometheus-adapter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For each of these queries we need a detailed description.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For sure, but should we do the description in the developer doc, instead of here in adapter.yaml?
Do we expect the user to use the metrics we provided, or we provide example here and expect they can customize on their own?