-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Fix Sumo Logic output plugin not splitting requests properly (#25) #8115
Fix Sumo Logic output plugin not splitting requests properly (#25) #8115
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once the requests are chunked, if any one succeeds, you may need to log the error (not return it) and continue to attempt to deliver all the rest of the chunks. This means dropping the ones that don't deliver correctly, as there's no way to partially deliver a batch. ... actually...
A better approach might be to ensure your batch size is small enough that you don't ever need to chunk, as once you start chunking your only options when a chunk fails to deliver is to: 1. Drop chunks that don't make it and accept the batch as delivered (returning no error), or 2. accept delivering duplicates and return an error, retrying the entire batch.
Can you explain a bit more how should that work?
I'd rather just do 1. |
abc95cb
to
a508b3a
Compare
I've changed the logic to just log the error when a chunk fails to get sent. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nearly there. two small change requests.
@@ -214,7 +214,7 @@ func (s *SumoLogic) Write(metrics []telegraf.Metric) error { | |||
func (s *SumoLogic) writeRequestChunks(chunks [][]byte) error { | |||
for _, reqChunk := range chunks { | |||
if err := s.write(reqChunk); err != nil { | |||
return err | |||
log.Printf("E! [SumoLogic] Error sending chunk: %v", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add
Log telegraf.Logger `toml:"-"`
to the struct, then you can use the Telegraf logger (which is automatically set with the logger instance), which doesn't require writing E! and [SumoLogic]
linesCount int | ||
) | ||
ts.Config.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | ||
requestCount++ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might need atomic.AddInt32
/ atomic.LoadInt32
for these counters. It's a different goroutine, and isn't race safe.
This should fix 2 problems:
MaxRequstBodySize
(now it will only happen when it's configured so small so that it's not able to accomodate even one metric - a warning will be printed out in such case but the request will go through).Required for all PRs: