mirror of
https://github.com/Luzifer/mondash.git
synced 2024-12-23 04:21:18 +00:00
Fix: Welcome dashboard contains no metrics for 1m
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
21e57d0bd9
commit
f3932a4d57
1 changed files with 38 additions and 35 deletions
|
@ -17,9 +17,15 @@ func runWelcomePage(cfg *config.Config) {
|
||||||
welcomeAPIToken := cfg.APIToken
|
welcomeAPIToken := cfg.APIToken
|
||||||
generateTicker := time.NewTicker(time.Minute)
|
generateTicker := time.NewTicker(time.Minute)
|
||||||
|
|
||||||
for {
|
// Do one initial push on start
|
||||||
select {
|
postWelcomeMetric(baseURL, welcomeAPIToken)
|
||||||
case <-generateTicker.C:
|
|
||||||
|
for range generateTicker.C {
|
||||||
|
postWelcomeMetric(baseURL, welcomeAPIToken)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func postWelcomeMetric(baseURL, welcomeAPIToken string) {
|
||||||
beers := rand.Intn(24)
|
beers := rand.Intn(24)
|
||||||
status := "OK"
|
status := "OK"
|
||||||
switch {
|
switch {
|
||||||
|
@ -42,7 +48,7 @@ func runWelcomePage(cfg *config.Config) {
|
||||||
body, err := json.Marshal(beer)
|
body, err := json.Marshal(beer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
continue
|
return
|
||||||
}
|
}
|
||||||
url := fmt.Sprintf("%s/welcome/beer_available", baseURL)
|
url := fmt.Sprintf("%s/welcome/beer_available", baseURL)
|
||||||
req, _ := http.NewRequest("PUT", url, bytes.NewBuffer(body))
|
req, _ := http.NewRequest("PUT", url, bytes.NewBuffer(body))
|
||||||
|
@ -50,10 +56,7 @@ func runWelcomePage(cfg *config.Config) {
|
||||||
resp, err := http.DefaultClient.Do(req)
|
resp, err := http.DefaultClient.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("[WelcomeRunner] %s", err)
|
log.Printf("[WelcomeRunner] %s", err)
|
||||||
continue
|
return
|
||||||
}
|
}
|
||||||
resp.Body.Close()
|
resp.Body.Close()
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue