Skip to content

Commit

Permalink
Adding AI Error metric and fixing AI restart metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
wymangr committed Jul 2, 2024
1 parent d159d12 commit 192a8fd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
11 changes: 9 additions & 2 deletions blueiris/blueirisMetrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ var (
warningMetricsTotal float64
parseErrorsTotal float64
restartCount float64
aiErrorCount float64
aiRestartingCount float64
aiRestartedCount float64
triggerCount map[string]float64
Expand All @@ -61,6 +62,7 @@ func BlueIris(ch chan<- prometheus.Metric, m common.MetricInfo, SecMet []common.
warningMetricsTotal = 0
parseErrorsTotal = 0
restartCount = 0
aiErrorCount = 0
aiRestartingCount = 0
aiRestartedCount = 0
timeoutcount = 0
Expand Down Expand Up @@ -164,6 +166,8 @@ func BlueIris(ch chan<- prometheus.Metric, m common.MetricInfo, SecMet []common.
}
}
}
case "ai_error":
ch <- prometheus.MustNewConstMetric(sm.Desc, sm.Type, aiErrorCount)
case "ai_starting":
ch <- prometheus.MustNewConstMetric(sm.Desc, sm.Type, aiRestartingCount)
case "ai_started":
Expand Down Expand Up @@ -308,10 +312,13 @@ func findObject(line string) (match []string, r *regexp.Regexp, matchType string
} else if strings.Contains(line, "AI has been restarted") {
restartCount++

} else if strings.Contains(line, "AI: is being started") {
} else if strings.Contains(line, "AI: error") {
aiErrorCount++

} else if strings.Contains(line, "AI: is being started") || strings.Contains(line, "AI is being restarted") {
aiRestartingCount++

} else if strings.Contains(line, "AI: has been started") {
} else if strings.Contains(line, "AI: has been started") || strings.Contains(line, "AI has been started") {
aiRestartedCount++

} else if strings.Contains(line, "DeepStack: Server error") {
Expand Down
3 changes: 2 additions & 1 deletion metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ var (
namespace string = "blueiris"

blueIrisServerMetrics = metrics{
1: newMetric("ai_duration", "Duration of Blue Iris AI analysis", prometheus.GaugeValue, []string{"camera", "type", "object", "detail"}, blueiris.BlueIris, CollectBool{true: []int{2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22}}, "blueIrisServerMetrics"),
1: newMetric("ai_duration", "Duration of Blue Iris AI analysis", prometheus.GaugeValue, []string{"camera", "type", "object", "detail"}, blueiris.BlueIris, CollectBool{true: []int{2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23}}, "blueIrisServerMetrics"),
2: newMetric("ai_count", "Count of Blue Iris AI analysis", prometheus.GaugeValue, []string{"camera", "type"}, blueiris.BlueIris, CollectBool{false: nil}, "blueIrisServerMetrics"),
3: newMetric("ai_duration_distinct", "Duration of Blue Iris AI analysis once", prometheus.GaugeValue, []string{"camera", "type", "object", "detail"}, blueiris.BlueIris, CollectBool{false: nil}, "blueIrisServerMetrics"),
4: newMetric("ai_restarted", "Times BlueIris restarted Deepstack", prometheus.GaugeValue, []string{}, blueiris.BlueIris, CollectBool{false: nil}, "blueIrisServerMetrics"),
Expand All @@ -43,6 +43,7 @@ var (
20: newMetric("ai_starting", "Count of AI is being started log lines", prometheus.GaugeValue, []string{}, blueiris.BlueIris, CollectBool{false: nil}, "blueIrisServerMetrics"),
21: newMetric("ai_started", "Count of AI has been started log lines", prometheus.GaugeValue, []string{}, blueiris.BlueIris, CollectBool{false: nil}, "blueIrisServerMetrics"),
22: newMetric("profile", "Count of activation of profiles", prometheus.GaugeValue, []string{"profile"}, blueiris.BlueIris, CollectBool{false: nil}, "blueIrisServerMetrics"),
23: newMetric("ai_error", "Count of AI error log lines", prometheus.GaugeValue, []string{}, blueiris.BlueIris, CollectBool{false: nil}, "blueIrisServerMetrics"),
}

scrapeDurationDesc = prometheus.NewDesc(
Expand Down

0 comments on commit 192a8fd

Please sign in to comment.