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

[exporter/elasticsearch] Limit bulk request size to avoid 413 Entity Too Large #36396

Merged
merged 15 commits into from
Nov 21, 2024

Conversation

carsonip
Copy link
Contributor

@carsonip carsonip commented Nov 15, 2024

Description

Limit the bulk request size to roughly flush::bytes for sync bulk indexer.
Sync bulk indexer is used when batcher::enabled is either true or false. In order words, sync bulk indexer is not used when batcher config is undefined.
Change flush::bytes to always measure in uncompressed bytes.
Change default batcher::max_size_items to 0 as bulk request size limit is now more effectively enforced by flush::bytes.

Link to tracking issue

Fixes #36163

Testing

Modified BenchmarkExporter to run with {name: "xxlarge_batch", batchSize: 1000000}, and removed batcher::max_size_items and added a log line for compressed and uncompressed buffer size to reproduce the error.

logger.go:146: 2024-11-19T17:16:40.060Z	ERROR	Flush	{"s.bi.Len": 10382932, "s.bi.UncompressedLen": 532777786}
    logger.go:146: 2024-11-19T17:16:40.312Z	ERROR	bulk indexer flush error	{"error": "flush failed (413): [413 Request Entity Too Large] "}

With this PR, every flush logs and there is no error.

   logger.go:146: 2024-11-19T17:23:52.574Z	ERROR	Flush	{"s.bi.Len": 99148, "s.bi.UncompressedLen": 5000007}

Documentation

@carsonip carsonip changed the title [exporter/elasticsearch] Make batcher respect flush::bytes [exporter/elasticsearch] Make sync bulk indexer respect flush::bytes Nov 15, 2024
@carsonip carsonip changed the title [exporter/elasticsearch] Make sync bulk indexer respect flush::bytes [exporter/elasticsearch] Respect flush::bytes in sync bulk indexer Nov 18, 2024
@carsonip carsonip marked this pull request as ready for review November 18, 2024 13:10
@carsonip carsonip requested a review from a team as a code owner November 18, 2024 13:10
@carsonip carsonip requested a review from ChrsMark November 18, 2024 13:10
@carsonip carsonip marked this pull request as draft November 18, 2024 14:53
@carsonip
Copy link
Contributor Author

Also benched with ~5MB vs ~1MB vs 95MB flush::bytes to an Elastic Cloud 64GB Elasticsearch, with num_workers=1:

5MB:

BenchmarkExporter/logs/otel/xxlarge_batch-16         	       1	99909472632 ns/op	     10009 events/s	13099905120 B/op	68449712 allocs/op

1MB:

BenchmarkExporter/logs/otel/xxlarge_batch-16         	       1	108315234948 ns/op	      9232 events/s	13138234072 B/op	68519404 allocs/op

95MB:

BenchmarkExporter/logs/otel/xxlarge_batch-16         	       1	97584554530 ns/op	     10248 events/s	13092218512 B/op	68444255 allocs/op

@carsonip carsonip marked this pull request as ready for review November 19, 2024 17:49
@carsonip carsonip changed the title [exporter/elasticsearch] Respect flush::bytes in sync bulk indexer [exporter/elasticsearch] Limit bulk request size to avoid 413 Entity Too Large Nov 19, 2024
Copy link
Member

@lahsivjar lahsivjar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need to change the default max size items? Other changes LGTM!

@carsonip carsonip requested a review from lahsivjar November 20, 2024 15:59
Copy link
Member

@lahsivjar lahsivjar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link
Contributor

@mauri870 mauri870 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

Copy link
Member

@ChrsMark ChrsMark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

exporter/elasticsearchexporter/README.md Outdated Show resolved Hide resolved
},
},
Flush: FlushSettings{
Bytes: 5e+6,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: maybe consider moving these defaults to some constant vars at some point. (not for this PR)

@ChrsMark ChrsMark added the ready to merge Code review completed; ready to merge by maintainers label Nov 21, 2024
ChrsMark and others added 2 commits November 21, 2024 18:11
@andrzej-stencel andrzej-stencel merged commit d8276d6 into open-telemetry:main Nov 21, 2024
158 checks passed
@github-actions github-actions bot added this to the next release milestone Nov 21, 2024
mauri870 added a commit to mauri870/beats that referenced this pull request Dec 5, 2024
This code was initially added in elastic#41523 because of a limitation from the
elasticsearch exporter.

The elasticsearch exporter has been updated to enforce flush::max_bytes
for the batcher extension and will automatically split the batch if it
exceeds the limit.

This error is now fixed in the collector v0.115.0.

See open-telemetry/opentelemetry-collector-contrib#36396.
mauri870 added a commit to elastic/beats that referenced this pull request Dec 10, 2024
This code was initially added in #41523 because of a limitation from the
elasticsearch exporter.

The elasticsearch exporter has been updated to enforce flush::max_bytes
for the batcher extension and will automatically split the batch if it
exceeds the limit.

This error is now fixed in the collector v0.115.0.

See open-telemetry/opentelemetry-collector-contrib#36396.
mergify bot pushed a commit to elastic/beats that referenced this pull request Dec 10, 2024
This code was initially added in #41523 because of a limitation from the
elasticsearch exporter.

The elasticsearch exporter has been updated to enforce flush::max_bytes
for the batcher extension and will automatically split the batch if it
exceeds the limit.

This error is now fixed in the collector v0.115.0.

See open-telemetry/opentelemetry-collector-contrib#36396.

(cherry picked from commit dbeb9cd)
mauri870 added a commit to elastic/beats that referenced this pull request Dec 10, 2024
…41971)

This code was initially added in #41523 because of a limitation from the
elasticsearch exporter.

The elasticsearch exporter has been updated to enforce flush::max_bytes
for the batcher extension and will automatically split the batch if it
exceeds the limit.

This error is now fixed in the collector v0.115.0.

See open-telemetry/opentelemetry-collector-contrib#36396.

(cherry picked from commit dbeb9cd)

Co-authored-by: Mauri de Souza Meneguzzo <mauri870@gmail.com>
michalpristas pushed a commit to michalpristas/beats that referenced this pull request Dec 13, 2024
…41911)

This code was initially added in elastic#41523 because of a limitation from the
elasticsearch exporter.

The elasticsearch exporter has been updated to enforce flush::max_bytes
for the batcher extension and will automatically split the batch if it
exceeds the limit.

This error is now fixed in the collector v0.115.0.

See open-telemetry/opentelemetry-collector-contrib#36396.
sbylica-splunk pushed a commit to sbylica-splunk/opentelemetry-collector-contrib that referenced this pull request Dec 17, 2024
…Too Large (open-telemetry#36396)

<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description

Limit the bulk request size to roughly `flush::bytes` for sync bulk
indexer.
Sync bulk indexer is used when `batcher::enabled` is either true or
false. In order words, sync bulk indexer is not used when batcher config
is undefined.
  Change `flush::bytes` to always measure in uncompressed bytes.
Change default `batcher::max_size_items` to `0` as bulk request size
limit is now more effectively enforced by `flush::bytes`.

<!-- Issue number (e.g. open-telemetry#1234) or full URL to issue, if applicable. -->
#### Link to tracking issue
Fixes open-telemetry#36163

<!--Describe what testing was performed and which tests were added.-->
#### Testing

Modified BenchmarkExporter to run with `{name: "xxlarge_batch",
batchSize: 1000000},` and removed `batcher::max_size_items` and added a
log line for compressed and uncompressed buffer size to reproduce the
error.
```
logger.go:146: 2024-11-19T17:16:40.060Z	ERROR	Flush	{"s.bi.Len": 10382932, "s.bi.UncompressedLen": 532777786}
    logger.go:146: 2024-11-19T17:16:40.312Z	ERROR	bulk indexer flush error	{"error": "flush failed (413): [413 Request Entity Too Large] "}
```

With this PR, every flush logs and there is no error.
```
   logger.go:146: 2024-11-19T17:23:52.574Z	ERROR	Flush	{"s.bi.Len": 99148, "s.bi.UncompressedLen": 5000007}
```

<!--Describe the documentation added.-->
#### Documentation

<!--Please delete paragraphs that you did not use before submitting.-->

---------

Co-authored-by: Christos Markou <chrismarkou92@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
exporter/elasticsearch ready to merge Code review completed; ready to merge by maintainers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[exporter/elasticsearch] Handle errors for 413 Entity Too Large
7 participants