A monitor resource represents a monitor inside MaxScale that monitors one or
more servers.
Resource Operations
Get a monitor
GET /v1/monitors/:name
Get a single monitor. The :name in the URI must be a valid monitor name with
all whitespace replaced with hyphens. The monitor names are case-sensitive.
All monitor parameters can be defined at creation time.
The following example defines a request body which creates a new monitor and
assigns two servers to be monitored by it. It also defines a custom value for
the monitor_interval parameter.
{
data: {
"id": "test-monitor", // Name of the monitor
"type": "monitors",
"attributes": {
"module": "mariadbmon", // The monitor uses the mariadbmon module
"parameters": { // Monitor parameters
"monitor_interval": 1000,
"user": "maxuser,
"password": "maxpwd"
}
},
"relationships": { // List of server relationships that this monitor uses
"servers": {
"data": [ // This monitor uses two servers
{
"id": "server1",
"type": "servers"
},
{
"id": "server2",
"type": "servers"
}
]
}
}
}
}
Response
Monitor is created:
Status: 204 No Content
Update a monitor
PATCH /v1/monitors/:name
The :name in the URI must map to a monitor name with all whitespace replaced
with hyphens. The request body must be a valid JSON document representing the
modified monitor.
Modifiable Fields
The following standard server parameter can be modified.
In addition to these standard parameters, the monitor specific parameters can
also be modified. Refer to the monitor module documentation for details on these
parameters.
Response
Monitor is modified:
Status: 204 No Content
Invalid request body:
Status: 403 Forbidden
Update monitor relationships
PATCH /v1/monitors/:name/relationships/servers
The :name in the URI must map to a monitor name with all whitespace replaced
with hyphens.
The request body must be a JSON object that defines only the data field. The
value of the data field must be an array of relationship objects that define
the id and type fields of the relationship. This object will replace the
existing relationships of the monitor.
The following is an example request and request body that defines a single
server relationship for a monitor.
All relationships for a monitor can be deleted by sending an empty array as thedata field value. The following example removes all servers from a monitor.