prometheus.go 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. package metrics
  2. import (
  3. "github.com/prometheus/client_golang/prometheus"
  4. "github.com/prometheus/client_golang/prometheus/promauto"
  5. )
  6. var (
  7. labels map[string]string
  8. activeViewerCount prometheus.Gauge
  9. activeChatClientCount prometheus.Gauge
  10. cpuUsage prometheus.Gauge
  11. chatUserCount prometheus.Gauge
  12. currentChatMessageCount prometheus.Gauge
  13. playbackErrorCount prometheus.Gauge
  14. )
  15. func setupPrometheusCollectors() {
  16. // Setup the Prometheus collectors.
  17. activeViewerCount = promauto.NewGauge(prometheus.GaugeOpts{
  18. Name: "owncast_instance_active_viewer_count",
  19. Help: "The number of viewers.",
  20. ConstLabels: labels,
  21. })
  22. activeChatClientCount = promauto.NewGauge(prometheus.GaugeOpts{
  23. Name: "owncast_instance_active_chat_client_count",
  24. Help: "The number of connected chat clients.",
  25. ConstLabels: labels,
  26. })
  27. chatUserCount = promauto.NewGauge(prometheus.GaugeOpts{
  28. Name: "owncast_instance_total_chat_users",
  29. Help: "The total number of chat users on this Owncast instance.",
  30. ConstLabels: labels,
  31. })
  32. currentChatMessageCount = promauto.NewGauge(prometheus.GaugeOpts{
  33. Name: "owncast_instance_current_chat_message_count",
  34. Help: "The number of chat messages currently saved before cleanup.",
  35. ConstLabels: labels,
  36. })
  37. playbackErrorCount = promauto.NewGauge(prometheus.GaugeOpts{
  38. Name: "owncast_instance_playback_error_count",
  39. Help: "Errors collected from players within this window",
  40. ConstLabels: labels,
  41. })
  42. cpuUsage = promauto.NewGauge(prometheus.GaugeOpts{
  43. Name: "owncast_instance_cpu_usage",
  44. Help: "CPU usage as seen internally to Owncast.",
  45. ConstLabels: labels,
  46. })
  47. }