package main import ( "fmt" "github.com/denzs/wsjtx_dashboards/shared/wsjtx" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promauto" log "github.com/sirupsen/logrus" ) var wsjtx_received_total *prometheus.CounterVec var wsjtx_received_call_total *prometheus.CounterVec func handlePrometheus(result wsjtx.Result) { incr_wsjtx_received_total(result) if promcalls { incr_wsjtx_received_callsigns_total(result) } } func incr_wsjtx_received_total(result wsjtx.Result) { if(wsjtx_received_total == nil) { log.Printf("creating wsjtx_received_total...") wsjtx_received_total = promauto.NewCounterVec(prometheus.CounterOpts{ Name: "wsjtx_received_total", Help: "DXCCs ordery by labels", }, []string{"num","signal","name","continent","cqzone","ituzone","band","mode","geohash","station"},) } wsjtx_received_total.With(prometheus.Labels{"num":fmt.Sprintf("%d",result.Ent.DXCC),"signal":fmt.Sprintf("%d",result.Signal), "band":result.Band, "name":result.Ent.Entity, "continent":result.Ent.Continent, "cqzone":fmt.Sprintf("%d",result.Ent.CQZone), "mode":result.Mode, "geohash":result.GeoHash, "station": station, "ituzone":fmt.Sprintf("%d",result.Ent.ITUZone)}).Inc() } func incr_wsjtx_received_callsigns_total(result wsjtx.Result) { if(wsjtx_received_call_total == nil) { log.Printf("creating wsjtx_received_call_total...") wsjtx_received_call_total = promauto.NewCounterVec(prometheus.CounterOpts{ Name: "wsjtx_received_call_total", Help: "DXCCs ordery by labels", }, []string{"num","signal","name","continent","cqzone","ituzone","band","call","mode","geohash","station"},) } wsjtx_received_call_total.With(prometheus.Labels{"num":fmt.Sprintf("%d",result.Ent.DXCC),"signal":fmt.Sprintf("%d",result.Signal), "band":result.Band, "name":result.Ent.Entity, "continent":result.Ent.Continent, "cqzone":fmt.Sprintf("%d",result.Ent.CQZone), "mode":result.Mode, "call":result.Call, "geohash":result.GeoHash, "station": station, "ituzone":fmt.Sprintf("%d",result.Ent.ITUZone)}).Inc() }