|
3 | 3 | # Assuming we're in the right project already...
|
4 | 4 | # Following procedure on https://infrawatch.github.io/documentation/#creating-an-alert-rule-in-prometheus_assembly-advanced-features
|
5 | 5 |
|
6 |
| -- name: "RHELOSP-144965 Create the alert" |
7 |
| - ansible.builtin.shell: |
8 |
| - cmd: | |
9 |
| - oc apply -f - <<EOF |
10 |
| - apiVersion: {{ observability_api }}/v1 |
11 |
| - kind: PrometheusRule |
12 |
| - metadata: |
13 |
| - creationTimestamp: null |
14 |
| - labels: |
15 |
| - prometheus: default |
16 |
| - role: alert-rules |
17 |
| - name: prometheus-alarm-rules |
18 |
| - namespace: service-telemetry |
19 |
| - spec: |
20 |
| - groups: |
21 |
| - - name: ./openstack.rules |
22 |
| - rules: |
23 |
| - - alert: Collectd metrics receive rate is zero |
24 |
| - expr: rate(sg_total_collectd_msg_received_count[1m]) == 0 |
25 |
| - EOF |
26 |
| - changed_when: false |
27 |
| - register: cmd_output |
28 |
| - failed_when: cmd_output.rc != 0 |
| 6 | +- name: "Do the test procedure" |
| 7 | + block: |
| 8 | + - name: "RHELOSP-144965 Create the alert" |
| 9 | + ansible.builtin.shell: |
| 10 | + cmd: | |
| 11 | + oc apply -f - <<EOF |
| 12 | + apiVersion: {{ observability_api }}/v1 |
| 13 | + kind: PrometheusRule |
| 14 | + metadata: |
| 15 | + creationTimestamp: null |
| 16 | + labels: |
| 17 | + prometheus: default |
| 18 | + role: alert-rules |
| 19 | + name: fvt-testing-prometheus-alarm-rules |
| 20 | + namespace: service-telemetry |
| 21 | + spec: |
| 22 | + groups: |
| 23 | + - name: ./openstack.rules |
| 24 | + rules: |
| 25 | + - alert: FVT_TESTING Collectd metrics receive rate is zero |
| 26 | + expr: rate(sg_total_collectd_msg_received_count[1m]) == 0 |
| 27 | + EOF |
| 28 | + changed_when: false |
| 29 | + register: cmd_output |
| 30 | + failed_when: cmd_output.rc != 0 |
29 | 31 |
|
30 |
| -- name: "RHELOSP-144480 Check that the alert was created" |
31 |
| - ansible.builtin.command: |
32 |
| - cmd: | |
33 |
| - curl -k {{ prom_auth_string }} https://{{ prom_url }}/api/v1/rules |
34 |
| - register: cmd_output |
35 |
| - changed_when: false |
36 |
| - failed_when: cmd_output.rc != 0 |
| 32 | + - name: "RHELOSP-144480 Check that the alert was created" |
| 33 | + ansible.builtin.command: |
| 34 | + cmd: | |
| 35 | + curl -k {{ prom_auth_string }} https://{{ prom_url }}/api/v1/rules |
| 36 | + register: cmd_output |
| 37 | + changed_when: true |
| 38 | + |
| 39 | + always: |
| 40 | + - name: "Delete the PrometheusRule" |
| 41 | + ansible.builtin.command: |
| 42 | + cmd: | |
| 43 | + oc delete prometheusrule.{{ observability_api }} fvt-testing-prometheus-alarm-rules |
| 44 | + register: delete_prom |
| 45 | + changed_when: delete_prom.rc == 0 |
| 46 | + |
| 47 | + - name: Wait up to two minutes until the rule is deleted |
| 48 | + ansible.builtin.command: |
| 49 | + cmd: | |
| 50 | + curl -k {{ prom_auth_string }} https://{{ prom_url }}/api/v1/rules |
| 51 | + retries: 12 |
| 52 | + delay: 10 |
| 53 | + until: 'not "FVT_TESTING Collectd metrics receive rate is zero" in cmd_output.stdout' |
| 54 | + changed_when: false |
0 commit comments