You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: correlation/api/newLogHandler.go
+9-5Lines changed: 9 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -3,12 +3,13 @@ package api
3
3
import (
4
4
"encoding/json"
5
5
"fmt"
6
-
"github.com/utmstack/UTMStack/correlation/ti"
7
6
"io"
8
-
"log"
9
7
"net/http"
10
8
"time"
11
9
10
+
"github.com/threatwinds/go-sdk/catcher"
11
+
"github.com/utmstack/UTMStack/correlation/ti"
12
+
12
13
"github.com/gin-gonic/gin"
13
14
"github.com/google/uuid"
14
15
"github.com/tidwall/gjson"
@@ -29,7 +30,7 @@ func NewLog(c *gin.Context) {
29
30
iferr!=nil {
30
31
response["status"] ="error"
31
32
response["error"] =fmt.Sprintf("%v", err)
32
-
log.Println(response["error"])
33
+
catcher.Error("Failed to read request body", err, map[string]any{"status": http.StatusBadRequest})
33
34
c.JSON(http.StatusBadRequest, response)
34
35
return
35
36
}
@@ -38,7 +39,7 @@ func NewLog(c *gin.Context) {
38
39
iferr:=json.Unmarshal(body, &lo); err!=nil {
39
40
response["status"] ="error"
40
41
response["error"] =fmt.Sprintf("%v", err)
41
-
log.Println(response["error"])
42
+
catcher.Error("Failed to read request body", err, map[string]any{"status": http.StatusBadRequest})
42
43
c.JSON(http.StatusBadRequest, response)
43
44
return
44
45
}
@@ -69,7 +70,10 @@ func NewLog(c *gin.Context) {
69
70
!gjson.Get(l, "dataSource").Exists() {
70
71
response["status"] ="error"
71
72
response["error"] ="The log doesn't have the required fields. Please be sure that you are sending the @timestamp in RFC3339Nano format, the dataType that could be windows, linux, iis, macos, ... and the dataSource that could be the Hostname or IP of the log source."
0 commit comments