Skip to content

Commit b79d3ad

Browse files
authored
Merge pull request #386 from fluent/rewrite-buffer-path-description
Rewrite wrong description about `path` of file buffer plugin
2 parents 948056a + 4b14fea commit b79d3ad

File tree

3 files changed

+88
-66
lines changed

3 files changed

+88
-66
lines changed

buffer/file.md

Lines changed: 87 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,50 +9,86 @@ The `file` buffer plugin provides a persistent buffer implementation. It uses fi
99

1010
### `path`
1111

12-
| type | required | default | version |
13-
| :--- | :---: | :--- | :--- |
14-
| string || | 0.9.0 |
15-
16-
The path where buffer chunks are stored. The '\*' is replaced with random characters. This parameter is required.
17-
18-
This parameter must be unique to avoid the race condition problem. For example, you cannot use a fixed path parameter in `fluent-plugin-forest`. `${tag}` or similar placeholder is needed. Of course, this parameter must also be unique between fluentd instances.
12+
| type | default | version |
13+
| :--- | :--- | :--- |
14+
| string | nil | 0.9.0 |
1915

20-
In addition, `path` should not be another `path` prefix. For example, the following configuration does not work well. `/var/log/fluent/foo` resumes `/var/log/fluent/foo.bar`'s buffer files during start phase and it causes `No such file or directory` in `/var/log/fluent/foo.bar` side.
16+
The directory path where buffer chunks are stored. Don't share this directory path with other buffers.
17+
Be sure to specify a unique path for each buffer.
2118

2219
```text
23-
<match pattern1>
20+
<match pattern>
21+
...
2422
<buffer>
2523
@type file
26-
path /var/log/fluent/foo
24+
path /var/log/fluent/buf
2725
</buffer>
2826
</match>
27+
```
2928

30-
<match pattern2>
31-
<buffer>
32-
@type file
33-
path /var/log/fluent/foo.bar
34-
</buffer>
35-
</match>
29+
This config outputs the buffer chunk files as follows. The file name is `buffer.b{chunk_id}{path_suffix}`.
30+
31+
```text
32+
/var/log/fluentd/buf/buffer.b58eec11d08ca8143b40e4d303510e0bb.log
33+
/var/log/fluentd/buf/buffer.b58eec11d08ca8143b40e4d303510e0bb.log.meta
3634
```
3735

38-
Here is the correct version to avoid the prefix problem:
36+
With [multiple workers](../deployment/multi-process-workers.md), a directory is automatically created for each worker.
37+
So there is no need to specify a unique path for each worker.
3938

