Fix prometheus viewer count value & rename metrics names
This commit is contained in:
@@ -35,31 +35,31 @@ func Start(getStatus func() models.Status) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
activeViewerCount = promauto.NewGauge(prometheus.GaugeOpts{
|
activeViewerCount = promauto.NewGauge(prometheus.GaugeOpts{
|
||||||
Name: "active_viewer_count",
|
Name: "owncast_instance_active_viewer_count",
|
||||||
Help: "The number of viewers.",
|
Help: "The number of viewers.",
|
||||||
ConstLabels: labels,
|
ConstLabels: labels,
|
||||||
})
|
})
|
||||||
|
|
||||||
activeChatClientCount = promauto.NewGauge(prometheus.GaugeOpts{
|
activeChatClientCount = promauto.NewGauge(prometheus.GaugeOpts{
|
||||||
Name: "active_chat_client_count",
|
Name: "owncast_instance_active_chat_client_count",
|
||||||
Help: "The number of connected chat clients.",
|
Help: "The number of connected chat clients.",
|
||||||
ConstLabels: labels,
|
ConstLabels: labels,
|
||||||
})
|
})
|
||||||
|
|
||||||
chatUserCount = promauto.NewGauge(prometheus.GaugeOpts{
|
chatUserCount = promauto.NewGauge(prometheus.GaugeOpts{
|
||||||
Name: "total_chat_users",
|
Name: "owncast_instance_total_chat_users",
|
||||||
Help: "The total number of chat users on this Owncast instance.",
|
Help: "The total number of chat users on this Owncast instance.",
|
||||||
ConstLabels: labels,
|
ConstLabels: labels,
|
||||||
})
|
})
|
||||||
|
|
||||||
currentChatMessageCount = promauto.NewGauge(prometheus.GaugeOpts{
|
currentChatMessageCount = promauto.NewGauge(prometheus.GaugeOpts{
|
||||||
Name: "current_chat_message_count",
|
Name: "owncast_instance_current_chat_message_count",
|
||||||
Help: "The number of chat messages currently saved before cleanup.",
|
Help: "The number of chat messages currently saved before cleanup.",
|
||||||
ConstLabels: labels,
|
ConstLabels: labels,
|
||||||
})
|
})
|
||||||
|
|
||||||
cpuUsage = promauto.NewGauge(prometheus.GaugeOpts{
|
cpuUsage = promauto.NewGauge(prometheus.GaugeOpts{
|
||||||
Name: "cpu_use_pct",
|
Name: "owncast_instance_cpu_use_pct",
|
||||||
Help: "CPU percentage used as seen within Owncast",
|
Help: "CPU percentage used as seen within Owncast",
|
||||||
ConstLabels: labels,
|
ConstLabels: labels,
|
||||||
})
|
})
|
||||||
@@ -77,7 +77,6 @@ func handlePolling() {
|
|||||||
collectCPUUtilization()
|
collectCPUUtilization()
|
||||||
collectRAMUtilization()
|
collectRAMUtilization()
|
||||||
collectDiskUtilization()
|
collectDiskUtilization()
|
||||||
collectChatClientCount()
|
|
||||||
|
|
||||||
// Alerting
|
// Alerting
|
||||||
handleAlerting()
|
handleAlerting()
|
||||||
|
|||||||
@@ -23,10 +23,10 @@ func startViewerCollectionMetrics() {
|
|||||||
defer storage.Close()
|
defer storage.Close()
|
||||||
|
|
||||||
collectViewerCount()
|
collectViewerCount()
|
||||||
handlePolling()
|
|
||||||
|
|
||||||
for range time.Tick(viewerMetricsPollingInterval) {
|
for range time.Tick(viewerMetricsPollingInterval) {
|
||||||
collectViewerCount()
|
collectViewerCount()
|
||||||
|
collectChatClientCount()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,15 +35,15 @@ func collectViewerCount() {
|
|||||||
if !core.GetStatus().Online {
|
if !core.GetStatus().Online {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Save to our Prometheus collector.
|
||||||
|
activeViewerCount.Set(float64(core.GetStatus().ViewerCount))
|
||||||
}
|
}
|
||||||
|
|
||||||
func collectChatClientCount() {
|
func collectChatClientCount() {
|
||||||
count := len(chat.GetClients())
|
count := len(chat.GetClients())
|
||||||
activeChatClientCount.Set(float64(count))
|
activeChatClientCount.Set(float64(count))
|
||||||
|
|
||||||
// Save to our Prometheus collector.
|
|
||||||
activeViewerCount.Set(float64(count))
|
|
||||||
|
|
||||||
// Total message count
|
// Total message count
|
||||||
cmc := data.GetMessagesCount()
|
cmc := data.GetMessagesCount()
|
||||||
currentChatMessageCount.Set(float64(cmc))
|
currentChatMessageCount.Set(float64(cmc))
|
||||||
|
|||||||
Reference in New Issue
Block a user