/
purge_logs.yaml
82 lines (81 loc) · 2.31 KB
/
purge_logs.yaml
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
---
version: '2.0'
name: st2-demos.diskspace_remediation
workflows:
main:
input:
- hostname
- directory
- file_extension
- threshold
- event_id
- check_name
- alert_message
- raw_payload
- service
tasks:
silence_check:
# [135, 26]
action: sensu.silence
input:
client: <% $.hostname %>
check: <% $.check_name %>
on-success:
- check_dir_size
on-error:
- victorops_escalation
check_dir_size:
# [205, 128]
action: st2-demos.check_dir_size
input:
hosts: <% $.hostname %>
directory: <% $.directory %>
threshold: <% $.threshold %>
on-error:
- remove_files
on-success:
- victorops_escalation
remove_files:
# [355, 230]
action: core.remote_sudo
input:
hosts: <% $.hostname %>
cmd: "rm -Rfv <% $.directory %>/*<% $.file_extension %>"
on-error:
- victorops_escalation
on-success:
- validate_dir_size: <% $.service == '' %>
- restart_service: <% $.service != '' %>
victorops_escalation:
# [105, 536]
action: victorops.open_incident
input:
severity: "critical"
entity: "<% $.hostname %>"
message: "DemoBot could not autoremediate disk space event on <% $.hostname %>. Alert: <% $.alert_message %>"
validate_dir_size:
# [365, 434]
action: st2-demos.check_dir_size
input:
hosts: <% $.hostname %>
directory: <% $.directory %>
threshold: <% $.threshold %>
on-success:
- post_success_to_slack
on-error:
- victorops_escalation
post_success_to_slack:
# [375, 536]
action: slack.post_message
input:
channel: "#demos"
message: "DemoBot has pruned <% $.directory %> on <% $.hostname %> due to a monitoring event. ID: <% $.event_id %>\nhttp://st2demo002:8080/#/history/<% env().st2_execution_id %>/general"
restart_service:
# [435, 332]
action: linux.service
input:
service: <% $.service %>
hosts: <% $.hostname %>
act: restart
on-success:
- validate_dir_size