feat: Add more logging to the metrics code
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
parent
8f09aa959b
commit
9abc268315
@ -2,6 +2,7 @@ package pages
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@ -45,12 +46,29 @@ func (c *LokiMetricConfig) sendMetricPing(domain, path string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.Debugf("Sending payload %s", string(jsonData))
|
||||||
|
|
||||||
// Send the ping to the Loki server
|
// Send the ping to the Loki server
|
||||||
go func() {
|
go func() {
|
||||||
http.Post(
|
res, err := http.Post(
|
||||||
c.Url,
|
c.Url,
|
||||||
"application/json",
|
"application/json",
|
||||||
strings.NewReader(string(jsonData)),
|
strings.NewReader(string(jsonData)),
|
||||||
)
|
)
|
||||||
|
if err != nil {
|
||||||
|
log.Errorf("Failed to send payload to Loki: %v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
defer res.Body.Close()
|
||||||
|
if res.StatusCode != 204 {
|
||||||
|
log.Errorf("Loki returned non-204 status code %d", res.StatusCode)
|
||||||
|
body, err := ioutil.ReadAll(res.Body)
|
||||||
|
if err != nil {
|
||||||
|
log.Warnf("Failed to read body. No more specific error message")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
log.Errorf("-> %s", body)
|
||||||
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user