You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
 
 
 
 
 
 

72 lines
2.8 KiB

package main
import (
"fmt"
// log "github.com/sirupsen/logrus"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
// "time"
)
var prt *prometheus.CounterVec
func handlePrometheus(r report) {
if(prt == nil) {
prt = promauto.NewCounterVec(prometheus.CounterOpts{ Name: "pskreporter_receivereports_total",
Help: "PSK Reporter receiveReports",},
[]string{"station","callsign","grid","signal","dxcc","mode","geohash","continent","band","ituzone","cqzone"},)
}
// _ , seen := reportList[r.CallSign]
// // only increase counter if reporter sends update to prevent double counting thru restarts
// if seen { // check if fetched record is newer than existing
// if r.lastReport > reportList[r.CallSign].lastReport {
// log.WithFields(log.Fields{
// "Callsign":r.CallSign,
// "Grid":r.Grid,
// "Geohash":r.GeoHash,
// "Mode":r.Mode,
// "Continent":r.Continent,
// "ITUZone":fmt.Sprintf("%d",r.ITUZone),
// "CQZone":fmt.Sprintf("%d",r.CQZone),
// "DXCC":r.Dxcc,
// }).Debug("new but fresh")
prt.With(prometheus.Labels{"signal":fmt.Sprintf("%d",r.Signal),
"callsign":r.CallSign,
"station":station,
"grid":r.Grid,
"mode":r.Mode,
"geohash":r.GeoHash,
"continent":r.Continent,
"ituzone":fmt.Sprintf("%d",r.ITUZone),
"cqzone":fmt.Sprintf("%d",r.CQZone),
"band":r.Band,
"dxcc":r.Dxcc}).Inc()
// } else { // just hit an old entry, no need to store
// log.Info("old entry!")
// return
// }
// } else {
// log.Info("!seen")
//// log.Infof("reportList:%+v",reportList)
// }
// if r.lastReport > (time.Now().Unix() - 300) {
//
// log.WithFields(log.Fields{
// "Callsign":r.CallSign,
// }).Debug("new but fresh")
//
// prt.With(prometheus.Labels{"signal":fmt.Sprintf("%d",r.Signal),
// "callsign":r.CallSign,
// "station":station,
// "grid":r.Grid,
// "mode":r.Mode,
// "geohash":r.GeoHash,
// "continent": r.Continent,
// "ituzone":fmt.Sprintf("%d",r.ITUZone),
// "cqzone":fmt.Sprintf("%d",r.CQZone),
// "band": r.Band,
// "dxcc":r.Dxcc}).Inc()
// }
// reportList[r.CallSign] = r
}