fluent-bit icon indicating copy to clipboard operation
fluent-bit copied to clipboard

Add an option to control the maximum size of JSON output

Open LionelCons opened this issue 5 years ago • 34 comments

When using an output plugin like http to send JSON data, one can mainly choose between the json_lines and json formats.

With json_lines, every log entry triggers a POST request, which implies a significant overhead, both on the network and on the receiving end.

With json, a single POST request can group multiple log entries. This is good. However, if there are many entries to send, this can result in sending a huge POST request that the receiver might struggle to handle.

It would be useful to be able to control the maximum size of the JSON output. It could be a maximum number of log entries or a maximum number of bytes.

LionelCons avatar Jul 27 '20 10:07 LionelCons

@LionelCons

On every flush call (applicable for all output plugins), they receive a Chunk which contains N records. In the case of the HTTP output plugin, the json_lines format just compose the payload in a different way than json, adding a breaking \n between each record. Note: there is a single HTTP POST to the remote end-point containing all the records together, not one per record.

edsiper avatar Nov 24 '20 03:11 edsiper

@edsiper, you write "they receive a Chunk which contains N records".

Is it possible to set a maximum value for N?

LionelCons avatar Nov 24 '20 07:11 LionelCons

it's not possible, our chunks are near 2MB, all records in the chunk are under the same tag

edsiper avatar Nov 24 '20 16:11 edsiper

Then, is it possible to reduce the chunk size?

I found the Mem_Buf_Limit option but that seems to be at input level.

LionelCons avatar Nov 25 '20 06:11 LionelCons

FWIW, I have made some tests with a big log file.

I saw an average size of 3.5 MB for the POST requests. This of course depends on formatting options (like Json_Date_Format).

This does not seem much but in an infrastructure with many fluent-bit instances sending their data in parallel this can be hard to swallow. We use Flume and the JSON input has to be parsed and enriched so it requires much more memory than its sheer size.

LionelCons avatar Nov 25 '20 07:11 LionelCons

FWIW, this is very similar to https://github.com/fluent/fluent-bit/issues/1938.

If we can control the max chunk size (per output plugin) then we can indirectly control the size of the JSON payload.

LionelCons avatar Apr 23 '21 07:04 LionelCons

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar May 25 '21 02:05 github-actions[bot]

This issue is still creating problems in some of our workflows.

LionelCons avatar May 25 '21 05:05 LionelCons

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Jun 28 '21 01:06 github-actions[bot]

This issue is still creating problems in some of our workflows.

LionelCons avatar Jun 30 '21 06:06 LionelCons

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 5 days. Maintainers can add the exempt-stale label.

github-actions[bot] avatar Jan 04 '22 01:01 github-actions[bot]

This issue is still creating problems in some of our workflows.

LionelCons avatar Jan 05 '22 10:01 LionelCons

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 5 days. Maintainers can add the exempt-stale label.

github-actions[bot] avatar Apr 06 '22 02:04 github-actions[bot]

This issue is still creating problems in some of our workflows.

LionelCons avatar Apr 06 '22 05:04 LionelCons

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 5 days. Maintainers can add the exempt-stale label.

github-actions[bot] avatar Jul 06 '22 02:07 github-actions[bot]

This issue is still creating problems in some of our workflows.

LionelCons avatar Jul 06 '22 07:07 LionelCons

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 5 days. Maintainers can add the exempt-stale label.

github-actions[bot] avatar Oct 06 '22 02:10 github-actions[bot]

This issue is still creating problems in some of our workflows.

LionelCons avatar Oct 06 '22 04:10 LionelCons

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 5 days. Maintainers can add the exempt-stale label.

github-actions[bot] avatar Jan 06 '23 02:01 github-actions[bot]

This issue is still creating problems in some of our workflows.

LionelCons avatar Jan 09 '23 07:01 LionelCons

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 5 days. Maintainers can add the exempt-stale label.

github-actions[bot] avatar Apr 11 '23 01:04 github-actions[bot]

This issue is still creating problems in some of our workflows.

LionelCons avatar Apr 11 '23 03:04 LionelCons

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 5 days. Maintainers can add the exempt-stale label.

github-actions[bot] avatar Jul 11 '23 02:07 github-actions[bot]

This issue is still creating problems in some of our workflows.

LionelCons avatar Jul 11 '23 06:07 LionelCons

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 5 days. Maintainers can add the exempt-stale label.

github-actions[bot] avatar Oct 11 '23 01:10 github-actions[bot]

This issue is still creating problems in some of our workflows.

LionelCons avatar Oct 11 '23 05:10 LionelCons

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 5 days. Maintainers can add the exempt-stale label.

github-actions[bot] avatar Jan 11 '24 01:01 github-actions[bot]

This issue is still creating problems in some of our workflows.

LionelCons avatar Jan 11 '24 06:01 LionelCons

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 5 days. Maintainers can add the exempt-stale label.

github-actions[bot] avatar Apr 14 '24 02:04 github-actions[bot]

This issue is still creating problems in some of our workflows.

LionelCons avatar Apr 15 '24 04:04 LionelCons