Merge "Get raw result of stress tests from prometheus"
[dcaegen2/collectors/hv-ves.git] / tools / performance / cloud / prometheus-getsnapshots.sh
1 #!/usr/bin/env bash
2 # ============LICENSE_START=======================================================
3 # dcaegen2-collectors-veshv
4 # ================================================================================
5 # Copyright (C) 2020 NOKIA
6 # ================================================================================
7 # Licensed under the Apache License, Version 2.0 (the "License");
8 # you may not use this file except in compliance with the License.
9 # You may obtain a copy of the License at
10 #
11 #      http://www.apache.org/licenses/LICENSE-2.0
12 #
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
18 # ============LICENSE_END=========================================================
19
20 ONAP_NAMESPACE=onap
21 PROMETHEUS_POD_NAME=$(kubectl -n ${ONAP_NAMESPACE} get pods --no-headers=true -o custom-columns=:metadata.name | grep prometheus-hv-ves-deployment)
22 DESTINATION_DIR=./prometheus-snapshots/
23
24 IP=$(kubectl config view -o jsonpath='{.clusters[].cluster.server}')
25 HTTPS="https://"
26 IP=${IP[@]//${HTTPS}}
27 IP=${IP[@]//:*}
28
29 echo "Sending request to create prometheus snapshot"
30 curl -XPOST http://${IP}:30000/api/v1/admin/tsdb/snapshot
31
32 echo -e "\nDownloading snapshots from prometheus to "${DESTINATION_DIR}
33 kubectl -n ${ONAP_NAMESPACE} cp  ${PROMETHEUS_POD_NAME}:/prometheus/snapshots ${DESTINATION_DIR}
34