3
PROMETHEUS=$(juju status --format=yaml prometheus2 2>&1 | sed -nr '/^ {8}public-address/s/.*://p')
5
if [ -z "${PROMETHEUS}" ]; then
6
echo "No prometheus2 instances"
10
for UNIT in ${PROMETHEUS}; do
12
echo "Calling unit to ensure it returns: 'up' metrics"
13
echo 'curl -f -s -S -v http://${UNIT}:9090/api/v1/query?query=up'
5
##################################
6
# prometheus2 verification
7
##################################
8
for UNIT in $(get_units prometheus2); do
9
echo -e "####\n# Calling unit to ensure it returns: 'up' metrics"
14
10
curl -f -s -S -v http://${UNIT}:9090/api/v1/query?query=up
15
11
if [ $? -ne 0 ]; then
16
echo "####################"
17
echo "# E2E Check Failed #"
18
echo "####################"
21
echo "Calling unit to ensure telegraf targets were registered correctly"
22
echo 'curl -f -s -S -g http://${UNIT}:9090/api/v1/query?query=up{job=\"telegraf\"}|grep telegraf'
15
echo -e "\n####\n# Calling unit to ensure telegraf targets were registered correctly"
23
16
curl -f -s -S -g http://${UNIT}:9090/api/v1/query?query=up{job=\"telegraf\"}|grep telegraf
24
17
if [ $? -ne 0 ]; then
25
echo "####################"
26
echo "# E2E Check Failed #"
27
echo "####################"
32
# If we are here it means no checks failed
21
echo -e "\n####\n# Calling unit to ensure pushgateway was registered correctly"
22
curl -f -s -S -g http://${UNIT}:9090/api/v1/query?query=up{job=\"prometheus-pushgateway\"}|grep prometheus-pushgateway
27
echo -e "\n####\n# Calling unit to ensure alertmanager was registered correctly"
28
curl -f -s -S -g http://${UNIT}:9090/api/v1/query?query=prometheus_notifications_alertmanagers_discovered==1|grep value
34
##################################
36
##################################
37
for UNIT in $(get_units prometheus-alertmanager); do
38
echo -e "####\n# Checking alertmanager"
39
curl -f -s -S -g http://${UNIT}:9093/metrics|grep alertmanager_build_info
45
##################################
47
##################################
48
for UNIT in $(get_units prometheus-pushgateway); do
49
echo -e "####\n# Checking pushgateway"
50
curl -f -s -S -g http://${UNIT}:9091/metrics|grep pushgateway_build_info
56
##################################
58
##################################
59
for UNIT in $(get_units prometheus-snmp-exporter); do
60
echo -e "####\n# Checking snmp-exporter"
61
curl -f -s -S -g http://${UNIT}:9116/metrics|grep snmp_exporter_build_info
67
##################################
69
##################################
70
for UNIT in $(get_units prometheus-blackbox-exporter); do
71
echo -e "####\n# Checking blackbox-exporter"
72
curl -f -s -S -g http://${UNIT}:9115/metrics|grep blackbox_exporter_build_info
78
##################################
80
##################################
81
for UNIT in $(get_units grafana); do
82
echo -e "####\n# Checking grafana"
83
curl -f -s -S -g http://${UNIT}:3000/metrics|grep grafana_info
87
curl -f -s -S -g http://${UNIT}:3000/|grep "<title>Grafana</title>"
93
# If we are here it means all checks passed
33
94
echo "#####################"
34
95
echo "# E2E Checks Passed #"
35
96
echo "#####################"