Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Limit list_log_file response size #265

Merged
merged 2 commits into from
Aug 1, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion api/graylog.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
package api

import (
"bytes"
"crypto/tls"
"encoding/json"
"io"
"net/http"
"strconv"
Expand Down Expand Up @@ -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.")
}
}
}

Expand Down