Monitoring Suspension Policies
- Last Updated 2/20/2025, 11:22:18 AM UTC
- About 7 min read
Polaris allows to suspend monitoring tasks via policies. Policies define which tasks will be suspended and when they will be suspended. Tasks are suspended on a per agent basis by subscribing agents to policies.
Tasks can be suspended by:
- name (regular expression)
- plugin
- all tasks
The interval over which the policies are enforced can be:
- recurring
- one-off
- on demand
# Enforcement Intervals
# Recurring Enforcement Intervals
These are defined in terms of:
- start time in 24-hour format, e.g., "12:00"
- end time in 24-hour format, e.g., "05:00"
- days of week, optional comma separated list of days of the week or ranges of days of week in
cron-like format. Defaults to all days of the week. e.g.
mon
- only mondaysmon-fri
- mondays to fridaysmon, wed
- mondays and wednesdaysmon-wed, fri
- mondays to wednesdays and fridays
- days of month, optional comma separated list of days of the month or ranges of days of month in
cron-like format. defaults to all days of the month. e.g.
1-5
, days 1 through 51-5, 19
, days 1 through 5 and 19th
- time zone, optional time zone, defaults to local timezone. This can be an IANA Time Zone Database
time zone, e.g.
America/New_York
or an abbreviated time zone, e.g.MST
, where not ambiguous
# One-Off Enforcement Intervals
These are enforced once and are defined in terms of:
- start time in 24-hour format, e.g., "12:00"
- end time in 24-hour format, e.g., "05:00"
- time zone, optional time zone, defaults to local timezone. This can be an IANA Time Zone Database
time zone, e.g.
America/New_York
or an abbreviated time zone, e.g.MST
, where not ambiguous
# On-Demand Enforcement
These policies enforce suspensions immediately and can be activated and deactivated on demand. Activations can have an optional duration over which the policy is enforced, once this duration elapses the policy is deactivated automatically.
# Target Tasks
# By Task Name
These are regular expressions that specify which tasks will be suspended by name. For example SOME_DB_NAME
will suspend all tasks that their name contains SOME_DB_NAME
# By Plugin Name
These specify tasks using specific plugins by a plugin name regular expression. For example specifying sys-mon
will suspend all tasks using plugin names that match sys-mon
.
# Defining Policies and Agent Subscriptions
Policies and their agent subscriptions are defined in a yaml
file which is then submitted to polaris for enforcement. You can add, remove or update policies by exporting the current policies from polaris into a yaml
file, modifying this file and re-submitting it to polaris.
The yaml
structure is a list of policy names with their properties according to enforcement interval and target tasks type:
name
the unique name of the policydescription
describes the policyfrequency_type
enforcement interval, one ofRECURRING
,ONCE
,ON-DEMAND
suspend_type
target tasks, one ofEVERYTHING
,PLUGINS
,TASK_NAMES
plugins_re
list of plugin name regular expressions forsuspend_type
"PLUGINS"task_names_re
list of tasks name regular expression forsuspend_type
"TASK_NAMES"enforce_recurring
recurring period interval for "RECURRING"frequency_type
start_time
start time in 24-hour format, e.g.,12:00
end_time
end time in 24-hour format, e.g.,18:00
days_of_week
optional comma separated list of days of the week or ranges of days of week in cron-like format. Defaults to all days of the weekdays_of_month
optional comma separated list of days of the month or ranges of days of month in cron-like format. defaults to all days of the monthtime_zone
optional time zone, defaults to local timezone. This can be an IANA Time Zone Database or an abbreviated time zone where not ambiguous
enforce_once
one off period interval for "ONCE"frequency_type
start_time
start time in 24-hour format, e.g.,12:00
end_time
end time in 24-hour format, e.g.,18:00
time_zone
optional time zone, defaults to local timezone. This can be an IANA Time Zone Database or an abbreviated time zone where not ambiguous
agents
list of agents to subscribe to this policy
Examples:
Recurring Enforcement Interval by Plugin Names
- name: Example Recurring Plugins Policy description: some description frequency_type: RECURRING suspend_type: PLUGINS plugins_re: - pl1 - pl2 enforce_recurring: start_time: "12:00:00" end_time: "18:01:00" days_of_week: mon-wed days_of_month: "" time_zone: "MST" agents: - one.host.com - another.host.com
Recurring Enforcement Interval by Task Names
- name: Example Recurring Tasks Policy description: some description frequency_type: RECURRING suspend_type: TASK_NAMES task_names_re: - Task Name regexp - Other Task Name regexp enforce_recurring: start_time: "12:00:00" end_time: "18:01:00" days_of_week: mon-wed days_of_month: "" time_zone: "MST" agents: - one.host.com - another.host.com
- Recurring Enforcement Interval for All Tasks
- name: Example Recurring Everything Policy description: some description frequency_type: RECURRING suspend_type: EVERYTHING enforce_recurring: start_time: "12:00:00" end_time: "18:01:00" days_of_week: mon-wed days_of_month: "" time_zone: "MST" agents: - one.host.com - another.host.com
One-Off Enforcement Interval by Task Names
- name: Example One-Off Tasks Policy description: some description frequency_type: ONCE suspend_type: TASK_NAMES task_names_re: - Task Name regexp - Other Task Name regexp enforce_once: start_time: "12:00:00" end_time: "18:01:00" time_zone: "MST" agents: - one.host.com - another.host.com
On-Demand Enforcement by Task Names
- name: Example On-Demand Tasks Policy description: some description frequency_type: ON-DEMAND suspend_type: TASK_NAMES task_names_re: - Task Name regexp - Other Task Name regexp agents: - one.host.com - another.host.com
# Manage Policies with the polaris CLI
The myrmex policies
command is used to manage monitoring suspension policies
$ myrmex policies --help
NAME:
myrmex policies - policies managed monitoring suspension policies
USAGE:
myrmex policies command [command options] [arguments...]
COMMANDS:
ls lists suspension policies
state exports current state of policies and subscriptions ready for sync
activate activates an ON-DEMAND policy
deactivate deactivates an ON-DEMAND policy
sync syncs suspension policies from yaml file
sync-yaml-sample prints a sample sync yaml file
subs lists policy subscriptions
OPTIONS:
--help, -h show help
# List the current policies and subscriptions
$ myrmex policies ls
- id: FVFKYIN4TJCUXDHRP2HG7TWZ5U
name: PeopleSoft Dev Monthly Refresh - TEST-DB1
description: peoplesoft dev monthly database refresh
version: 01JB9NS5BX6HY5N7TGEGFCVY7M
created: "2024-10-28T13:41:53Z"
updated: "2024-10-28T13:41:53Z"
frequency_type: RECURRING
suspend_type: TASK_NAMES
task_names_re:
- TEST-DB1
enforce_recurring:
start_time: "05:30:00"
end_time: "07:30:00"
days_of_month: "1"
time_zone: US/Pacific
- id: QEMQQ5BTWFF7TCJ5JONYQOXHDU
name: PeopleSoft Dev Daily Refresh - TEST-DB2
description: peoplesoft dev daily database refresh
version: 01JB9NTRRKWM7PGQ95DH1RZM35
created: "2024-10-28T13:41:53Z"
updated: "2024-10-28T13:41:53Z"
frequency_type: RECURRING
suspend_type: TASK_NAMES
task_names_re:
- TEST-DB2
enforce_recurring:
start_time: "04:00:00"
end_time: "06:00:00"
time_zone: US/Pacific
# List agent subscriptions to policies
$ myrmex policies subs
- agent_uuid: 06bfea52-eb46-40f6-9893-0ffdd3411192
agent: agent01
policy_uuid: FVFKYIN4TJCUXDHRP2HG7TWZ5U
policy: PeopleSoft Dev Monthly Refresh - TEST-DB1
policy_version: 01JB9NS5BX6HY5N7TGEGFCVY7M
status: STATUS_ACTIVE
added: "2024-10-28T13:41:53Z"
synced: "2024-10-28T13:41:53Z"
- agent_uuid: 06bfea52-eb46-40f6-9893-0ffdd3411192
agent: agent01
policy_uuid: QEMQQ5BTWFF7TCJ5JONYQOXHDU
policy: PeopleSoft Dev Daily Refresh - TEST-DB2
policy_version: 01JB9NTRRKWM7PGQ95DH1RZM35
status: STATUS_ACTIVE
added: "2024-10-28T13:41:53Z"
synced: "2024-10-28T13:42:45Z"
- agent_uuid: 23ea2304-6b9b-4ba7-8277-8a05a0e7c860
agent: agent02
policy_uuid: FVFKYIN4TJCUXDHRP2HG7TWZ5U
policy: PeopleSoft Dev Monthly Refresh - TEST-DB1
policy_version: 01JB9NS5BX6HY5N7TGEGFCVY7M
status: STATUS_ACTIVE
added: "2024-10-28T13:41:53Z"
synced: "2024-10-28T13:41:53Z"
- agent_uuid: 23ea2304-6b9b-4ba7-8277-8a05a0e7c860
agent: agent02
policy_uuid: QEMQQ5BTWFF7TCJ5JONYQOXHDU
policy: PeopleSoft Dev Daily Refresh - TEST-DB2
policy_version: 01JB9NTRRKWM7PGQ95DH1RZM35
status: STATUS_ACTIVE
added: "2024-10-28T13:41:53Z"
synced: "2024-10-28T13:42:45Z"
# Create or modify policies and subscriptions
Use the myrmex policies state
command to get the current policy state and then modify this state and
submit to polaris with myrmex policies sync
# export state
$ myrmex policies state > policies.yaml
# ... modify policies.yaml
# submit state
$ myrmex policies sync policies.yaml
# Activate/Deactivate On-Demand Policies
Activate and deactivate policies by their UUID
(as reported by myrmex policies ls
).
Activations can have an optional duration after which the policy is automatically deactivated.
# activate policy FVFKYIN4TJCUXDHRP2HG7TWZ5U indefinetely
myrmex policies activate FVFKYIN4TJCUXDHRP2HG7TWZ5U
# activate policy FVFKYIN4TJCUXDHRP2HG7TWZ5U for the next 30m
myrmex policies activate FVFKYIN4TJCUXDHRP2HG7TWZ5U 30m
# deactivate policy FVFKYIN4TJCUXDHRP2HG7TWZ5U
myrmex policies deactivate FVFKYIN4TJCUXDHRP2HG7TWZ5U