Fluentd
Search…
copy
The copy output plugin copies events to multiple outputs.
It is included in Fluentd's core.

Example Configuration

1
<match pattern>
2
@type copy
3
<store>
4
@type file
5
path /var/log/fluent/myapp1
6
...
7
</store>
8
<store>
9
...
10
</store>
11
<store>
12
...
13
</store>
14
</match>
Copied!
Please see the Configuration File article for the basic structure and syntax of the configuration file.
Here is an example set up to send events to both a local file under /var/log/fluent/myapp and the collection fluentd.test to an Elasticsearch instance (See out_file and out_elasticsearch):
1
<match myevent.file_and_elasticsearch>
2
@type copy
3
<store>
4
@type file
5
path /var/log/fluent/myapp
6
compress gzip
7
<format>
8
localtime false
9
</format>
10
<buffer time>
11
timekey_wait 10m
12
timekey 86400
13
timekey_use_utc true
14
path /var/log/fluent/myapp
15
</buffer>
16
<inject>
17
time_format %Y%m%dT%H%M%S%z
18
localtime false
19
</inject>
20
</store>
21
<store>
22
@type elasticsearch
23
host fluentd
24
port 9200
25
index_name fluentd
26
type_name fluentd
27
</store>
28
</match>
Copied!

Plugin Helpers

Parameters

@type

The value must be copy.

copy_mode

type
default
available
version
enum
no_copy
no_copy, shallow, deep, marshal
1.8.1
Chooses how to pass the events to <store> plugins.
Supported modes:
    no_copy (default)
    Share events between store plugins.
    shallow
    Pass shallow copied events to each store plugin. This mode uses Ruby's dup method. This mode is useful when you do not modify the nested fields after out_copy, e.g. remove top-level fields.
    deep
    Pass deep copied events to each store plugin. This mode uses msgpack-ruby internally. This mode is useful when you modify the nested field after out_copy, e.g. Kubernetes related fields.
    marshal
    Pass deep copied events to each store plugin. This mode uses Ruby's marshal internally. This mode is useful when msgpack-ruby cannot process your events. This mode is very slow.

deep_copy

type
default
version
bool
false
0.14.0
This parameter is deprecated since v1.8.1. Use copy_mode instead.
out_copy shares a record between store plugins by default.
If true, out_copy passes dupped record to each store plugin. This behavior is similar to copy_mode shallow.

<store> Section

Specifies the storage destinations. The format is the same as the <match> directive.
This section is required at least once.

ignore_error argument

If one store raises an error, it affects other <store>. For example:
1
<match app.**>
2
@type copy
3
<store>
4
@type plugin1
5
</store>
6
<store>
7
@type plugin2
8
</store>
9
</match>
Copied!
If plugin1's emit/format raises an error, plugin2 is not executed. If you want to ignore an error from a less important <store>, you can specify ignore_error in <store>:
1
<match app.**>
2
@type copy
3
<store ignore_error>
4
@type plugin1
5
</store>
6
<store>
7
@type plugin2
8
</store>
9
</match>
Copied!

ignore_if_prev_successes argument

Since Fluentd v1.12.2, you can use ignore_if_prev_successes to define fallback outputs. For example:
1
<match app.**>
2
@type copy
3
<store ignore_error>
4
@type plugin1
5
name c0
6
</store>
7
<store ignore_if_prev_success ignore_error>
8
@type plugin2
9
name c1
10
</store>
11
</match>
Copied!
Fluentd will make use of plugin2 only if the preceeding destinations (plugin1 in this case) fail.
If this article is incorrect or outdated, or omits critical information, please let us know. Fluentd is an open-source project under Cloud Native Computing Foundation (CNCF). All components are available under the Apache 2 License.
Last modified 4mo ago