mirror of
https://github.com/unpoller/unpoller.git
synced 2026-03-31 06:24:21 -04:00
- Add job=unpoller to every Loki stream (alarm, anomaly, event, ids,
system_log, protect_log, protect_thumbnail) for standard Grafana/Loki
source filtering with {job="unpoller"}
- Add event_type and inner_alert_action labels to IDS streams using
EventType and InnerAlertAction fields
- Add event_type and inner_alert_action labels to Alarm streams using
Key and InnerAlertAction fields
- Skip severity/category on Anomaly: the unifi.Anomaly struct has no
such fields
Co-authored-by: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -27,9 +27,12 @@ func (r *Report) Alarm(event *unifi.Alarm, logs *Logs) {
|
||||
logs.Streams = append(logs.Streams, LogStream{
|
||||
Entries: [][]string{{strconv.FormatInt(event.Datetime.UnixNano(), 10), string(msg)}},
|
||||
Labels: CleanLabels(MergeLabels(map[string]string{
|
||||
"application": "unifi_alarm",
|
||||
"source": event.SourceName,
|
||||
"site_name": event.SiteName,
|
||||
"application": "unifi_alarm",
|
||||
"job": "unpoller",
|
||||
"source": event.SourceName,
|
||||
"site_name": event.SiteName,
|
||||
"event_type": event.Key,
|
||||
"inner_alert_action": event.InnerAlertAction,
|
||||
}, r.ExtraLabels)),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ func (r *Report) Anomaly(event *unifi.Anomaly, logs *Logs) {
|
||||
Entries: [][]string{{strconv.FormatInt(event.Datetime.UnixNano(), 10), string(msg)}},
|
||||
Labels: CleanLabels(MergeLabels(map[string]string{
|
||||
"application": "unifi_anomaly",
|
||||
"job": "unpoller",
|
||||
"source": event.SourceName,
|
||||
"site_name": event.SiteName,
|
||||
}, r.ExtraLabels)),
|
||||
|
||||
@@ -29,6 +29,7 @@ func (r *Report) Event(event *unifi.Event, logs *Logs) {
|
||||
Entries: [][]string{{strconv.FormatInt(event.Datetime.UnixNano(), 10), string(msg)}},
|
||||
Labels: CleanLabels(MergeLabels(map[string]string{
|
||||
"application": "unifi_event",
|
||||
"job": "unpoller",
|
||||
"site_name": event.SiteName,
|
||||
"source": event.SourceName,
|
||||
}, r.ExtraLabels)),
|
||||
@@ -54,6 +55,7 @@ func (r *Report) SystemLogEvent(event *unifi.SystemLogEntry, logs *Logs) {
|
||||
Entries: [][]string{{strconv.FormatInt(event.Datetime().UnixNano(), 10), string(msg)}},
|
||||
Labels: CleanLabels(MergeLabels(map[string]string{
|
||||
"application": "unifi_system_log",
|
||||
"job": "unpoller",
|
||||
"site_name": event.SiteName,
|
||||
"source": event.SourceName,
|
||||
"category": event.Category,
|
||||
|
||||
@@ -27,9 +27,12 @@ func (r *Report) IDs(event *unifi.IDS, logs *Logs) {
|
||||
logs.Streams = append(logs.Streams, LogStream{
|
||||
Entries: [][]string{{strconv.FormatInt(event.Datetime.UnixNano(), 10), string(msg)}},
|
||||
Labels: CleanLabels(MergeLabels(map[string]string{
|
||||
"application": "unifi_ids",
|
||||
"source": event.SourceName,
|
||||
"site_name": event.SiteName,
|
||||
"application": "unifi_ids",
|
||||
"job": "unpoller",
|
||||
"source": event.SourceName,
|
||||
"site_name": event.SiteName,
|
||||
"event_type": event.EventType,
|
||||
"inner_alert_action": event.InnerAlertAction,
|
||||
}, r.ExtraLabels)),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ func (r *Report) ProtectLogEvent(event *unifi.ProtectLogEntry, logs *Logs) {
|
||||
Entries: [][]string{{strconv.FormatInt(event.Datetime().UnixNano(), 10), string(msg)}},
|
||||
Labels: CleanLabels(MergeLabels(map[string]string{
|
||||
"application": "unifi_protect_log",
|
||||
"job": "unpoller",
|
||||
"source": event.SourceName,
|
||||
"event_type": event.GetEventType(),
|
||||
"category": event.GetCategory(),
|
||||
@@ -59,6 +60,7 @@ func (r *Report) ProtectLogEvent(event *unifi.ProtectLogEntry, logs *Logs) {
|
||||
Entries: [][]string{{strconv.FormatInt(event.Datetime().UnixNano()+1, 10), string(thumbnailJSON)}},
|
||||
Labels: CleanLabels(MergeLabels(map[string]string{
|
||||
"application": "unifi_protect_thumbnail",
|
||||
"job": "unpoller",
|
||||
"source": event.SourceName,
|
||||
"event_id": event.ID,
|
||||
"camera": event.Camera,
|
||||
|
||||
Reference in New Issue
Block a user