Laravel Forge JavaScript SDK

Monitoring

Monitoring

Server monitoring is only available on the Business plan.

Create a monitor

Method

forge.monitors.create(server_id, payload)

Usage

1const forge = new Forge('API_TOKEN');
2
3const monitor = await forge.monitors.create(server_id, payload);

Payload

1{
2 type: 'cpu_load',
3 operator: 'gte',
4 threshold: '1.3',
5 minutes: '5',
6 notify: 'email@example.com'
7}

Available Monitors

Monitors work on a % value.

KeyDescription
diskThe used disk space
used_memoryThe amount of used memory
cpu_loadThe CPU load

Operators

  • gte - greater than or equal to
  • lte - less than or equal to

Example Response

1{
2 "monitor": {
3 "id": 8,
4 "status": "installed",
5 "type": "disk",
6 "operator": "lte",
7 "threshold": 25,
8 "minutes": 0,
9 "state": "OK",
10 "state_changed_at": "2020-03-01 12:45:00"
11 }
12}

List monitors

Method

forge.monitors.list(server_id)

Usage

1const forge = new Forge('API_TOKEN');
2
3const monitors = await forge.monitors.list(server_id);

Example Response

1{
2 "monitors": [
3 {
4 "id": 3,
5 "status": "installed",
6 "type": "free_memory",
7 "operator": "lte",
8 "threshold": 70,
9 "minutes": 5,
10 "state": "ALERT",
11 "state_changed_at": "2020-03-01 12:45:00"
12 },
13 {
14 "id": 7,
15 "status": "installed",
16 "type": "disk",
17 "operator": "lte",
18 "threshold": 25,
19 "minutes": 0,
20 "state": "OK",
21 "state_changed_at": "2020-03-01 12:45:00"
22 }
23 ]
24}

Get a monitor

Method

forge.monitors.get(server_id, monitor_id)

Usage

1const forge = new Forge('API_TOKEN');
2
3const monitor = await forge.monitors.get(server_id, monitor_id);

Example Response

1{
2 "monitor": {
3 "id": 3,
4 "status": "installed",
5 "type": "free_memory",
6 "operator": "lte",
7 "threshold": 70,
8 "minutes": 5,
9 "state": "ALERT",
10 "state_changed_at": "2020-03-01 12:45:00"
11 }
12}

Delete a monitor

Method

forge.monitors.delete(server_id, monitor_id)

Usage

1const forge = new Forge('API_TOKEN');
2
3await forge.monitors.delete(server_id, monitor_id);

Edit this page on GitHub