~jamon/mojo/charm-testing-influxdb

« back to all changes in this revision

Viewing changes to charm-testing/prometheus2/post-deploy

  • Committer: mergebot at canonical
  • Author(s): "Jacek Nykis"
  • Date: 2018-07-05 14:33:47 UTC
  • mfrom: (109.1.2 mojo-specs)
  • Revision ID: mergebot@juju-139df4-prod-is-toolbox-0.canonical.com-20180705143347-l1hixz1d4p4akzhv
Improve prometheus verification script. Add symlinks to allow upgrade-charm testing for prometheus-alertmanager, prometheus-blackbox-exporter, prometheus-pushgateway and prometheus-snmp-exporter

Reviewed-on: https://code.launchpad.net/~jacekn/mojo/mojo-specs/+merge/349005
Reviewed-by: Laurent Sesques <laurent.sesques@canonical.com>

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/bin/bash
2
2
 
3
 
PROMETHEUS=$(juju status --format=yaml prometheus2 2>&1 | sed -nr '/^ {8}public-address/s/.*://p')
4
 
 
5
 
if [ -z "${PROMETHEUS}" ]; then
6
 
    echo "No prometheus2 instances"
7
 
    exit 1
8
 
fi
9
 
 
10
 
for UNIT in ${PROMETHEUS}; do
11
 
 
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'
 
3
. helpers
 
4
 
 
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 "####################"
19
 
        exit 1
 
12
        fail
20
13
    fi
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'
 
14
 
 
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 "####################"
28
 
        exit 1
29
 
    fi
30
 
done
31
 
 
32
 
# If we are here it means no checks failed
 
18
        fail
 
19
    fi
 
20
 
 
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
 
23
    if [ $? -ne 0 ]; then
 
24
        fail
 
25
    fi
 
26
 
 
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
 
29
    if [ $? -ne 0 ]; then
 
30
        fail
 
31
    fi
 
32
done
 
33
 
 
34
##################################
 
35
# alertmanager
 
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
 
40
    if [ $? -ne 0 ]; then
 
41
        fail
 
42
    fi
 
43
done
 
44
 
 
45
##################################
 
46
# pushgateway
 
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
 
51
    if [ $? -ne 0 ]; then
 
52
        fail
 
53
    fi
 
54
done
 
55
 
 
56
##################################
 
57
# snmp-exporter
 
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
 
62
    if [ $? -ne 0 ]; then
 
63
        fail
 
64
    fi
 
65
done
 
66
 
 
67
##################################
 
68
# blackbox-exporter
 
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
 
73
    if [ $? -ne 0 ]; then
 
74
        fail
 
75
    fi
 
76
done
 
77
 
 
78
##################################
 
79
# grafana
 
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
 
84
    if [ $? -ne 0 ]; then
 
85
        fail
 
86
    fi
 
87
    curl -f -s -S -g http://${UNIT}:3000/|grep "<title>Grafana</title>"
 
88
    if [ $? -ne 0 ]; then
 
89
        fail
 
90
    fi
 
91
done
 
92
 
 
93
# If we are here it means all checks passed
33
94
echo "#####################"
34
95
echo "# E2E Checks Passed #"
35
96
echo "#####################"