Skip to main content

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

auth_token

String

Yes

A valid auth_token returned from the authenticate request. Alternatively, basic authenticate headers can be used in place of this parameter. See the authenticate endpoint for more information and usage examples.

name

String

Yes

Name of the maintenance window.

description

String

Yes

Description of the maintenance window.

filter

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 \t, \n, \b, or \r followed by a backslash in the path, you do not need to pass any extra backslashes. See the Example of escaped characters.

See Filter Search Data for more information on creating SQL-like filters.

start_date_time

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.

duration

Number

Yes

Duration of the maintenance window in seconds. The minimum duration is 1 second and the maximum is 157784630 seconds (5 years).

forward_alerts

Boolean

Yes

Whether or not alerts should be forwarded to the next Moolet in the processing chain.

recurring_period

Number

No

recurring_period_units

Number

No

timezone

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

window_id

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
}