Monitor API
The Notehub monitor API provides RESTful methods that can be used to manage project alerts.
Name | HTTP Request |
---|---|
Get Monitors | GET /v1/projects/{projectUID}/monitors |
Get Monitor | GET /v1/projects/{projectUID}/monitors/{monitorUID} |
Create Monitor | POST /v1/projects/{projectUID}/monitors |
Delete Monitor | DELETE /v1/projects/{projectUID}/monitors/{monitorUID} |
Update Monitor | PUT /v1/projects/{projectUID}/monitors/{monitorUID} |
Get Monitors Notehub
Get all alert monitors for a Notehub project.
HTTP Method: | GET |
URL: | https://api.notefile.net/v1/projects/{projectUID}/monitors |
Path Parameters: |
|
Minimum Notehub project-level role: | viewer |
Required HTTP Headers: | Authorization: Bearer <access_token> , where the access token is a Notehub API bearer token. |
curl -X GET
-L 'https://api.notefile.net/v1/projects/<projectUID>/monitors'
-H 'Authorization: Bearer <access_token>'
import * as NotehubJs from "@blues-inc/notehub-js";
let defaultClient = NotehubJs.ApiClient.instance;
// Configure API key authorization: api_key
let api_key = defaultClient.authentications["api_key"];
api_key.apiKey = "YOUR API KEY";
let apiInstance = new NotehubJs.MonitorApi();
let projectUID = "app:2606f411-dea6-44a0-9743-1130f57d77d8"; // String |
apiInstance.getMonitors(projectUID).then((data) => {
console.log("API called successfully. Returned data: " + JSON.stringify(data));
}, (error) => {
console.error(error);
});
import notehub_py
from notehub_py.models.monitor import Monitor
from notehub_py.rest import ApiException
from pprint import pprint
# Defining the host is optional and defaults to https://api.notefile.net
configuration = notehub_py.Configuration(
host = "https://api.notefile.net"
)
# Configure API key authorization: api_key
configuration.api_key["api_key"] = os.environ["API_KEY"]
# Enter a context with an instance of the API client
with notehub_py.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = notehub_py.MonitorApi(api_client)
project_uid = "app:2606f411-dea6-44a0-9743-1130f57d77d8" # str |
try:
api_response = api_instance.get_monitors(project_uid)
print("The response of MonitorApi->get_monitors:\n")
pprint(api_response)
except Exception as e:
print("Exception when calling MonitorApi->get_monitors: %s\n" % e)
Response Members
monitors
array
An array of all monitors on the specified Notehub project. See Get Monitor for a full description of the fields returned.
{
"monitors": [
{
"uid": "monitor:8d19ed7e-36ae-43a1-9bb3-443bef9c02c1",
"name": "test-monitor",
"description": "monitor description",
"disabled": true,
"silenced": true,
"notefile_filter": [
"_track.qo"
],
"source_selector": "temperature",
"condition_type": "equal_to",
"alert_routes": [
{
"email": "test@blues.com"
},
],
"last_routed_at": "2024-06-01 01:23:45 +0000 UTC",
"routing_cooldown_period": "5m0s",
"aggregate_function": "none",
"aggregate_window": "0s"
},
...
]
}
Get Monitor Notehub
Get an alert monitor for a Notehub project.
HTTP Method: | GET |
URL: | https://api.notefile.net/v1/projects/{projectUID}/monitors/{monitorUID} |
Path Parameters: |
|
Minimum Notehub project-level role: | viewer |
Required HTTP Headers: | Authorization: Bearer <access_token> , where the access token is a Notehub API bearer token. |
curl -X GET
-L 'https://api.notefile.net/v1/projects/<projectUID>/monitors/<monitorUID>'
-H 'Authorization: Bearer <access_token>'
import * as NotehubJs from "@blues-inc/notehub-js";
let defaultClient = NotehubJs.ApiClient.instance;
// Configure API key authorization: api_key
let api_key = defaultClient.authentications["api_key"];
api_key.apiKey = "YOUR API KEY";
let apiInstance = new NotehubJs.MonitorApi();
let projectUID = "app:2606f411-dea6-44a0-9743-1130f57d77d8"; // String |
let monitorUID = "monitor:8bAdf00d-000f-51c-af-01d5eaf00dbad"; // String |
apiInstance.getMonitor(projectUID, monitorUID).then((data) => {
console.log("API called successfully. Returned data: " + JSON.stringify(data));
}, (error) => {
console.error(error);
});
import notehub_py
from notehub_py.models.monitor import Monitor
from notehub_py.rest import ApiException
from pprint import pprint
# Defining the host is optional and defaults to https://api.notefile.net
configuration = notehub_py.Configuration(
host = "https://api.notefile.net"
)
# Configure API key authorization: api_key
configuration.api_key["api_key"] = os.environ["API_KEY"]
# Enter a context with an instance of the API client
with notehub_py.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = notehub_py.MonitorApi(api_client)
project_uid = "app:2606f411-dea6-44a0-9743-1130f57d77d8" # str |
monitor_uid = "monitor:8bAdf00d-000f-51c-af-01d5eaf00dbad" # str |
try:
api_response = api_instance.get_monitor(project_uid, monitor_uid)
print("The response of MonitorApi->get_monitor:\n")
pprint(api_response)
except Exception as e:
print("Exception when calling MonitorApi->get_monitor: %s\n" % e)
Response Members
uid
string
The globally-unique identifier for the monitor.
name
string
The name of the monitor.
description
string
The description of the monitor.
disabled
boolean
Whether the monitor is disabled.
silenced
boolean
Whether the monitor is silenced.
notefile_filter
array
An array of the Notefile names the monitor is based on.
source_selector
string
The JSONata expression that selects the value to monitor from the source
Notefile's body
.
condition_type
string
The type of condition to apply to the value selected by the source_selector
.
alert_routes
array
An array of entities to notify when an alert is triggered.
last_routed_at
date
An ISO 8601 date for the last time the monitor was evaluated and routed.
routing_cooldown_period
string
The time period Notehub will wait before routing another event after the monitor has been triggered.
{
"uid": "monitor:8d19ed7e-36ae-43a1-9bb3-443bef9c02c1",
"name": "test-monitor",
"description": "monitor description",
"disabled": true,
"silenced": true,
"notefile_filter": [
"_track.qo"
],
"source_selector": "temperature",
"condition_type": "equal_to",
"alert_routes": [
{
"email": "test@blues.com"
},
],
"last_routed_at": "2024-06-01 01:23:45 +0000 UTC",
"routing_cooldown_period": "5m0s",
"aggregate_function": "none",
"aggregate_window": "0s"
}
Create Monitor Notehub
Create an alert monitor for a Notehub project.
HTTP Method: | POST |
URL: | https://api.notefile.net/v1/projects/{projectUID}/monitors |
Path Parameters: |
|
Minimum Notehub project-level role: | developer |
Required HTTP Headers: | Authorization: Bearer <access_token> , where the access token is a Notehub API bearer token. |
name
string
The name of the monitor.
description
string
The description of the monitor.
disabled
boolean (optional)
If true
, the monitor will be disabled in Notehub.
This argument defaults to false
.
silenced
boolean (optional)
If true
, this monitor will not send alerts.
This argument defaults to false
.
fleet_filter
array (optional)
An array of FleetUID to monitor.
notefile_filter
array
An array of Notefiles names you want the monitor to be based on.
source_selector
string
A valid JSONata expression
that selects the value to monitor from the source Notefile's body
. For example,
"temperature"
would select the body.temperature
field from all monitored Notefiles.
The expression must evaluate to a single, numeric value.
condition_type
string
The type of condition to apply to the value selected by the source_selector
. Possible
values are "greater_than"
, "greater_than_or_equal_to"
, "less_than"
,
"less_than_or_equal_to"
, "equal_to"
, and "not_equal_to"
.
This argument defaults to "greater_than"
.
threshold
number
The numeric threshold to apply to the value selected by the source_selector
.
alert_routes
array
An array of entities to notify when an alert is triggered. There are three types of entities you can provide.
To add an email notification add an object with a key of email
and a value of the
email address you'd like to use.
{"email":"your.email@blues.com"}
Slack Webhook
To add a Slack webhook notification add an object with url
, message_type
, and
text
properties.
Learn more about these properties in Slack Webhook Routes.
{"url":"hooks.slack.com/...", "message_type": "text|blocks", "text": "Message Text"}
Slack Bearer
To add a Slack bearer notification add an object with token
, channel
,
message_type
and text
properties.
Learn more about these properties in Slack Bearer Routes.
{"token":"<your-token>", "channel": "CXXXXXXXXXX", "message_type": "text|blocks", "text": "Message Text"}
aggregate_function
string (optional)
An optional aggregate function to apply to the selected values before applying the
condition. Available values "none"
, "sum"
, "average"
, "max"
, "min"
.
This arguments defaults to "none"
.
aggregate_window
string (optional)
The time window to aggregate the selected values when an aggregate function is
applied. The value you provide must be a number followed by a time unit. For example,
10m
for 10 minutes, 10m30s
for 10 minutes and 30 seconds, or 5hr30m10s
for
5 hours 30 minutes 10 seconds.
per_device
boolean (optional)
If enabled and an aggregate function is applied, the monitor will be evaluated per device rather than across all available devices.
This argument defaults to false
.
routing_cooldown_period
string (optional)
The time period to wait before routing another event after the monitor has been
triggered. The value you provide must be a number followed by a time unit. For example,
10m
for 10 minutes, 10m30s
for 10 minutes and 30 seconds, or 5hr30m10s
for
5 hours 30 minutes 10 seconds.
This argument defaults to 5m0s
.
curl -X POST
-L 'https://api.notefile.net/v1/projects/<projectUID>/monitors'
-H 'Authorization: Bearer <access_token>'
-d '{"name":"<name>", "description": "<description>","notefile_filter":["data.qo"],"source_selector":"temperature","condition_type":"greater_than","threshold":100,"alert_routes":[{"email":"<email>"}]}'
import * as NotehubJs from "@blues-inc/notehub-js";
let defaultClient = NotehubJs.ApiClient.instance;
// Configure API key authorization: api_key
let api_key = defaultClient.authentications["api_key"];
api_key.apiKey = "YOUR API KEY";
let apiInstance = new NotehubJs.MonitorApi();
let projectUID = "app:2606f411-dea6-44a0-9743-1130f57d77d8"; // String |
let monitorProps = {
name: "Monitor Name", // String |
description: "Monitor Description", // String |
notefileFilter: ["data.qo"], // [String] |
sourceSelector: "temperature", // String |
conditionType: "greater_than", // String |
threshold: 100, // Number |
alertRoutes: [
{
email: "example@blues.com"
}
] // [MonitorAlertRoutes] |
}
let monitor = new NotehubJs.CreateMonitor(monitorProps); // Monitor | Body or payload of monitor to be created
apiInstance.createMonitor(projectUID, monitor).then((data) => {
console.log("API called successfully. Returned data: " + JSON.stringify(data));
}, (error) => {
console.error(error);
});
import notehub_py
from notehub_py.models.create_monitor import CreateMonitor
from notehub_py.models.monitor import Monitor
from notehub_py.rest import ApiException
from pprint import pprint
# Defining the host is optional and defaults to https://api.notefile.net
configuration = notehub_py.Configuration(
host = "https://api.notefile.net"
)
# Configure API key authorization: api_key
configuration.api_key["api_key"] = os.environ["API_KEY"]
# Enter a context with an instance of the API client
with notehub_py.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = notehub_py.MonitorApi(api_client)
project_uid = "app:2606f411-dea6-44a0-9743-1130f57d77d8" # str |
monitor_props = {
"name": "Monitor Name", # str |
"description": "Monitor Description", # str |
"source_type": "event", # str |
"disabled": False, # bool |
"alert": False, # bool |
"notefile_filter": ["data.qo"], # List[str] |
"source_selector": "temperature", # str |
"condition_type": "greater_than", # str |
"threshold": 100, # int |
"alert_routes": [
{
"email": "example@blues.com" # str |
}
],
"silenced": False, # bool |
"routing_cooldown_period": "5m0s", # str |
"per_device": False # bool |
}
create_monitor = notehub_py.CreateMonitor(monitor_props) # CreateMonitor | Body or payload of monitor to be created
try:
api_response = api_instance.create_monitor(project_uid, create_monitor)
print("The response of MonitorApi->create_monitor:\n")
pprint(api_response)
except Exception as e:
print("Exception when calling MonitorApi->create_monitor: %s\n" % e)
Response Members
uid
string
The globally-unique identifier for the monitor.
name
string
The name of the monitor.
description
string
The description of the monitor.
disabled
boolean
Whether the monitor is disabled.
silenced
boolean
Whether the monitor is silenced.
notefile_filter
array
An array of the Notefile names the monitor is based on.
source_selector
string
The JSONata expression that selects the value to monitor from the source
Notefile's body
.
condition_type
string
The type of condition to apply to the value selected by the source_selector
.
alert_routes
array
An array of entities to notify when an alert is triggered.
last_routed_at
date
An ISO 8601 date for the last time the monitor was evaluated and routed.
routing_cooldown_period
string
The time period Notehub will wait before routing another event after the monitor has been triggered.
{
"uid": "monitor:8d19ed7e-36ae-43a1-9bb3-443bef9c02c1",
"name": "test-monitor",
"description": "monitor description",
"disabled": true,
"silenced": true,
"notefile_filter": [
"_track.qo"
],
"source_selector": "temperature",
"condition_type": "equal_to",
"alert_routes": [
{
"email": "test@blues.com"
},
],
"last_routed_at": "2024-06-01 01:23:45 +0000 UTC",
"routing_cooldown_period": "5m0s",
"aggregate_function": "none",
"aggregate_window": "0s"
}
Delete Monitor Notehub
Delete an alert monitor for a Notehub project.
HTTP Method: | DELETE |
URL: | https://api.notefile.net/v1/projects/{projectUID}/monitors/{monitorUID} |
Path Parameters: |
|
Minimum Notehub project-level role: | developer |
Required HTTP Headers: | Authorization: Bearer <access_token> , where the access token is a Notehub API bearer token. |
curl -X DELETE
-L 'https://api.notefile.net/v1/projects/<projectUID>/monitors/<monitorUID>'
-H 'Authorization: Bearer <access_token>'
import * as NotehubJs from "@blues-inc/notehub-js";
let defaultClient = NotehubJs.ApiClient.instance;
// Configure API key authorization: api_key
let api_key = defaultClient.authentications["api_key"];
api_key.apiKey = "YOUR API KEY";
let apiInstance = new NotehubJs.MonitorApi();
let projectUID = "app:2606f411-dea6-44a0-9743-1130f57d77d8"; // String |
let monitorUID = "monitor:8bAdf00d-000f-51c-af-01d5eaf00dbad"; // String |
apiInstance.deleteMonitor(projectUID, monitorUID).then((data) => {
console.log("API called successfully. Returned data: " + JSON.stringify(data));
}, (error) => {
console.error(error);
});
import notehub_py
from notehub_py.models.monitor import Monitor
from notehub_py.rest import ApiException
from pprint import pprint
# Defining the host is optional and defaults to https://api.notefile.net
configuration = notehub_py.Configuration(
host = "https://api.notefile.net"
)
# Configure API key authorization: api_key
configuration.api_key["api_key"] = os.environ["API_KEY"]
# Enter a context with an instance of the API client
with notehub_py.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = notehub_py.MonitorApi(api_client)
project_uid = "app:2606f411-dea6-44a0-9743-1130f57d77d8" # str |
monitor_uid = "monitor:8bAdf00d-000f-51c-af-01d5eaf00dbad" # str |
try:
api_response = api_instance.delete_monitor(project_uid, monitor_uid)
print("The response of MonitorApi->delete_monitor:\n")
pprint(api_response)
except Exception as e:
print("Exception when calling MonitorApi->delete_monitor: %s\n" % e)
Response Members
{}
means success.Update Monitor Notehub
Update an alert monitor for a Notehub project.
HTTP Method: | PUT |
URL: | https://api.notefile.net/v1/projects/{projectUID}/monitors/{monitorUID} |
Path Parameters: |
|
Minimum Notehub project-level role: | developer |
Required HTTP Headers: | Authorization: Bearer <access_token> , where the access token is a Notehub API bearer token. |
name
string
The name of the monitor.
description
string
The description of the monitor.
disabled
boolean (optional)
If true
, the monitor will be disabled in Notehub.
This argument defaults to false
.
silenced
boolean (optional)
If true
, this monitor will not send alerts.
This argument defaults to false
.
fleet_filter
array (optional)
An array of FleetUID to monitor.
notefile_filter
array
An array of Notefiles names you want the monitor to be based on.
source_selector
string
A valid JSONata expression
that selects the value to monitor from the source Notefile's body
. For example,
"temperature"
would select the body.temperature
field from all monitored Notefiles.
The expression must evaluate to a single, numeric value.
condition_type
string
The type of condition to apply to the value selected by the source_selector
. Possible
values are "greater_than"
, "greater_than_or_equal_to"
, "less_than"
,
"less_than_or_equal_to"
, "equal_to"
, and "not_equal_to"
.
This argument defaults to "greater_than"
.
threshold
number
The numeric threshold to apply to the value selected by the source_selector
.
alert_routes
array
An array of entities to notify when an alert is triggered. There are three types of entities you can provide.
To add an email notification add an object with a key of email
and a value of the
email address you'd like to use.
{"email":"your.email@blues.com"}
Slack Webhook
To add a Slack webhook notification add an object with url
, message_type
, and
text
properties.
Learn more about these properties in Slack Webhook Routes.
{"url":"hooks.slack.com/...", "message_type": "text|blocks", "text": "Message Text"}
Slack Bearer
To add a Slack bearer notification add an object with token
, channel
,
message_type
and text
properties.
Learn more about these properties in Slack Bearer Routes.
{"token":"<your-token>", "channel": "CXXXXXXXXXX", "message_type": "text|blocks", "text": "Message Text"}
aggregate_function
string (optional)
An optional aggregate function to apply to the selected values before applying the
condition. Available values "none"
, "sum"
, "average"
, "max"
, "min"
.
This arguments defaults to "none"
.
aggregate_window
string (optional)
The time window to aggregate the selected values when an aggregate function is
applied. The value you provide must be a number followed by a time unit. For example,
10m
for 10 minutes, 10m30s
for 10 minutes and 30 seconds, or 5hr30m10s
for
5 hours 30 minutes 10 seconds.
per_device
boolean (optional)
If enabled and an aggregate function is applied, the monitor will be evaluated per device rather than across all available devices.
This argument defaults to false
.
routing_cooldown_period
string (optional)
The time period to wait before routing another event after the monitor has been
triggered. The value you provide must be a number followed by a time unit. For example,
10m
for 10 minutes, 10m30s
for 10 minutes and 30 seconds, or 5hr30m10s
for
5 hours 30 minutes 10 seconds.
This argument defaults to 5m0s
.
curl -X PUT
-L 'https://api.notefile.net/v1/projects/<projectUID>/monitors/<monitorUID>'
-H 'Authorization: Bearer <access_token>'
-d '{"name":"<name>", "description": "<description>","notefile_filter":["data.qo"],"source_selector":"temperature","condition_type":"greater_than","threshold":100,"alert_routes":[{"email":"<email>"}]}'
import * as NotehubJs from "@blues-inc/notehub-js";
let defaultClient = NotehubJs.ApiClient.instance;
// Configure API key authorization: api_key
let api_key = defaultClient.authentications["api_key"];
api_key.apiKey = "YOUR API KEY";
let apiInstance = new NotehubJs.MonitorApi();
let projectUID = "app:2606f411-dea6-44a0-9743-1130f57d77d8"; // String |
let monitorUID = "monitor:8bAdf00d-000f-51c-af-01d5eaf00dbad"; // String |
let monitorProps = {
name: "Monitor Name", // String |
description: "Monitor Description", // String |
notefileFilter: ["data.qo"], // [String] |
sourceSelector: "temperature", // String |
conditionType: "greater_than", // String |
threshold: 100, // Number |
alertRoutes: [
{
email: "example@blues.com"
}
] // [MonitorAlertRoutes] |
}
let monitor = new NotehubJs.Monitor(monitorProps); // Monitor | Body or payload of monitor to be created
apiInstance.updateMonitor(projectUID, monitorUID, monitor).then((data) => {
console.log("API called successfully. Returned data: " + JSON.stringify(data));
}, (error) => {
console.error(error);
});
import notehub_py
from notehub_py.models.monitor import Monitor
from notehub_py.rest import ApiException
from pprint import pprint
# Defining the host is optional and defaults to https://api.notefile.net
configuration = notehub_py.Configuration(
host = "https://api.notefile.net"
)
# Configure API key authorization: api_key
configuration.api_key["api_key"] = os.environ["API_KEY"]
# Enter a context with an instance of the API client
with notehub_py.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = notehub_py.MonitorApi(api_client)
project_uid = "app:2606f411-dea6-44a0-9743-1130f57d77d8" # str |
monitor_uid = "monitor:8bAdf00d-000f-51c-af-01d5eaf00dbad" # str |
monitor_props = {
"name": "Monitor Name", # str |
"description": "Monitor Description", # str |
"source_type": "event", # str |
"disabled": False, # bool |
"alert": False, # bool |
"notefile_filter": ["data.qo"], # List[str] |
"source_selector": "temperature", # str |
"condition_type": "greater_than", # str |
"threshold": 100, # int |
"alert_routes": [
{
"email": "example@blues.com" # str |
}
],
"silenced": False, # bool |
"routing_cooldown_period": "5m0s", # str |
"per_device": False # bool |
}
monitor = notehub_py.Monitor(monitor_props) # Monitor | Body or payload of monitor to be created
try:
api_response = api_instance.update_monitor(project_uid, monitor_uid, monitor)
print("The response of MonitorApi->update_monitor:\n")
pprint(api_response)
except Exception as e:
print("Exception when calling MonitorApi->update_monitor: %s\n" % e)
Response Members
uid
string
The globally-unique identifier for the monitor.
name
string
The name of the monitor.
description
string
The description of the monitor.
disabled
boolean
Whether the monitor is disabled.
silenced
boolean
Whether the monitor is silenced.
notefile_filter
array
An array of the Notefile names the monitor is based on.
source_selector
string
The JSONata expression that selects the value to monitor from the source
Notefile's body
.
condition_type
string
The type of condition to apply to the value selected by the source_selector
.
alert_routes
array
An array of entities to notify when an alert is triggered.
last_routed_at
date
An ISO 8601 date for the last time the monitor was evaluated and routed.
routing_cooldown_period
string
The time period Notehub will wait before routing another event after the monitor has been triggered.
{
"uid": "monitor:8d19ed7e-36ae-43a1-9bb3-443bef9c02c1",
"name": "test-monitor",
"description": "monitor description",
"disabled": true,
"silenced": true,
"notefile_filter": [
"_track.qo"
],
"source_selector": "temperature",
"condition_type": "equal_to",
"alert_routes": [
{
"email": "test@blues.com"
},
],
"last_routed_at": "2024-06-01 01:23:45 +0000 UTC",
"routing_cooldown_period": "5m0s",
"aggregate_function": "none",
"aggregate_window": "0s"
}