package metrics import ( "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/collectors" "github.com/prometheus/client_golang/prometheus/promhttp" "log" "net/http" ) var ActiveCameras = prometheus.NewGauge(prometheus.GaugeOpts{ Name: "active_rtsp_cameras_total", Help: "Количество активных rtsp потоков (работающих горутин) для камер.", }) // Metrics establish metrics for an application. func Metrics() { // Register standart metrics. appRegistry := prometheus.NewRegistry() appRegistry.MustRegister(collectors.NewGoCollector()) appRegistry.MustRegister(collectors.NewProcessCollector(collectors.ProcessCollectorOpts{})) appRegistry.MustRegister(ActiveCameras) //// Endpoint for metrics. http.Handle("/metrics", promhttp.HandlerFor(appRegistry, promhttp.HandlerOpts{})) // Start server. err := http.ListenAndServe(":9110", nil) if err != nil { log.Println(err) } }