Merge "Use prometheus api to get metrics names in check_data"
This commit is contained in:
commit
14cc275efd
@ -75,7 +75,7 @@ function wait_for_data {
|
||||
# Adding sleep time so that metrics is pushed by node exporter
|
||||
sleep 60
|
||||
}
|
||||
function check_data {
|
||||
function check_data_node_exporter {
|
||||
if curl -s --head --request GET "http://$HOST_IP:$NODE_EXPORTER_PORT/metrics" | grep "200 OK" > /dev/null; then
|
||||
echo "#### Metrics data ####"
|
||||
curl "http://$HOST_IP:$NODE_EXPORTER_PORT/metrics"
|
||||
|
@ -11,7 +11,7 @@ PROMETHEUS_PORT=${PROMETHEUS_PORT:-9090}
|
||||
|
||||
function pre_install_prometheus {
|
||||
# Install OS packages
|
||||
install_package wget tar
|
||||
install_package wget tar jq
|
||||
}
|
||||
|
||||
function install_prometheus {
|
||||
@ -94,10 +94,12 @@ function wait_for_data {
|
||||
sleep 60
|
||||
}
|
||||
|
||||
function check_data {
|
||||
if curl -s --head --request GET "http://$HOST_IP:$PROMETHEUS_PORT/metrics" | grep "200 OK" > /dev/null; then
|
||||
echo "#### Metrics data ####"
|
||||
curl "http://$HOST_IP:$PROMETHEUS_PORT/metrics"
|
||||
function check_data_prometheus {
|
||||
local url="http://$HOST_IP:$PROMETHEUS_PORT/api/v1/label/__name__/values"
|
||||
|
||||
if curl -s --head --request GET "$url" | grep "200 OK" > /dev/null; then
|
||||
echo "#### List of metrics names ####"
|
||||
curl -s "$url" | jq -r '.data[]'
|
||||
else
|
||||
die $LINENO "Couldn't get data from prometheus"
|
||||
fi
|
||||
|
@ -36,7 +36,7 @@ if is_service_enabled prometheus; then
|
||||
start_prometheus
|
||||
echo_summary "Give time to prometheus to scrape data"
|
||||
wait_for_data
|
||||
check_data
|
||||
check_data_prometheus
|
||||
fi
|
||||
|
||||
if [[ "$1" == "unstack" ]]; then
|
||||
@ -80,7 +80,7 @@ if is_service_enabled node_exporter; then
|
||||
start_node_exporter
|
||||
echo_summary "Give time to node_exporter to push metrics"
|
||||
wait_for_data
|
||||
check_data
|
||||
check_data_node_exporter
|
||||
fi
|
||||
|
||||
if [[ "$1" == "unstack" ]]; then
|
||||
|
Loading…
x
Reference in New Issue
Block a user