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

Fix Sumo Logic output plugin not splitting requests properly (#25) #8115

Conversation

pmalek-sumo
Copy link
Contributor

This should fix 2 problems:

  • sending the last request with empty body (the condition when calculating boundary was incorrect)
  • sending requests bigger than 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:

  • Signed CLA.
  • Associated README.md updated.
  • Has appropriate unit tests.

@sjwang90 sjwang90 added the feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin label Sep 11, 2020
Copy link
Contributor

@ssoroka ssoroka left a 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.

@pmalek-sumo
Copy link
Contributor Author

A better approach might be to ensure your batch size is small enough that you don't ever need to chunk

Can you explain a bit more how should that work?

  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.

I'd rather just do 1.

@sjwang90 sjwang90 added this to the 1.16.0 milestone Sep 14, 2020
@pmalek-sumo pmalek-sumo force-pushed the fix-sumologic-output-plugin-metrics-chunks-pr branch from abc95cb to a508b3a Compare September 15, 2020 14:20
@pmalek-sumo
Copy link
Contributor Author

pmalek-sumo commented Sep 15, 2020

I've changed the logic to just log the error when a chunk fails to get sent.

Copy link
Contributor

@ssoroka ssoroka left a 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)
Copy link
Contributor

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++
Copy link
Contributor

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.

@ssoroka ssoroka merged commit ca7252c into influxdata:master Sep 24, 2020
@pmalek-sumo pmalek-sumo deleted the fix-sumologic-output-plugin-metrics-chunks-pr branch September 25, 2020 09:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants