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/{projectOrProductUID}/monitors |
| Get Monitor | GET /v1/projects/{projectOrProductUID}/monitors/{monitorUID} |
| Create Monitor | POST /v1/projects/{projectOrProductUID}/monitors |
| Delete Monitor | DELETE /v1/projects/{projectOrProductUID}/monitors/{monitorUID} |
| Update Monitor | PUT /v1/projects/{projectOrProductUID}/monitors/{monitorUID} |
Get Monitors Notehub
Get all alert monitors for a Notehub project.
| HTTP Method: | GET |
| URL: | https://api.notefile.net/v1/projects/{projectOrProductUID}/monitors |
| Path Parameters: |
|
| Minimum Notehub project-level role: | viewer |
| Required HTTP Headers: | Authorization: Bearer <token>, where the token is a valid authentication token. |
curl -X GET
-L 'https://api.notefile.net/v1/projects/<projectOrProductUID>/monitors'
-H 'Authorization: Bearer <access_token>'import * as NotehubJs from "@blues-inc/notehub-js";
let defaultClient = NotehubJs.ApiClient.instance;
// Configure Bearer access token for authorization: personalAccessToken
let personalAccessToken = defaultClient.authentications["personalAccessToken"];
personalAccessToken.accessToken = "YOUR ACCESS TOKEN";
let apiInstance = new NotehubJs.MonitorApi();
let projectOrProductUID = "app:2606f411-dea6-44a0-9743-1130f57d77d8";
apiInstance.getMonitors(projectOrProductUID).then(
(data) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data),
);
},
(error) => {
console.error(error);
},
);import os
from pprint import pprint
import notehub_py
configuration = notehub_py.Configuration(
access_token=os.environ["BEARER_TOKEN"]
)
# Enter a context with an instance of the API client
with notehub_py.ApiClient(configuration) as api_client:
api_instance = notehub_py.MonitorApi(api_client)
project_or_product_uid = "app:2606f411-dea6-44a0-9743-1130f57d77d8"
try:
api_response = api_instance.get_monitors(project_or_product_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
The response is a JSON array of all monitors on the specified Notehub project. See Get Monitor for a description of each monitor's fields.
[
{
"uid": "monitor:8d19ed7e-36ae-43a1-9bb3-443bef9c02c1",
"name": "test-monitor",
"description": "monitor description",
"disabled": true,
"silenced": true,
"notefile_filter": [
"_track.qo"
],
"source_type": "event",
"source_selector": "temperature",
"condition_type": "equal_to",
"threshold": 100,
"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/{projectOrProductUID}/monitors/{monitorUID} |
| Path Parameters: |
|
| Minimum Notehub project-level role: | viewer |
| Required HTTP Headers: | Authorization: Bearer <token>, where the token is a valid authentication token. |
curl -X GET
-L 'https://api.notefile.net/v1/projects/<projectOrProductUID>/monitors/<monitorUID>'
-H 'Authorization: Bearer <access_token>'import * as NotehubJs from "@blues-inc/notehub-js";
let defaultClient = NotehubJs.ApiClient.instance;
// Configure Bearer access token for authorization: personalAccessToken
let personalAccessToken = defaultClient.authentications["personalAccessToken"];
personalAccessToken.accessToken = "YOUR ACCESS TOKEN";
let apiInstance = new NotehubJs.MonitorApi();
let projectOrProductUID = "app:2606f411-dea6-44a0-9743-1130f57d77d8";
let monitorUID = "monitor:8d19ed7e-36ae-43a1-9bb3-443bef9c02c1";
apiInstance.getMonitor(projectOrProductUID, monitorUID).then(
(data) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data),
);
},
(error) => {
console.error(error);
},
);import os
from pprint import pprint
import notehub_py
configuration = notehub_py.Configuration(
access_token=os.environ["BEARER_TOKEN"]
)
# Enter a context with an instance of the API client
with notehub_py.ApiClient(configuration) as api_client:
api_instance = notehub_py.MonitorApi(api_client)
project_or_product_uid = "app:2606f411-dea6-44a0-9743-1130f57d77d8"
monitor_uid = "monitor:8d19ed7e-36ae-43a1-9bb3-443bef9c02c1"
try:
api_response = api_instance.get_monitor(
project_or_product_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.
alert
boolean
Whether the monitor is currently in an alert state.
fleet_filter
array
An array of the FleetUIDs the monitor watches.
notefile_filter
array
An array of the Notefile names the monitor is based on.
source_type
string
The type of source the monitor watches: "event" or "heartbeat".
source_selector
string
A dot-delimited path to the value to monitor within the source Notefile's body.
condition_type
string
The type of condition to apply to the value selected by the source_selector.
threshold
number
The value the condition_type compares against. For heartbeat monitors this is
the number of seconds of inactivity.
alert_routes
array
An array of entities to notify when an alert is triggered.
last_routed_at
string
The last time the monitor sent notifications, for example
"2024-06-01 01:23:45 +0000 UTC".
routing_cooldown_period
string
The time period Notehub will wait before routing another event after the monitor has been triggered.
aggregate_function
string
The aggregate function applied to the selected values before the condition is checked.
aggregate_window
string
The time window the aggregate_function is applied over.
per_device
boolean
Whether the aggregate function is evaluated per device rather than across all devices.
{
"uid": "monitor:8d19ed7e-36ae-43a1-9bb3-443bef9c02c1",
"name": "test-monitor",
"description": "monitor description",
"disabled": true,
"silenced": true,
"notefile_filter": [
"_track.qo"
],
"source_type": "event",
"source_selector": "temperature",
"condition_type": "equal_to",
"threshold": 100,
"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.
Notehub Essentials users can have one active heartbeat monitor per project at no cost. Additional heartbeat monitors, as well as all event monitors, require a Notehub Enterprise plan.
The API returns a 403 error if your plan doesn't allow the monitor. See
Blues pricing or
contact Blues sales for more information.
| HTTP Method: | POST |
| URL: | https://api.notefile.net/v1/projects/{projectOrProductUID}/monitors |
| Path Parameters: |
|
| Minimum Notehub project-level role: | developer |
| Required HTTP Headers: | Authorization: Bearer <token>, where the token is a valid authentication token. |
name
string
The name of the monitor.
description
string (optional)
The description of the monitor.
This argument defaults to an empty string.
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 FleetUIDs to monitor.
notefile_filter
array (optional)
An array of Notefile names to monitor. Omit this argument for heartbeat monitors.
source_selector
string (optional)
A dot-delimited path to a single, numeric value within the source Notefile's body.
For example, "temperature" would select the body.temperature field from all
monitored Notefiles.
This argument is required for event monitors, unless aggregate_function is
"count". A count monitor counts matching events, so it doesn't need a field to
read.
source_type
string (optional)
The type of source to monitor. Set to "event" to create an event monitor, and
"heartbeat" to create a heartbeat monitor.
This argument defaults to "event".
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 is required for event monitors but can be omitted for
heartbeat monitors, which always use "greater_than_or_equal_to".
threshold
number
The numeric threshold to apply to the value selected by the source_selector.
For heartbeat monitors this is the number of seconds of inactivity.
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 a required url and optional
message_type and text properties.
Learn more about these properties in Slack Webhook Route Type.
{"url":"hooks.slack.com/...", "message_type": "text|blocks", "text": "Message Text"}
Slack Bearer
To add a Slack bearer notification add an object with a required token and optional
channel, message_type, and text properties.
Learn more about these properties in Slack Bearer Route Type.
{"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 are "none", "sum", "avg", "max", "min",
"count".
This argument 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 one or more numbers (decimals allowed), each
followed by a time unit of ns, us, ms, s, m, or h. For example, 10m
for 10 minutes, 10m30s for 10 minutes and 30 seconds, 5h30m10s for 5 hours
30 minutes 10 seconds, or 1.5h for 90 minutes.
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 one or more numbers (decimals allowed), each
followed by a time unit of ns, us, ms, s, m, or h. For example, 10m
for 10 minutes, 10m30s for 10 minutes and 30 seconds, 5h30m10s for 5 hours
30 minutes 10 seconds, or 1.5h for 90 minutes.
This argument defaults to 5m0s.
curl -X POST
-L 'https://api.notefile.net/v1/projects/<projectOrProductUID>/monitors'
-H 'Authorization: Bearer <access_token>'
-H 'Content-Type: application/json'
-d '{"name":"<name>", "description": "<description>","notefile_filter":["data.qo"],"source_type":"event","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 Bearer access token for authorization: personalAccessToken
let personalAccessToken = defaultClient.authentications["personalAccessToken"];
personalAccessToken.accessToken = "YOUR ACCESS TOKEN";
let apiInstance = new NotehubJs.MonitorApi();
let projectOrProductUID = "app:2606f411-dea6-44a0-9743-1130f57d77d8";
let createMonitor = {
name: "Temperature Monitor",
description: "Alert when temperature exceeds 100",
notefile_filter: ["data.qo"],
source_type: "event",
source_selector: "temperature",
condition_type: "greater_than",
threshold: 100,
alert_routes: [{ email: "someone@example.com" }],
}; // CreateMonitor
apiInstance.createMonitor(projectOrProductUID, createMonitor).then(
(data) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data),
);
},
(error) => {
console.error(error);
},
);import os
from pprint import pprint
import notehub_py
configuration = notehub_py.Configuration(
access_token=os.environ["BEARER_TOKEN"]
)
# Enter a context with an instance of the API client
with notehub_py.ApiClient(configuration) as api_client:
api_instance = notehub_py.MonitorApi(api_client)
project_or_product_uid = "app:2606f411-dea6-44a0-9743-1130f57d77d8"
create_monitor = notehub_py.CreateMonitor(
name="Temperature Monitor",
description="Alert when temperature exceeds 100",
notefile_filter=["data.qo"],
source_type="event",
source_selector="temperature",
condition_type="greater_than",
threshold=100,
alert_routes=[
notehub_py.MonitorAlertRoutesInner(
notehub_py.EmailNotification(email="someone@example.com")
)
],
)
try:
api_response = api_instance.create_monitor(
project_or_product_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
The created monitor. See Get Monitor for a description of each field.
{
"uid": "monitor:8d19ed7e-36ae-43a1-9bb3-443bef9c02c1",
"name": "test-monitor",
"description": "monitor description",
"disabled": true,
"silenced": true,
"notefile_filter": [
"_track.qo"
],
"source_type": "event",
"source_selector": "temperature",
"condition_type": "equal_to",
"threshold": 100,
"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/{projectOrProductUID}/monitors/{monitorUID} |
| Path Parameters: |
|
| Minimum Notehub project-level role: | developer |
| Required HTTP Headers: | Authorization: Bearer <token>, where the token is a valid authentication token. |
curl -X DELETE
-L 'https://api.notefile.net/v1/projects/<projectOrProductUID>/monitors/<monitorUID>'
-H 'Authorization: Bearer <access_token>'import * as NotehubJs from "@blues-inc/notehub-js";
let defaultClient = NotehubJs.ApiClient.instance;
// Configure Bearer access token for authorization: personalAccessToken
let personalAccessToken = defaultClient.authentications["personalAccessToken"];
personalAccessToken.accessToken = "YOUR ACCESS TOKEN";
let apiInstance = new NotehubJs.MonitorApi();
let projectOrProductUID = "app:2606f411-dea6-44a0-9743-1130f57d77d8";
let monitorUID = "monitor:8d19ed7e-36ae-43a1-9bb3-443bef9c02c1";
apiInstance.deleteMonitor(projectOrProductUID, monitorUID).then(
(data) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data),
);
},
(error) => {
console.error(error);
},
);import os
from pprint import pprint
import notehub_py
configuration = notehub_py.Configuration(
access_token=os.environ["BEARER_TOKEN"]
)
# Enter a context with an instance of the API client
with notehub_py.ApiClient(configuration) as api_client:
api_instance = notehub_py.MonitorApi(api_client)
project_or_product_uid = "app:2606f411-dea6-44a0-9743-1130f57d77d8"
monitor_uid = "monitor:8d19ed7e-36ae-43a1-9bb3-443bef9c02c1"
try:
api_response = api_instance.delete_monitor(
project_or_product_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.
This request replaces the monitor's existing settings. Any omitted
fields, such as name or threshold, may be cleared or reset to
their defaults.
| HTTP Method: | PUT |
| URL: | https://api.notefile.net/v1/projects/{projectOrProductUID}/monitors/{monitorUID} |
| Path Parameters: |
|
| Minimum Notehub project-level role: | developer |
| Required HTTP Headers: | Authorization: Bearer <token>, where the token is a valid authentication 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 FleetUIDs to monitor.
notefile_filter
array (optional)
An array of Notefile names to monitor. Omit this argument for heartbeat monitors.
source_selector
string (optional)
A dot-delimited path to a single, numeric value within the source Notefile's body.
For example, "temperature" would select the body.temperature field from all
monitored Notefiles.
This argument is required for event monitors, unless aggregate_function is
"count". A count monitor counts matching events, so it doesn't need a field to
read.
source_type
string (optional)
The type of source to monitor: "event" or "heartbeat". If you omit this
argument, the monitor keeps its current type.
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".
If you omit this argument, the monitor keeps its current condition. Heartbeat
monitors always use "greater_than_or_equal_to".
threshold
number
The numeric threshold to apply to the value selected by the source_selector.
For heartbeat monitors this is the number of seconds of inactivity.
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 a required url and optional
message_type and text properties.
Learn more about these properties in Slack Webhook Route Type.
{"url":"hooks.slack.com/...", "message_type": "text|blocks", "text": "Message Text"}
Slack Bearer
To add a Slack bearer notification add an object with a required token and optional
channel, message_type, and text properties.
Learn more about these properties in Slack Bearer Route Type.
{"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 are "none", "sum", "avg", "max", "min",
"count".
This argument 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 one or more numbers (decimals allowed), each
followed by a time unit of ns, us, ms, s, m, or h. For example, 10m
for 10 minutes, 10m30s for 10 minutes and 30 seconds, 5h30m10s for 5 hours
30 minutes 10 seconds, or 1.5h for 90 minutes.
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 one or more numbers (decimals allowed), each
followed by a time unit of ns, us, ms, s, m, or h. For example, 10m
for 10 minutes, 10m30s for 10 minutes and 30 seconds, 5h30m10s for 5 hours
30 minutes 10 seconds, or 1.5h for 90 minutes.
This argument defaults to 5m0s.
curl -X PUT
-L 'https://api.notefile.net/v1/projects/<projectOrProductUID>/monitors/<monitorUID>'
-H 'Authorization: Bearer <access_token>'
-H 'Content-Type: application/json'
-d '{"name":"<name>", "description": "<description>","notefile_filter":["data.qo"],"source_type":"event","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 Bearer access token for authorization: personalAccessToken
let personalAccessToken = defaultClient.authentications["personalAccessToken"];
personalAccessToken.accessToken = "YOUR ACCESS TOKEN";
let apiInstance = new NotehubJs.MonitorApi();
let projectOrProductUID = "app:2606f411-dea6-44a0-9743-1130f57d77d8";
let monitorUID = "monitor:8d19ed7e-36ae-43a1-9bb3-443bef9c02c1";
let monitor = {
name: "Temperature Monitor",
description: "Alert when temperature exceeds 100",
notefile_filter: ["data.qo"],
source_type: "event",
source_selector: "temperature",
condition_type: "greater_than",
threshold: 100,
alert_routes: [{ email: "someone@example.com" }],
}; // Monitor
apiInstance.updateMonitor(projectOrProductUID, monitorUID, monitor).then(
(data) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data),
);
},
(error) => {
console.error(error);
},
);import os
from pprint import pprint
import notehub_py
configuration = notehub_py.Configuration(
access_token=os.environ["BEARER_TOKEN"]
)
# Enter a context with an instance of the API client
with notehub_py.ApiClient(configuration) as api_client:
api_instance = notehub_py.MonitorApi(api_client)
project_or_product_uid = "app:2606f411-dea6-44a0-9743-1130f57d77d8"
monitor_uid = "monitor:8d19ed7e-36ae-43a1-9bb3-443bef9c02c1"
monitor = notehub_py.Monitor(
name="Temperature Monitor",
description="Alert when temperature exceeds 100",
notefile_filter=["data.qo"],
source_type="event",
source_selector="temperature",
condition_type="greater_than",
threshold=100,
alert_routes=[
notehub_py.MonitorAlertRoutesInner(
notehub_py.EmailNotification(email="someone@example.com")
)
],
)
try:
api_response = api_instance.update_monitor(
project_or_product_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
The updated monitor. See Get Monitor for a description of each field.
{
"uid": "monitor:8d19ed7e-36ae-43a1-9bb3-443bef9c02c1",
"name": "test-monitor",
"description": "monitor description",
"disabled": true,
"silenced": true,
"notefile_filter": [
"_track.qo"
],
"source_type": "event",
"source_selector": "temperature",
"condition_type": "equal_to",
"threshold": 100,
"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"
}