createMaintenanceWindow
A Graze API POST request that creates a maintenance window. A maintenance window filters alerts caused by a known period of maintenance.
Back to Graze API EndPoint Reference.
Request arguments
Endpoint createMaintenanceWindow
takes the following request arguments:
Name | Type | Required | Description |
---|---|---|---|
| String | Yes | A valid |
| String | Yes | Name of the maintenance window. |
| String | Yes | Description of the maintenance window. |
| String | Yes | SQL-like filter that alerts must match to be included in the maintenance window. If the filter includes a backslash in the filter string, you need to double escape these to maintain the backslash character in the filter string. However, if you have See Filter Search Data for more information on creating SQL-like filters. |
| Number | Yes | Start time of the maintenance window. This must be in Unix epoch time and may be up to 5 years in the future. |
| Number | Yes | Duration of the maintenance window in seconds. The minimum duration is 1 second and the maximum is 157784630 seconds (5 years). |
| Boolean | Yes | Whether or not alerts should be forwarded to the next Moolet in the processing chain. |
| Number | No | |
| Number | No | |
| String | No | Time zone that you want the maintenance window to be created in. Default is the time zone of the user that makes the request. If the user has a "SYSTEM" time zone, Moogsoft Enterprise uses the MoogSvr time zone. The time zone must be a valid entry in the IANA Time Zone Database. When scheduling recurring maintenance windows, Moogsoft Enterprise takes into account any daylight savings time changes for the time zone. |
Response
Endpoint createMaintenanceWindow
returns the following response:
Successful requests return a JSON object containing the following:
Name | Type | Description |
---|---|---|
| Number | ID of the new maintenance window. |
Examples
The following examples demonstrate typical use of endpoint createMaintenanceWindow
:
Request examples
Example cURL request to create a window, which recurs once a month (from its start_date_time), with a filter where the source is "server1" and the external ID is one of "value1", "value2", or "value3":
curl -X POST -u graze:graze -k -v "https://localhost/graze/v1/createMaintenanceWindow" -H "Content-Type: application/json; charset=UTF-8" -d '{"name":"window1", "description":"window1 description here", "filter": "source = \"server1\" and external_id in (\"value1\", \"value2\", \"value3\")", "start_date_time": 1473849237, "duration": 55800, "forward_alerts": false, "recurring_period": 1, "recurring_period_units": 4}'
Example cURL request to create a one-time maintenance window, which is filtered where the source is equal to "hostIsDown":
curl -X POST -u graze:graze -k -v "https://localhost/graze/v1/createMaintenanceWindow" -H "Content-Type: application/json; charset=UTF-8" -d '{"name": "my_window_1", "description": "This is my description", "filter": "source = \"hostIsDown\"", "start_date_time": 1473849237, "duration": 55800, "forward_alerts": false}'
Example cURL request to create a daily maintenance window in the "America/New York" time zone:
curl -X POST -u graze:graze -k -v "https://localhost/graze/v1/createMaintenanceWindow" -H "Content-Type: application/json; charset=UTF-8" -d '{"name":"window", "description":"window with specified timezone", "filter": "source = \"server1\" and external_id in (\"value1\", \"value2\", \"value3\")", "start_date_time": 1564566188, "duration": 3600, "forward_alerts": false, "recurring_period": 1, "recurring_period_units": 2, "timezone": "America/New_York"}'
Example of escaped characters
Example cURL request using multiple escaped backslash characters in the filter to maintain the correct characters in the filter string:
curl -X POST -u graze:graze -k -v "https://localhost/graze/v1/createMaintenanceWindow" -H "application/json; charset=UTF-8" -d '{"name":"LON Server 1", "description":"[10453] ", "filter":"NOT (alert_id IS NULL) AND (agent_location MATCHES \"LON_S1\") AND (custom_info.eventDetails.alert_customer MATCHES \"LON\") AND (manager MATCHES \"LOGFILE\") AND (class MATCHES \"could not execute backup\") AND (custom_info.eventDetails.field_1 MATCHES \"C:\\\\\\\\\\LON_SVR1\\Backup\\2019\")", "start_date_time":1480483478, "duration":86400, "recurring_period_units":2, "recurring_period":1, "forward_alerts":false}'
The endpoint createMaintenanceWindow
creates the correct filter:
((((( NOT (alert_id IS NULL)) AND (`Agent location` MATCHES "LON_S1")) AND (custom_info.eventDetails.alert_customer MATCHES "LON")) AND (Manager MATCHES "LOGFILE")) AND (Class MATCHES "could not execute backup")) AND (custom_info.eventDetails.field_1 MATCHES "C:\\\\LON_SVR1\Backup\2019")
Response example
A successful request returns the ID of the new maintenance window:
{ "window_id":16 }