mirror of
https://github.com/OneUptime/oneuptime.git
synced 2026-01-11 19:56:44 +00:00
feat: Add log viewing instructions and improve error logging in agent
This commit is contained in:
parent
ded41fc7ec
commit
79dbc94f82
2 changed files with 28 additions and 8 deletions
|
|
@ -44,6 +44,16 @@ oneuptime-infrastructure-agent restart
|
|||
oneuptime-infrastructure-agent uninstall && rm -rf /usr/bin/oneuptime-infrastructure-agent
|
||||
```
|
||||
|
||||
### Viewing agent logs
|
||||
|
||||
```
|
||||
oneuptime-infrastructure-agent logs
|
||||
```
|
||||
|
||||
You can also use the following options:
|
||||
- Show specific number of lines: `oneuptime-infrastructure-agent logs -n 50`
|
||||
- Follow logs in real-time: `oneuptime-infrastructure-agent logs -f`
|
||||
|
||||
### Supported Platforms
|
||||
|
||||
- Linux
|
||||
|
|
@ -78,4 +88,10 @@ sudo ./oneuptime-infrastructure-agent start
|
|||
|
||||
```bash
|
||||
sudo ./oneuptime-infrastructure-agent stop
|
||||
```
|
||||
|
||||
### Viewing logs
|
||||
|
||||
```bash
|
||||
sudo ./oneuptime-infrastructure-agent logs
|
||||
```
|
||||
|
|
@ -129,7 +129,7 @@ func collectMetricsJob(secretKey string, oneuptimeUrl string, proxyUrl string) {
|
|||
}
|
||||
reqBody, err := json.Marshal(reqData)
|
||||
if err != nil {
|
||||
slog.Error("Failed to marshal request data: ", err)
|
||||
slog.Error("Failed to marshal request data", "error", err)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -144,19 +144,23 @@ func collectMetricsJob(secretKey string, oneuptimeUrl string, proxyUrl string) {
|
|||
|
||||
resp, err := client.Post(oneuptimeUrl+"/server-monitor/response/ingest/"+secretKey, "application/json", bytes.NewBuffer(reqBody))
|
||||
if err != nil {
|
||||
slog.Error("Failed to create request: ", err)
|
||||
slog.Error("Failed to send request to server", "error", err)
|
||||
return
|
||||
}
|
||||
|
||||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
slog.Error("Failed to ingest metrics with status code ", resp.StatusCode)
|
||||
respBody, _ := io.ReadAll(resp.Body)
|
||||
slog.Error("Response: ", string(respBody))
|
||||
if resp.StatusCode == http.StatusOK {
|
||||
slog.Info("Metrics successfully pushed to OneUptime server", "status", resp.StatusCode, "endpoint", oneuptimeUrl+"/server-monitor/response/ingest/"+secretKey)
|
||||
} else {
|
||||
slog.Error("Failed to ingest metrics", "status_code", resp.StatusCode)
|
||||
respBody, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
slog.Error("Failed to read error response body", "error", err)
|
||||
} else {
|
||||
slog.Error("Server response", "body", string(respBody))
|
||||
}
|
||||
}
|
||||
|
||||
slog.Info("1 minute metrics have been sent to OneUptime.")
|
||||
}
|
||||
|
||||
func checkIfSecretKeyIsValid(secretKey string, oneuptimeUrl string, proxyUrl string) bool {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue