metrics now include service name for each service metric

pull/688/head
hunterlong 2020-06-21 21:51:40 -07:00
parent 85059bda4f
commit 5a042e3c66
4 changed files with 10 additions and 10 deletions

View File

@ -28,7 +28,6 @@ func (f *Failure) AfterDelete() {
}
func (f *Failure) AfterCreate() {
metrics.Inc("failure", f.Service)
metrics.Query("failure", "create")
}

View File

@ -27,7 +27,6 @@ func (h *Hit) AfterDelete() {
}
func (h *Hit) AfterCreate() {
metrics.Inc("success", h.Service)
metrics.Query("hit", "create")
}

View File

@ -10,7 +10,7 @@ var (
Name: "service_online",
Help: "If service is online",
},
[]string{"service", "name", "type"},
[]string{"service", "type"},
)
// service failures

View File

@ -88,7 +88,7 @@ func isIPv6(address string) bool {
// checkIcmp will send a ICMP ping packet to the service
func CheckIcmp(s *Service, record bool) (*Service, error) {
defer s.updateLastCheck()
timer := prometheus.NewTimer(metrics.ServiceTimer(s.Id))
timer := prometheus.NewTimer(metrics.ServiceTimer(s.Name))
defer timer.ObserveDuration()
if err := utils.Ping(s.Domain, s.Timeout); err != nil {
@ -105,7 +105,7 @@ func CheckIcmp(s *Service, record bool) (*Service, error) {
// CheckGrpc will check a gRPC service
func CheckGrpc(s *Service, record bool) (*Service, error) {
defer s.updateLastCheck()
timer := prometheus.NewTimer(metrics.ServiceTimer(s.Id))
timer := prometheus.NewTimer(metrics.ServiceTimer(s.Name))
defer timer.ObserveDuration()
dnsLookup, err := dnsCheck(s)
@ -152,7 +152,7 @@ func CheckGrpc(s *Service, record bool) (*Service, error) {
// checkTcp will check a TCP service
func CheckTcp(s *Service, record bool) (*Service, error) {
defer s.updateLastCheck()
timer := prometheus.NewTimer(metrics.ServiceTimer(s.Id))
timer := prometheus.NewTimer(metrics.ServiceTimer(s.Name))
defer timer.ObserveDuration()
dnsLookup, err := dnsCheck(s)
@ -219,7 +219,7 @@ func (s *Service) updateLastCheck() {
// checkHttp will check a HTTP service
func CheckHttp(s *Service, record bool) (*Service, error) {
defer s.updateLastCheck()
timer := prometheus.NewTimer(metrics.ServiceTimer(s.Id))
timer := prometheus.NewTimer(metrics.ServiceTimer(s.Name))
defer timer.ObserveDuration()
dnsLookup, err := dnsCheck(s)
@ -285,7 +285,7 @@ func CheckHttp(s *Service, record bool) (*Service, error) {
s.LastResponse = string(content)
s.LastStatusCode = res.StatusCode
metrics.Gauge("status_code", float64(res.StatusCode), s.Id)
metrics.Gauge("status_code", float64(res.StatusCode), s.Name)
if s.Expected.String != "" {
match, err := regexp.MatchString(s.Expected.String, string(content))
@ -329,7 +329,8 @@ func recordSuccess(s *Service) {
fmt.Sprintf("Service #%d '%v' Successful Response: %s | Lookup in: %s | Online: %v | Interval: %d seconds", s.Id, s.Name, humanMicro(hit.Latency), humanMicro(hit.PingTime), s.Online, s.Interval))
s.LastLookupTime = hit.PingTime
s.LastLatency = hit.Latency
metrics.Gauge("online", 1., s.Id, s.Name, s.Type)
metrics.Gauge("online", 1., s.Name, s.Type)
metrics.Inc("success", s.Name)
sendSuccess(s)
s.SuccessNotified = true
}
@ -383,7 +384,8 @@ func recordFailure(s *Service, issue string) {
s.Online = false
s.SuccessNotified = false
s.DownText = s.DowntimeText()
metrics.Gauge("online", 0., s.Id, s.Name, s.Type)
metrics.Gauge("online", 0., s.Name, s.Type)
metrics.Inc("failure", s.Name)
sendFailure(s, fail)
}