diff --git a/types/failures/database.go b/types/failures/database.go index e2cd7d1b..e3aad286 100644 --- a/types/failures/database.go +++ b/types/failures/database.go @@ -28,7 +28,6 @@ func (f *Failure) AfterDelete() { } func (f *Failure) AfterCreate() { - metrics.Inc("failure", f.Service) metrics.Query("failure", "create") } diff --git a/types/hits/database.go b/types/hits/database.go index 3268279f..5c3ce19f 100644 --- a/types/hits/database.go +++ b/types/hits/database.go @@ -27,7 +27,6 @@ func (h *Hit) AfterDelete() { } func (h *Hit) AfterCreate() { - metrics.Inc("success", h.Service) metrics.Query("hit", "create") } diff --git a/types/metrics/services.go b/types/metrics/services.go index 24f5908b..a0b43439 100644 --- a/types/metrics/services.go +++ b/types/metrics/services.go @@ -10,7 +10,7 @@ var ( Name: "service_online", Help: "If service is online", }, - []string{"service", "name", "type"}, + []string{"service", "type"}, ) // service failures diff --git a/types/services/routine.go b/types/services/routine.go index 3162d641..30eb2b8d 100644 --- a/types/services/routine.go +++ b/types/services/routine.go @@ -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) }