blob: 4d5a7e7f13a48d98f7bb1fe61a09fcf09804e2cc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
---
- block:
- name: get end time
set_fact:
time_end: "{{ lookup('pipe', 'date +%s%N | head -c 13' ) | int }}"
- name: calculate duration
set_fact:
duration:
"{{ ((time_end|int) - (time_start|int))/1000 }}"
- name: "update a grafana annotation start"
uri:
url:
"{{ grafana.api | regex_replace('\\/$', '') }}/annotations/{{
grafana_events.json.id }}"
method: PUT
status_code: 200
body_format: "json"
body: "{{
{
'time': time_start | int,
'tags': grafana_tags + [ result ],
'text': text + '<br/>Duration (s): ' + duration
}
}}"
headers:
Content-Type: "application/json"
Accept: "application/json"
Authorization: "Bearer {{ grafana.token }}"
- name: "update a grafana annotation end"
uri:
url:
"{{ grafana.api | regex_replace('\\/$', '') }}/annotations/{{
grafana_events.json.endId }}"
method: PUT
status_code: 200
body_format: "json"
body: "{{
{
'time': time_end | int,
'tags': grafana_tags + [ result ],
'text': text + '<br/>Duration (s): ' + duration
}
}}"
headers:
Content-Type: "application/json"
Accept: "application/json"
Authorization: "Bearer {{ grafana.token }}"
delegate_to: "{{ grafana.jumphost }}"
ignore_errors: true
|