diff --git a/api/graylog.go b/api/graylog.go index 306ff46..ed3010f 100644 --- a/api/graylog.go +++ b/api/graylog.go @@ -16,7 +16,9 @@ package api import ( + "bytes" "crypto/tls" + "encoding/json" "io" "net/http" "strconv" @@ -151,7 +153,20 @@ func UpdateRegistration(httpClient *http.Client, ctx *context.Ctx, status *grayl registration.NodeDetails.Status = status registration.NodeDetails.Metrics = metrics if len(ctx.UserConfig.ListLogFiles) > 0 { - registration.NodeDetails.LogFileList = common.ListFiles(ctx.UserConfig.ListLogFiles) + fileList := common.ListFiles(ctx.UserConfig.ListLogFiles) + buf := new(bytes.Buffer) + if fileList != nil { + json.NewEncoder(buf).Encode(fileList) + } + fileListSize := buf.Len() + // Maximum MongoDB document size is 16793600 bytes so we leave some extra space for the rest of the request + // before we skip to send the file list. + if fileListSize < 10000000 { + registration.NodeDetails.LogFileList = fileList + } else { + log.Warn("[UpdateRegistration] Maximum file list size exceeded, skip sending list of active log files!" + + " Adjust list_log_file setting.") + } } }