mirror of
https://github.com/TwiN/gatus.git
synced 2024-12-23 15:18:55 +01:00
Publish metrics when monitoring
This commit is contained in:
parent
3620e5306c
commit
e162740654
@ -3,6 +3,7 @@ package watchdog
|
|||||||
import (
|
import (
|
||||||
"github.com/TwinProduction/gatus/config"
|
"github.com/TwinProduction/gatus/config"
|
||||||
"github.com/TwinProduction/gatus/core"
|
"github.com/TwinProduction/gatus/core"
|
||||||
|
"github.com/TwinProduction/gatus/metric"
|
||||||
"log"
|
"log"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
@ -20,9 +21,11 @@ func GetServiceResults() *map[string][]*core.Result {
|
|||||||
func Monitor() {
|
func Monitor() {
|
||||||
for _, service := range config.Get().Services {
|
for _, service := range config.Get().Services {
|
||||||
go func(service *core.Service) {
|
go func(service *core.Service) {
|
||||||
|
|
||||||
for {
|
for {
|
||||||
log.Printf("[watchdog][Monitor] Monitoring serviceName=%s", service.Name)
|
log.Printf("[watchdog][Monitor] Monitoring serviceName=%s", service.Name)
|
||||||
result := service.EvaluateConditions()
|
result := service.EvaluateConditions()
|
||||||
|
metric.PublishMetricsForService(service, result)
|
||||||
rwLock.Lock()
|
rwLock.Lock()
|
||||||
serviceResults[service.Name] = append(serviceResults[service.Name], result)
|
serviceResults[service.Name] = append(serviceResults[service.Name], result)
|
||||||
if len(serviceResults[service.Name]) > 10 {
|
if len(serviceResults[service.Name]) > 10 {
|
||||||
|
Loading…
Reference in New Issue
Block a user