Previous
Custom queries
Configure triggers to receive email or webhook notifications when your machines need attention. Triggers fire when specific events occur, such as a sensor reading crossing a threshold, a machine going offline, or error logs appearing.
| Trigger type | Fires when | Use case |
|---|---|---|
| Telemetry sync | Data syncs from a machine to the cloud | Know when any data arrives |
| Conditional telemetry | Synced data meets a condition you define | CPU above 80%, temperature below freezing, battery under 20% |
| Machine logs | Error, warning, or info logs appear | Catch errors without watching the LOGS tab |
| Part online | A machine part comes online | Know when a machine reconnects after maintenance |
| Part offline | A machine part goes offline | Respond to unexpected disconnections |
To alert on sensor data, you need three things: a sensor producing data, the data management service capturing and syncing that data, and a trigger that fires when the data arrives or meets a condition.
To monitor machine health metrics like CPU usage, memory, and temperature, add a performance metrics sensor.
On your machine’s CONFIGURE page, click the + icon next to your machine part and select Component or service.
Search for and add the hwmonitor:cpu_monitor model from the sbc-hwmonitor module.
You can add additional sensors for memory, temperature, and other metrics.
See the sbc-hwmonitor module page for the full list.
First install telegraf:
brew install telegraf
On your machine’s CONFIGURE page, click the + icon next to your machine part and select Component.
Search for and add the viam-sensor:telegrafsensor model.
You can add additional sensors for other metrics.
See the viam-telegraf-sensor module page for the full list.
Click Save, then click Test at the bottom of the sensor configuration card to verify readings are coming through.
data management / RDK service and click Create.
Leave the default sync interval of 0.1 minutes (every 6 seconds) and keep both Capturing and Syncing enabled.Readings from the Method dropdown and set the Frequency to 0.05 Hz (once every 20 seconds).To verify data is syncing, click the … menu on the sensor card and select View captured data. Wait a minute for data to capture and sync, then refresh.
cpu, operator greater than, value 50.Add a triggers field to your machine configuration:
"triggers": [
{
"name": "trigger-1",
"event": {
"type": "part_data_ingested",
"data_ingested": {
"data_types": ["binary", "tabular", "file"]
}
},
"notifications": [
{
"type": "email",
"value": "you@example.com",
"seconds_between_notifications": 300
}
]
}
]
"triggers": [
{
"name": "cpu-alert",
"event": {
"type": "conditional_data_ingested",
"conditional": {
"data_capture_method": "sensor:cpu-monitor:Readings",
"conditions": {
"evals": [
{
"operator": "gt",
"value": {
"cpu": 50
}
}
]
}
}
},
"notifications": [
{
"type": "email",
"value": "you@example.com",
"seconds_between_notifications": 600
}
]
}
]
If this is a test, stop data capture to avoid charges for syncing unwanted data. In the Data capture section of your sensor’s configuration, toggle the switch to Off and click Save.
Configure a trigger that fires when machine logs of a specified level appear. Viam checks for matching logs once per hour.
"triggers": [
{
"name": "error-log-alert",
"event": {
"type": "conditional_logs_ingested",
"log_levels": ["error", "warn"]
},
"notifications": [
{
"type": "email",
"value": "you@example.com"
}
]
}
]
The notification interval for log triggers is always one hour.
"triggers": [
{
"name": "machine-online",
"event": {
"type": "part_online"
},
"notifications": [
{
"type": "email",
"value": "you@example.com",
"seconds_between_notifications": 600
}
]
}
]
"triggers": [
{
"name": "machine-offline",
"event": {
"type": "part_offline"
},
"notifications": [
{
"type": "email",
"value": "you@example.com",
"seconds_between_notifications": 300
}
]
}
]
Viam uses a 60-second buffer before declaring a part offline. This prevents false alerts from brief network interruptions.
Every notification method has a seconds_between_notifications setting that controls the minimum time between consecutive alerts.
If a trigger fires more frequently than this interval, Viam suppresses the extra notifications.
Set this value based on how quickly you need to respond:
Starting with a longer interval and shortening it as needed is better than starting short and dealing with notification noise.
You can also manage triggers from the command line:
viam machines part add-trigger --part <part-name-or-id>
viam machines part delete-trigger --part <part-name-or-id> --name <trigger-name>
Was this page helpful?
Glad to hear it! If you have any other feedback please let us know:
We're sorry about that. To help us improve, please tell us what we can do better:
Thank you!