You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: configuration/config-file-yaml.md
+64-2Lines changed: 64 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -22,7 +22,8 @@ Normal Fluentd configuration syntax has the following the list of directives:
22
22
3.**`filter`** directives determine the event processing pipelines
23
23
4.**`system`** directives set system-wide configuration
24
24
5.**`label`** directives group the output and filter for internal routing
25
-
6.**`@include`** directives include other files
25
+
6.**`worker`** directives limit to the specific workers
26
+
7.**`@include`** directives include other files
26
27
27
28
In YAML configuration world, we reconstructed them for YAML format.
28
29
@@ -240,7 +241,68 @@ The `@ROOT` label is a builtin label used for getting root router by plugin's `e
240
241
241
242
This label is introduced since v1.14.0 to assign a label back to the default route. For example, timed-out event records are handled by the concat filter can be sent to the default route.
242
243
243
-
## 6. Reuse your config: the `!include` YAML tag
244
+
## 6. Limit to specific workers: the `worker` element
245
+
246
+
When setting up multiple workers, you can use the **worker** element to limit plugins to run on specific workers.
247
+
248
+
This is useful for input and output plugins that do not support multiple workers.
249
+
250
+
You can use the `$arg N` or `$arg N-M` to specify workers. The number is a zero-based worker index.
251
+
252
+
See [Multi Process Workers](../deployment/multi-process-workers.md) article for details about multiple workers.
253
+
254
+
Here is a configuration example:
255
+
256
+
```text
257
+
system:
258
+
workers: 4
259
+
260
+
config:
261
+
- source:
262
+
$type: sample
263
+
tag: test.allworkers
264
+
sample: "{\"message\": \"Run with all workers.\"}"
265
+
266
+
- worker:
267
+
$arg: 0
268
+
config:
269
+
- source:
270
+
$type: sample
271
+
tag: test.oneworker
272
+
sample: "{\"message\": \"Run with only worker-0.\"}"
273
+
274
+
- worker:
275
+
$arg: 0-1
276
+
config:
277
+
- source:
278
+
$type: sample
279
+
tag: test.someworkers
280
+
sample: "{\"message\": \"Run with worker-0 and worker-1.\"}"
281
+
282
+
- filter:
283
+
$type: record_transformer
284
+
$tag: test.**
285
+
record:
286
+
worker_id: !fluent/s "#{worker_id}"
287
+
288
+
- match:
289
+
$type: stdout
290
+
$tag: test.**
291
+
```
292
+
293
+
The outputs of this config are as follows:
294
+
295
+
```text
296
+
... test.allworkers: {"message":"Run with all workers.","worker_id":"0"}
297
+
... test.allworkers: {"message":"Run with all workers.","worker_id":"1"}
298
+
... test.allworkers: {"message":"Run with all workers.","worker_id":"2"}
299
+
... test.allworkers: {"message":"Run with all workers.","worker_id":"3"}
300
+
... test.oneworker: {"message":"Run with only worker-0.","worker_id":"0"}
301
+
... test.someworkers: {"message":"Run with worker-0 and worker-1.","worker_id":"0"}
302
+
... test.someworkers: {"message":"Run with worker-0 and worker-1.","worker_id":"1"}
303
+
```
304
+
305
+
## 7. Reuse your config: the `!include` YAML tag
244
306
245
307
The element in separate configuration files can be imported using the **!include** element:
Copy file name to clipboardExpand all lines: configuration/config-file.md
+66-2Lines changed: 66 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -60,7 +60,8 @@ The configuration file consists of the following directives:
60
60
3.**`filter`** directives determine the event processing pipelines
61
61
4.**`system`** directives set system-wide configuration
62
62
5.**`label`** directives group the output and filter for internal routing
63
-
6.**`@include`** directives include other files
63
+
6.**`worker`** directives limit to the specific workers
64
+
7.**`@include`** directives include other files
64
65
65
66
Let's actually create a configuration file step by step.
66
67
@@ -280,7 +281,70 @@ The `@ROOT` label is a builtin label used for getting root router by plugin's `e
280
281
281
282
This label is introduced since v1.14.0 to assign a label back to the default route. For example, timed-out event records are handled by the concat filter can be sent to the default route.
282
283
283
-
## 6. Reuse your config: the `@include` directive
284
+
## 6. Limit to specific workers: the `worker` directive
285
+
286
+
When setting up multiple workers, you can use the **worker** directive to limit plugins to run on specific workers.
287
+
288
+
This is useful for input and output plugins that do not support multiple workers.
289
+
290
+
You can use the `<worker N>` or `<worker N-M>` directives to specify workers. The number is a zero-based worker index.
291
+
292
+
See [Multi Process Workers](../deployment/multi-process-workers.md) article for details about multiple workers.
293
+
294
+
Here is a configuration example:
295
+
296
+
```text
297
+
<system>
298
+
workers 4
299
+
</system>
300
+
301
+
<source>
302
+
@type sample
303
+
tag test.allworkers
304
+
sample {"message": "Run with all workers."}
305
+
</source>
306
+
307
+
<worker 0>
308
+
<source>
309
+
@type sample
310
+
tag test.oneworker
311
+
sample {"message": "Run with only worker-0."}
312
+
</source>
313
+
</worker>
314
+
315
+
<worker 0-1>
316
+
<source>
317
+
@type sample
318
+
tag test.someworkers
319
+
sample {"message": "Run with worker-0 and worker-1."}
320
+
</source>
321
+
</worker>
322
+
323
+
<filter test.**>
324
+
@type record_transformer
325
+
<record>
326
+
worker_id "#{worker_id}"
327
+
</record>
328
+
</filter>
329
+
330
+
<match test.**>
331
+
@type stdout
332
+
</match>
333
+
```
334
+
335
+
The outputs of this config are as follows:
336
+
337
+
```text
338
+
... test.allworkers: {"message":"Run with all workers.","worker_id":"0"}
339
+
... test.allworkers: {"message":"Run with all workers.","worker_id":"1"}
340
+
... test.allworkers: {"message":"Run with all workers.","worker_id":"2"}
341
+
... test.allworkers: {"message":"Run with all workers.","worker_id":"3"}
342
+
... test.oneworker: {"message":"Run with only worker-0.","worker_id":"0"}
343
+
... test.someworkers: {"message":"Run with worker-0 and worker-1.","worker_id":"0"}
344
+
... test.someworkers: {"message":"Run with worker-0 and worker-1.","worker_id":"1"}
345
+
```
346
+
347
+
## 7. Reuse your config: the `@include` directive
284
348
285
349
The directives in separate configuration files can be imported using the **@include** directive:
0 commit comments