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
+23-23
Original file line number
Diff line number
Diff line change
@@ -56,7 +56,7 @@ Let's actually create a configuration file step by step.
56
56
57
57
Fluentd input sources are enabled by selecting and configuring the desired input plugins using **source** elements. Fluentd standard input plugins include `http` and `forward`. The `http` provides an HTTP endpoint to accept incoming HTTP messages whereas `forward` provides a TCP endpoint to accept TCP packets. Of course, it can be both at the same time. You may add multiple `source` configurations as required.
58
58
59
-
```text
59
+
```yaml
60
60
config:
61
61
# Receive events from 24224/tcp
62
62
# This is used by log forwarding and the fluent-cat command
@@ -80,7 +80,7 @@ You can add new input sources by writing your own plugins. For further informati
80
80
81
81
The **match** element looks for events with **match**ing tags and processes them. The most common use of the `match` element is to output events to other systems. For this reason, the plugins that correspond to the `match` element are called **output plugins**. Fluentd standard output plugins include `file` and `forward`. Let's add those to our configuration file.
82
82
83
-
```text
83
+
```yaml
84
84
config:
85
85
# Receive events from 24224/tcp
86
86
# This is used by log forwarding and the fluent-cat command
@@ -153,7 +153,7 @@ System-wide configurations are set by `system` element. Most of them are also av
153
153
154
154
Example:
155
155
156
-
```text
156
+
```yaml
157
157
system:
158
158
# equal to -qq option
159
159
log_level: error
@@ -168,7 +168,7 @@ See also [System Configuration](../deployment/system-config.md) article for more
168
168
169
169
If this parameter is set, fluentd supervisor and worker process names are changed.
170
170
171
-
```text
171
+
```yaml
172
172
system:
173
173
process_name: fluentd1
174
174
```
@@ -191,7 +191,7 @@ The `label` element's parameter is a builtin plugin parameter so `$name` paramet
191
191
192
192
Here is a configuration example:
193
193
194
-
```text
194
+
```yaml
195
195
config:
196
196
- source:
197
197
$type: forward
@@ -253,7 +253,7 @@ See [Multi Process Workers](../deployment/multi-process-workers.md) article for
253
253
254
254
Here is a configuration example:
255
255
256
-
```text
256
+
```yaml
257
257
system:
258
258
workers: 4
259
259
@@ -306,15 +306,15 @@ The outputs of this config are as follows:
306
306
307
307
The element in separate configuration files can be imported using the **!include** element:
308
308
309
-
```text
309
+
```yaml
310
310
config:
311
311
# Include config files in the ./config.d directory
312
312
- !include config.d/*.conf
313
313
```
314
314
315
315
The `!include` YAML tag supports regular file path, glob pattern, and http URL conventions:
316
316
317
-
```text
317
+
```yaml
318
318
config:
319
319
# absolute path
320
320
- !include /path/to/config.conf
@@ -333,7 +333,7 @@ config:
333
333
334
334
Note that for the glob pattern, files are expanded in alphabetical order. If there are `a.conf` and `b.conf` then fluentd parses `a.conf` first. But, you should not write the configuration that depends on this order. It is so error-prone, therefore, use multiple separate `!include` YAML tags for safety.
335
335
336
-
```text
336
+
```yaml
337
337
config:
338
338
# If you have a.conf, b.conf, ..., z.conf and a.conf / z.conf are important
339
339
@@ -350,7 +350,7 @@ config:
350
350
351
351
The `!include` YAML tag can be used under sections to share the same parameters:
352
352
353
-
```text
353
+
```yaml
354
354
# config file
355
355
config:
356
356
- match:
@@ -381,7 +381,7 @@ Note that, in the middle of element case of `!include` YAML tag usage, users mus
381
381
382
382
Fluentd tries to match tags in the order that they appear in the config file. So, if you have the following configuration:
383
383
384
-
```text
384
+
```yaml
385
385
config:
386
386
# '**' matches all tags. Bad :(
387
387
- match:
@@ -396,7 +396,7 @@ config:
396
396
397
397
then `myapp.access` is never matched. Wider match patterns should be defined after tight match patterns.
398
398
399
-
```text
399
+
```yaml
400
400
config:
401
401
- match:
402
402
$tag: myapp.access
@@ -413,7 +413,7 @@ Of course, if you use two same patterns, the second `match` is never matched. If
413
413
414
414
The common pitfall is when you put a `filter` element after `match` element. It will never work since events never go through the filter for the reason explained above.
415
415
416
-
```text
416
+
```yaml
417
417
config:
418
418
# You should NOT put this <filter> block after the <match> block below.
419
419
# If you do, Fluentd will just emit events without applying the filter.
@@ -433,7 +433,7 @@ config:
433
433
434
434
When using YAML format syntax in Fluentd configuration, you can use `!fluent/s "#{...}"` to embed arbitrary Ruby code into match patterns. Here is an example:
435
435
436
-
```text
436
+
```yaml
437
437
config:
438
438
- match:
439
439
$tag: fluent/s "app.#{ENV['FLUENTD_TAG']}"
@@ -466,7 +466,7 @@ This section describes some useful features for the configuration file.
466
466
467
467
You can write multiline values for `"` quoted string, array and hash values.
468
468
469
-
```text
469
+
```yaml
470
470
str_param: "foo # Converts to "foo bar". As NL interpretation will be required for continuos newlines.
471
471
bar"
472
472
@@ -488,7 +488,7 @@ Fluentd assumes `[` or `{` is a start of array / hash. So, if you want to set `[
488
488
489
489
Example \# 1: mail plugin
490
490
491
-
```text
491
+
```yaml
492
492
config:
493
493
- match:
494
494
$tag: '**'
@@ -498,7 +498,7 @@ config:
498
498
499
499
Example \# 2: map plugin
500
500
501
-
```text
501
+
```yaml
502
502
config:
503
503
- match:
504
504
$tag:tag
@@ -514,14 +514,14 @@ This restriction will be removed with the configuration parser improvement.
514
514
515
515
You can evaluate the Ruby code with `!fluent/s #{}` in `"` quoted string. This is useful for setting machine information e.g. hostname.
516
516
517
-
```text
517
+
```yaml
518
518
host_param: !fluent/s "#{Socket.gethostname}" # host_param is actual hostname like `webserver1`.
519
519
env_param: !fluent/s "foo-#{ENV['FOO_BAR']}" # NOTE that foo-"#{ENV["FOO_BAR"]}" doesn't work.
520
520
```
521
521
522
522
In YAML config format, `hostname` and `worker_id` shortcuts are also available:
523
523
524
-
```text
524
+
```yaml
525
525
host_param: !fluent/s "#{hostname}" # This is same with Socket.gethostname
526
526
$id: !fluent/s "out_foo#{worker_id}" # This is same with ENV["SERVERENGINE_WORKER_ID"]
527
527
```
@@ -530,22 +530,22 @@ The `worker_id` shortcut is useful under multiple workers. For example, for a se
530
530
531
531
Helper methods `use_nil` and `use_default` are available:
532
532
533
-
```text
533
+
```yaml
534
534
some_param: !fluent/s "#{ENV['FOOBAR'] || use_nil}" # Replace with nil if ENV["FOOBAR"] isn't set
535
535
some_param: !fluent/s "#{ENV['FOOBAR'] || use_default}" # Replace with the default value if ENV["FOOBAR"] isn't set
536
536
```
537
537
538
538
Note that these methods not only replace the embedded Ruby code but the entire string with `nil` or a default value.
539
539
540
-
```text
540
+
```yaml
541
541
some_path: !fluent/s "#{use_nil}/some/path" # some_path is nil, not "/some/path"
542
542
```
543
543
544
544
### In double-quoted string literal, `\` is the escape character
545
545
546
546
The backslash `\` is interpreted as an escape character. You need `\` for setting `"`, `\r`, `\n`, `\t`, `\` or several characters in double-quoted string literal.
547
547
548
-
```text
548
+
```yaml
549
549
str_param: "foo\nbar" # \n is interpreted as actual LF character
0 commit comments