Skip to content

Commit

Permalink
refactor(#3112): replace fixed timout by dynamic alert searching.
Browse files Browse the repository at this point in the history
Signed-off-by: Mauro Malara <[email protected]>
  • Loading branch information
mauromalara committed Sep 1, 2022
1 parent c80948d commit eb541ae
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,16 @@
- name: "{{ event_description }}"
shell: "{{ command }}"

- name: Wait for alerts to be generated
wait_for:
timeout: 5
- name: Search alert in alerts log
include_role:
name: manage_alerts
tasks_from: search_alert.yaml
vars:
timestamp: \d+-\d+-\d+T\d+:\d+:\d+\.\d+[+|-]\d+
custom_regex: ".+timestamp\":\"{{ timestamp }}\",.+level\":{{ rule_level }},\"description\":\
\"{{ rule_description }}\",\"id\":\"{{ rule_id }}\".+osquery\":.+\"name\":\"{{ osquery_name }}\""
attempts: 15
time_btw_attempts: 2

- name: Get alert json
include_role:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
extra:
data.osquery.name: low_free_memory
extra_vars:
rule_id: 24012
rule_description: "osquery: System memory is under 10%"
rule_level: 4
osquery_name: low_free_memory
event_description: Stress system memory
command: >
stress --vm-bytes $(awk '/MemAvailable/{printf "%d\n", $2 * 0.98;}' < /proc/meminfo)k --vm-keep -m 1 -t 60

0 comments on commit eb541ae

Please sign in to comment.