ObjAlertEdit extends ObjAlert to provide YAML export/import for alert
definitions. It exports all def_alert rows for a given package, stripping
runtime-state fields that are repopulated on each alert run.
Exported files are written to local.documents/alerts/ by default.
ObjAlert.ObjAlert
→ ObjAlertEdit.ObjAlertEdit ← this module
| Table | Purpose |
|---|---|
def_alert |
One row per Alert/Package — definition and thresholds |
Runtime-state fields stripped on export: guid, LastCheck, LastTrigger,
Package (Package is stored at the top level).
package: homechoice
alerts:
- Alert: DB_DOWN
Active: Y
Severity: CRITICAL
Description: Database connectivity check
TriggerSql: |
SELECT COUNT(*) FROM information_schema.tables
TriggerCooldown: 300
- Alert: API_LATENCY
Active: Y
Severity: HIGH
...
import_from_data() issues a single DELETE … WHERE Package = ? to replace
all alerts for the package, then reinserts each row from the file.
# Export all alerts for the active package
python factory.core/extend.edit/ObjAlertEdit.py save
# Export for a specific package
python factory.core/extend.edit/ObjAlertEdit.py save --package homechoice
# Custom output filename
python factory.core/extend.edit/ObjAlertEdit.py save \
--filename prod_alerts.yaml
# Import from YAML file
python factory.core/extend.edit/ObjAlertEdit.py load alerts_homechoice.yaml
# List all alerts
python factory.core/extend.edit/ObjAlertEdit.py list-alerts
| Method | Purpose |
|---|---|
load(package) |
Load all alert rows from DB |
list_alerts(package) |
List alerts with severity and description |
export_to_file(filename, package) |
Export to YAML |
import_from_data(data, package) |
Import from in-memory dict |
import_from_file(filename, package) |
Import from YAML file |