Monitoring Packs And Map Policies
Monitoring Packs and Map Policies API allows us to get and set various properties of Monitoring Packs and Map Policies; additionally, it can be used to get a list of nodes that are using monitoring pack or policy and modify such list by adding and removing nodes.
All requests below can be applied to Monitoring Packs and Map Policies
get-monitoring-pack-properties
Get Monitoring Pack Properties
Get properties of the monitoring pack based on the filter.
GET/api/rest/2/policies/<policy>?properties=<filter>
List Of Additional Monitoring Pack Properties
cURL
curl --url "http://localhost/api/rest/2/policies/CPU?api_key=<your-api-key>&properties=name,status"
Node.js
const http = require('http'); http.get('http://localhost/api/rest/2/policies/CPU?api_key=<your-api-key>&properties=name,status', (res) => { res.setEncoding('utf8'); res.on('error', (error) => { console.log(error) }); res.on('data', (chunk) => { console.log(chunk) }) });
PowerShell
Invoke-RestMethod -Uri "http://localhost/api/rest/2/policies/CPU?api_key=<your-api-key>&properties=name,status"
Python
import requests requests.get('http://localhost/api/rest/2/policies/CPU?api_key=<your-api-key>&properties=name,status')
Parameters
| Name | Description |
|---|---|
| policy | Policy ID, name or path |
| filter | List of properties. Returns all properties if omitted, value is "all" or "*" |
Status Codes
| Status Code | Description |
|---|---|
| 200 | OK |
| 401 | Access denied |
| 404 | Policy not found |
Result
{ "id": 1050, "name": "CPU", "status": "unknown", "stats": { "nodes": { "total": 0, "ok": 0, "unknown": 0, "warning": 0, "error": 0, "alerts": { "active": 0, "las24Hours": { "unacknowledged": 0, "total": 0, "critical": 0, "warning": 0 } } }, "maps": { "total": 2, "ok": 0, "unknown": 0, "warning": 2, "error": 0 } }, "path": "/Monitoring Packs/Operating Systems/Windows/CPU", "isDynamic": true, "isFolder": true, "readOnly": false }
get-monitoring-pack-property
Get Monitoring Pack Property
Get a single property of the monitoring pack.
GET/api/rest/2/policies/<policy>/<property>
List Of Additional Monitoring Pack Properties
cURL
curl --url "http://localhost/api/rest/2/policies/CPU/id?api_key=<your-api-key>"
Node.js
const http = require('http'); http.get('http://localhost/api/rest/2/policies/CPU/id?api_key=<your-api-key>', (res) => { res.setEncoding('utf8'); res.on('error', (error) => { console.log(error) }); res.on('data', (chunk) => { console.log(chunk) }) });
PowerShell
Invoke-RestMethod -Uri "http://localhost/api/rest/2/policies/CPU/id?api_key=<your-api-key>"
Python
import requests requests.get('http://localhost/api/rest/2/policies/CPU/id?api_key=<your-api-key>')
Parameters
| Name | Description |
|---|---|
| policy | Policy ID, name or path |
| property | Name of the property to get |
Status Codes
| Status Code | Description |
|---|---|
| 200 | OK |
| 401 | Access denied |
| 404 | Policy not found |
Result
{ "id": 78 }
set-monitoring-pack-property
Set Monitoring Pack Property
Set a property of the monitoring pack
PUT/api/rest/2/policies/<policy>
cURL
curl --request PUT --url "https://localhost/api/rest/2/policies/1050?api_key=<your-api-key>" --header "Content-Type: application/json" --data "{\"name\": \"New Name\"}"
Node.js
const http = require('http'), options = { method: 'PUT', hostname: 'localhost', path: '/api/rest/2/policies/1050', headers: { 'Content-Type': 'application/json', "x-api-key": '<your-api-key>' } }, viewData = { "name": "New Name" }; const req = http.request(options, (res) => { res.setEncoding('utf8');
res.on('error', (error) => { console.log(error) }); res.on('data', (chunk) => { console.log(chunk) }) }); req.write(JSON.stringify(viewData)); req.end();
PowerShell
$url = "http://localhost/api/rest/2/policies/1050" $viewData = @{ name='New Name' } $body = (ConvertTo-Json $viewData) $hdrs = @{} $hdrs.Add("X-API-KEY","<your-api-key>") $hdrs.Add("Content-Type","application/json") Invoke-RestMethod -Uri $url -Method Put -Body $body -Headers $hdrs
Python
import requests url = 'http://localhost/api/rest/2/policies/1050' data = { "name": "New Name" } headers = { 'Content-Type': 'application/json', 'x-api-key': '<your-api-key>' } requests.put(url=url, data=data, headers=headers)
Parameters
| Name | Description |
|---|---|
| view | Policy ID, name or path |
| property | Name of policy property to set |
Status Codes
| Status Code | Description |
|---|---|
| 200 | OK |
| 401 | Access denied |
| 404 | Policy not found |
Result
{ "status":"ok" }
enable-monitoring-pack
Enable Monitoring Pack
Enable all alerting and data collection of the monitoring pack
PUT/api/rest/2/policies/<policy>/enable
cURL
curl --request PUT --url "https://localhost/api/rest/2/policies/1050/enable?api_key=<your-api-key>"
Node.js
const http = require('http'), options = { method: 'PUT', hostname: 'localhost', path: '/api/rest/2/policies/1050/enable', headers: { 'Content-Type': 'application/json', "x-api-key": '<your-api-key>' } }; const req = http.request(options, (res) => { res.setEncoding('utf8'); res.on('error', (error) => { console.log(error) }); res.on('data', (chunk) => { console.log(chunk) }) }); req.end();
PowerShell
$url = "http://localhost/api/rest/2/policies/1050/enable" $hdrs = @{} $hdrs.Add("X-API-KEY","<your-api-key>") $hdrs.Add("Content-Type","application/json") Invoke-RestMethod -Uri $url -Method Put -Headers $hdrs
Python
import requests url = 'http://localhost/api/rest/2/policies/1050/enable' headers = { 'Content-Type': 'application/json', 'x-api-key': '<your-api-key>' } requests.put(url=url, headers=headers)
Parameters
| Name | Description |
|---|---|
| view | View ID, name or path |
Status Codes
| Status Code | Description |
|---|---|
| 200 | OK |
| 401 | Access denied |
| 404 | Policy not found |
Result
{ "status":"ok" }
disable-monitoring-pack
Disable Monitoring Pack
Disable all alerting and data collection of the monitoring pack
PUT/api/rest/2/policies/<policy>/disable
cURL
curl --request PUT --url "https://localhost/api/rest/2/policies/1050/disable?api_key=<your-api-key>"
Node.js
const http = require('http'), options = { method: 'PUT', hostname: 'localhost', path: '/api/rest/2/policies/1050/disable', headers: { 'Content-Type': 'application/json', "x-api-key": '<your-api-key>' } }; const req = http.request(options, (res) => { res.setEncoding('utf8'); res.on('error', (error) => { console.log(error) }); res.on('data', (chunk) => { console.log(chunk) }) }); req.end();
PowerShell
$url = "http://localhost/api/rest/2/policies/1050/disable" $hdrs = @{} $hdrs.Add("X-API-KEY","<your-api-key>") $hdrs.Add("Content-Type","application/json") Invoke-RestMethod -Uri $url -Method Put -Headers $hdrs
Python
import requests url = 'http://localhost/api/rest/2/policies/1050/disable' headers = { 'Content-Type': 'application/json', 'x-api-key': '<your-api-key>' } requests.put(url=url, headers=headers)
Parameters
| Name | Description |
|---|---|
| policy | Policy ID, name or path |
Status Codes
| Status Code | Description |
|---|---|
| 200 | OK |
| 401 | Access denied |
| 404 | Policy not found |
Result
{ "status":"ok" }
get-list-of-nodes-of-the-monitoring-pack
Get List of Nodes of the Monitoring Pack
Get all nodes that belong to the monitoring pack.
GET/api/rest/2/policies/<policy>/nodes
cURL
curl --url "http://localhost/api/rest/2/policies/CPU/nodes?api_key=<your-api-key>"
Node.js
const http = require('http'); http.get('http://localhost/api/rest/2/policies/CPU/nodes?api_key=<your-api-key>', (res) => { res.setEncoding('utf8'); res.on('error', (error) => { console.log(error) }); res.on('data', (chunk) => { console.log(chunk) }) });
PowerShell
Invoke-RestMethod -Uri "http://localhost/api/rest/2/policies/CPU/nodes?api_key=<your-api-key>"
Python
import requests requests.get('http://localhost/api/rest/2/policies/CPU/nodes?api_key=<your-api-key>')
Parameters
| Name | Description |
|---|---|
| policy | Name ID or path to the policy |
Status Codes
| Status Code | Description |
|---|---|
| 200 | OK |
| 401 | Access denied |
| 404 | Policy not found |
Result
[ {"id":1019,"name":"foo","networkAddress":"192.168.1.89","dnsName":"foo.test.com"}, {"id":1019,"name":"bar","networkAddress":"192.168.1.10","dnsName":"bar.test.com"} ]
add-node-to-the-monitoring-pack
Add Node To the Monitoring Pack
Add node to the monitoring pack (applies to manual monitoring packs only)
POST/api/rest/2/policies/<view>/nodes/<node>
cURL
curl --request POST --url "https://localhost/api/rest/2/policies/CPU/nodes/192.168.1.10?api_key=<your-api-key>"
Node.js
const http = require('http'), querystring = require('querystring'), options = { method: 'POST', hostname: 'localhost', path: '/api/rest/2/policies/CPU/nodes/192.168.1.10' , headers: { "x-api-key": '<your-api-key>' } }; const req = http.request(options, (res) => { res.setEncoding('utf8'); res.on('error', (error) => { console.log(error) }); res.on('data', (chunk) => { console.log(chunk) }) }); req.end();
PowerShell
$url = "http://localhost/api/rest/2/policies/CPU/nodes/192.168.1.10" $hdrs = @{} $hdrs.Add("X-API-KEY","<your-api-key>") $hdrs.Add("Content-Type","application/json") Invoke-RestMethod -Uri $url -Method Post -Headers $hdrs
Python
import requests url = 'http://localhost/api/rest/2/policies/CPU/nodes/192.168.1.10' headers = { 'Content-Type': 'application/json', 'x-api-key': '<your-api-key>' } response = requests.post(url=url, headers=headers)
Parameters
| Name | Description |
|---|---|
| view | Name ID or path to the policy |
| node | ID, name or IP address of the node to add |
Status Codes
| Status Code | Description |
|---|---|
| 200 | OK |
| 401 | Access denied |
| 404 | Policy or node not found |
Result
{ "status":"ok" }
remove-node-from-the-monitoring-pack
Remove Node from the Monitoring Pack
Remove a node from the monitoring pack (applies to manual monitoring packs only)
DELETE/api/rest/2/policies/<policy>/nodes/<node>
cURL
curl --request DELETE --url "https://localhost/api/rest/2/policies/CPU/nodes/192.168.1.10?api_key=<your-api-key>"
Node.js
const http = require('http'), querystring = require('querystring'), options = { method: 'DELETE', hostname: 'localhost', path: '/api/rest/2/policies/CPU/nodes/192.168.1.10' , headers: { "x-api-key": '<your-api-key>' } }; const req = http.request(options, (res) => { res.setEncoding('utf8'); res.on('error', (error) => { console.log(error) }); res.on('data', (chunk) => { console.log(chunk) }) }); req.end();
PowerShell
$url = "http://localhost/api/rest/2/policies/CPU/nodes/192.168.1.10" $hdrs = @{} $hdrs.Add("X-API-KEY","<your-api-key>") $hdrs.Add("Content-Type","application/json") Invoke-RestMethod -Uri $url -Method Delete -Headers $hdrs
Python
import requests url = 'http://localhost/api/rest/2/policies/CPU/nodes/192.168.1.10' headers = { 'Content-Type': 'application/json', 'x-api-key': '<your-api-key>' } response = requests.delete(url=url, headers=headers)
Parameters
| Name | Description |
|---|---|
| policy | Name ID or path to the policy |
| node | ID, name or IP address of the node to remove |
Status Codes
| Status Code | Description |
|---|---|
| 200 | OK |
| 401 | Access denied |
| 404 | Policy or node not found |
Result
{ "status":"ok" }