4039
```text
41-
<match pattern1>
40+
<system>
41+
workers 2
42+
</system>
43+
44+
...
45+
46+
<match pattern>
47+
...
4248
<buffer>
4349
@type file
44-
path /var/log/fluent/foo.baz
50+
path /var/log/fluent/buf
4551
</buffer>
4652
</match>
53+
```
54+
55+
This config outputs the buffer chunk files as follows. The directory `worker{worker_id}` is automatically created.
56+
57+
```text
58+
/var/log/fluentd/buf/worker0/buffer.b58eec11d08ca8143b40e4d303510e0bb.log
59+
/var/log/fluentd/buf/worker0/buffer.b58eec11d08ca8143b40e4d303510e0bb.log.meta
60+
61+
/var/log/fluentd/buf/worker1/buffer.b5e2a5aca2bcd9818ad6718845ddc456a.log
62+
/var/log/fluentd/buf/worker1/buffer.b5e2a5aca2bcd9818ad6718845ddc456a.log.meta
63+
```
64+
65+
If you specify `root_dir` in [system configuration](../deployment/system-config.md) and [@id](../configuration/plugin-common-parameters.md#id) of the plugin,
66+
then you can omit this parameter.
67+
68+
```text
69+
<system>
70+
root_dir /var/log/fluentd
71+
</system>
72+
73+
...
4774
48-
<match pattern2>
75+
<match pattern>
76+
@id test_id
77+
...
4978
<buffer>
5079
@type file
51-
path /var/log/fluent/foo.bar
5280
</buffer>
5381
</match>
5482
```
5583

84+
This config outputs the buffer chunk files as follows. The directory `{root_dir}/worker{worker_id}/{@id}/buffer` is used for the path.
85+
In this case, the `worker{worker_id}` directory is created even for a single worker.
86+
87+
```text
88+
/var/log/fluentd/worker0/test_id/buffer/buffer.b58eec11d08ca8143b40e4d303510e0bb.log
89+
/var/log/fluentd/worker0/test_id/buffer/buffer.b58eec11d08ca8143b40e4d303510e0bb.log.meta
90+
```
91+
5692
Please make sure that you have **enough space in the path directory**. Running out of disk space is a problem frequently reported by users.
5793

5894
### `path_suffix`
@@ -75,22 +111,47 @@ Changes the suffix of the buffer file.
75111

76112
This parameter is useful when `.log` is not fit for your environment. See also [this issue's comment](https://github.com/fluent/fluentd/issues/2236#issuecomment-514733974).
77113

78-
## Example
114+
## Tips
115+
116+
### Customize a filename of the buffer chunk
117+
118+
You can customize the prefix of filename (`buffer` by default) by adding `.*` to the end of the `path` parameter.
79119

80120
```text
81121
<match pattern>
122+
...
82123
<buffer>
83124
@type file
84-
path /var/log/fluent/myapp.*.buffer
125+
path /var/log/fluent/buf/custom.*
85126
</buffer>
86127
</match>
87128
```
88129

89-
## Tips
130+
This config outputs the buffer chunk files as follows. The prefix `buffer` is changed to `custom`.
90131

91-
### Multi-Process Environment
132+
```text
133+
/var/log/fluentd/buf/custom.b58eec11d08ca8143b40e4d303510e0bb.log
134+
/var/log/fluentd/buf/custom.b58eec11d08ca8143b40e4d303510e0bb.log.meta
135+
```
92136

93-
If you use this plugin under the multi-process environment, you need to use `@id`/`root_dir` parameters instead of fixed `path` parameter. See [Multi Process Workers](../deployment/multi-process-workers.md#root_dir-id-parameter) article.
137+
You can also customize the entire filename by adding `.*.` to the `path` parameter.
138+
139+
```text
140+
<match pattern>
141+
...
142+
<buffer>
143+
@type file
144+
path /var/log/fluent/buf/custom_prefix.*.custom_suffix
145+
</buffer>
146+
</match>
147+
```
148+
149+
This config outputs the buffer chunk files as follows. In this case, `path_suffix` parameter is not used.
150+
151+
```text
152+
/var/log/fluentd/buf/custom_prefix.b58eec11d08ca8143b40e4d303510e0bb.custom_suffix
153+
/var/log/fluentd/buf/custom_prefix.b58eec11d08ca8143b40e4d303510e0bb.custom_suffix.meta
154+
```
94155

95156
## Limitation
96157

configuration/plugin-common-parameters.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ The `@id` parameter specifies a unique name for the configuration. It is used as
3131
</match>
3232
```
3333

34-
This parameter should be specified for all the plugins to enable `root_dir` and `workers` feature globally.
34+
This parameter should be specified for all the plugins to enable `root_dir` feature globally.
3535

3636
See also: [System Configuration](../deployment/system-config.md)
3737

deployment/multi-process-workers.md

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -131,45 +131,6 @@ As of Fluentd v1.4.0, `<worker N-M>` syntax has been introduced:
131131

132132
With this directive, you can specify multiple workers per worker directive.
133133

134-
### `root_dir/@id` parameter
135-
136-
These parameters must be specified when you use the file buffer.
137-
138-
With multi-process workers, you cannot use the fixed `path` configuration for file buffer because it conflicts buffer file path between processes.
139-
140-
```text
141-
<system>
142-
workers 2
143-
</system>
144-
145-
<match pattern>
146-
@type forward
147-
<buffer>
148-
@type file
149-
path /var/log/fluentd/forward # This is not allowed
150-
</buffer>
151-
</match>
152-
```
153-
154-
Instead of a fixed configuration, fluentd provides the dynamic buffer path based on `root_dir` and `@id` parameters. The stored path is `${root_dir}/worker${worker index}/${plugin @id}/buffer` directory.
155-
156-
```text
157-
<system>
158-
workers 2
159-
root_dir /var/log/fluentd
160-
</system>
161-
162-
<match pattern>
163-
@type forward
164-
@id out_fwd
165-
<buffer>
166-
@type file
167-
</buffer>
168-
</match>
169-
```
170-
171-
With this configuration, `forward` output buffer files are stored into `/var/log/fluentd/worker0/out_fwd/buffer` and `/var/log/fluentd/worker1/out_fwd/buffer` directories.
172-
173134
## Operation
174135

175136
Each worker consumes memory and disk space separately. Take care while configuring buffer spaces and monitoring memory/disk consumption.

0 commit comments

Comments
 (0)