graphicek/server/models/alerts.go

47 lines
1.5 KiB
Go
Raw Normal View History

2024-03-29 20:49:08 +01:00
package models
type AlertItem struct {
2024-03-31 20:47:43 +02:00
Id int64 `json:"id" db:"id"`
ContactPointId int64 `json:"contactPointId" db:"contact_point_id"`
Name string `json:"name" db:"name"`
Condition string `json:"condition" db:"condition"`
CustomMessage string `json:"customMessage" db:"custom_message"`
CustomResolvedMessage string `json:"customResolvedMessage" db:"custom_resolved_message"`
2024-03-29 20:49:08 +01:00
/* how long does the condition have to be true for the alert to go off */
TriggerInterval int64 `json:"triggerInterval" db:"trigger_interval"`
2024-03-29 20:49:08 +01:00
/* current alert status, possible values: good, pending, alerting */
LastStatus AlertStatus `json:"lastStatus" db:"last_status"`
2024-03-29 20:49:08 +01:00
/* time at which was status last changed */
LastStatusAt int64 `json:"lastStatusAt" db:"last_status_at"`
2024-03-29 20:49:08 +01:00
}
type AlertConditionSensorValue struct {
SensorId int64 `json:"sensorId"`
Condition string `json:"condition"`
Value float64 `json:"value"`
}
type AlertConditionSensorLastContact struct {
2024-03-31 09:50:09 +02:00
SensorId int64 `json:"sensorId"`
Value float64 `json:"value"`
ValueUnit string `json:"valueUnit"`
2024-03-29 20:49:08 +01:00
}
type AlertConditionType string
const (
AlertConditionSensorValueType = "sensor_value"
AlertConditionSensorLastContactType = "sensor_last_contact"
)
type AlertStatus string
const (
AlertStatusOk = "ok"
AlertStatusAlertPending = "alert_pending"
AlertStatusAlerting = "alerting"
AlertStatusOkPending = "ok_pending"
)