-
Notifications
You must be signed in to change notification settings - Fork 561
docs: administration: monitoring: on-demand-flush: Add on-demand flush to the HTTP server #2642
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
Open
RaJiska
wants to merge
4
commits into
fluent:master
Choose a base branch
from
RaJiska:http-flush-now
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+89
−0
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
25fb041
docs: administration: monitoring: on-demand-flush: Add on-demand flus…
RaJiska 005531f
docs: summary: Add on-demand flush entry
RaJiska c93cc64
docs: summary: Further describe flush_now_count semantics
RaJiska 87100dc
docs: administration: on-demand-flush: Correct response semantics and…
eschabell File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| --- | ||
| description: Trigger an immediate flush over HTTP, independent of the periodic Flush interval | ||
| --- | ||
|
|
||
| # On-demand flush | ||
|
|
||
| Fluent Bit supports triggering a flush of currently buffered records on demand, over the HTTP server, independent of the configured periodic `Flush` interval. | ||
|
|
||
| ## Enable the HTTP server | ||
|
|
||
| To get started with on-demand flush over HTTP, enable the HTTP Server in the configuration file: | ||
|
|
||
| {% tabs %} | ||
| {% tab title="fluent-bit.yaml" %} | ||
|
|
||
| ```yaml | ||
| service: | ||
| http_server: on | ||
| http_listen: 0.0.0.0 | ||
| http_port: 2020 | ||
| ``` | ||
|
|
||
| {% endtab %} | ||
| {% tab title="fluent-bit.conf" %} | ||
|
|
||
| ```text | ||
| [SERVICE] | ||
| HTTP_Server On | ||
| HTTP_Listen 0.0.0.0 | ||
| HTTP_PORT 2020 | ||
| ``` | ||
|
|
||
| {% endtab %} | ||
| {% endtabs %} | ||
|
|
||
| ## How to flush | ||
|
|
||
| After enabling the HTTP server, use one of the following methods to trigger an on-demand flush: | ||
|
|
||
| ### HTTP | ||
|
|
||
| Use the following HTTP endpoints to trigger an on-demand flush: | ||
|
|
||
| - `PUT /api/v2/flush` | ||
| - `POST /api/v2/flush` | ||
|
|
||
| The endpoint ignores the request body, so no payload is required. To trigger a flush with curl: | ||
|
|
||
| ```shell | ||
| curl -X POST http://localhost:2020/api/v2/flush | ||
| ``` | ||
|
|
||
| Obtain a count of on-demand flushes using the HTTP endpoint: | ||
|
|
||
| - `GET /api/v2/flush` | ||
|
|
||
| The endpoint returns `flush_now_count` as follows: | ||
|
|
||
| ```json | ||
| {"flush_now_count":3} | ||
| ``` | ||
|
|
||
| The default value of the counter is `0`. | ||
|
|
||
| ## What a flush does | ||
|
|
||
| An on-demand flush performs two steps. Fluent Bit first invalidates any pending retries and reschedules them to run immediately, so chunks waiting in retry backoff are sent without waiting out their backoff timer. Tasks that are already running are left untouched. Fluent Bit then dispatches the currently buffered chunks to the output plugins, which is the same work the periodic `Flush` interval performs. | ||
|
|
||
| ## Confirm a flush | ||
|
|
||
| A successful request returns HTTP status `200` with the incremented counter: | ||
|
|
||
| ```json | ||
| {"flush":"done","flush_now_count":3} | ||
| ``` | ||
|
|
||
| `flush_now_count` is a process-wide counter incremented once per on-demand flush processed by the engine. It's incremented when buffered chunks are dispatched to the output plugins. A `200` only guarantees the engine is processing chunks, not that they got pushed out or received by the outputs. Because the counter is global, it can't be used to correlate a response with a specific request when several flushes are issued concurrently. | ||
|
|
||
| If the engine doesn't acknowledge the request within 2 seconds, the endpoint responds with HTTP status `503`. The reported counter is the current process-wide value, which doesn't include this request: | ||
|
|
||
| ```json | ||
| {"flush":"timeout","flush_now_count":2} | ||
| ``` | ||
|
|
||
| A `503` means the engine didn't acknowledge the request in time, not that the flush was cancelled. The request stays queued and the engine can still process it later, incrementing the counter after the response was sent. | ||
|
|
||
| The endpoint responds with HTTP status `500` and an empty body in two cases. If the request can't be delivered to the engine, no flush is triggered and the counter isn't incremented. If the JSON response can't be encoded, the flush was already requested and might have completed, so the counter can still advance. A `GET` request returns `500` with an empty body under the same encoding failure. | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.