aboutsummaryrefslogtreecommitdiffstats
path: root/roles/run-ci/tasks/grafana_start.yml
diff options
context:
space:
mode:
Diffstat (limited to 'roles/run-ci/tasks/grafana_start.yml')
-rw-r--r--roles/run-ci/tasks/grafana_start.yml42
1 files changed, 42 insertions, 0 deletions
diff --git a/roles/run-ci/tasks/grafana_start.yml b/roles/run-ci/tasks/grafana_start.yml
new file mode 100644
index 0000000..183a439
--- /dev/null
+++ b/roles/run-ci/tasks/grafana_start.yml
@@ -0,0 +1,42 @@
+---
+- block:
+ - name: get start time (epoch+milliseconds)
+ set_fact:
+ time_start: "{{ lookup('pipe', 'date +%s%N | head -c 13' ) | int }}"
+
+ - name: set tags
+ set_fact:
+ grafana_tags: "{{ [ inventory_hostname ] }}"
+
+ - name: add inpod in tags
+ set_fact:
+ grafana_tags: "{{ grafana_tags + [ inpod ] }}"
+ when: inpod is defined
+
+ - name: "Create a grafana annotation"
+ uri:
+ url: "{{ grafana.api | regex_replace('\\/$', '') }}/annotations"
+ method: POST
+ status_code: 200
+ body_format: "json"
+ body: "{{
+ {
+ 'time': time_start | int,
+ 'isRegion': true,
+ 'timeEnd': (time_start | int + 10000000),
+ 'tags': grafana_tags,
+ 'title': step,
+ 'text': text
+ }
+ }}"
+ headers:
+ Content-Type: "application/json"
+ Accept: "application/json"
+ Authorization: "Bearer {{ grafana.token }}"
+ register: grafana_events
+ vars:
+ text:
+ "<a href=\"{{ pipeline_url }}\">{{ step }}</a> running"
+
+ delegate_to: "{{ grafana.jumphost }}"
+ ignore_errors: true