Swarmlab docs

Application development in a distributed system

Development of Distributed Systems from Design to Application


You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

150 lines
5.5 KiB

3 years ago
= dummy_service
3 years ago
== fluent.conf
3 years ago
3 years ago
config file: WriteToMongo/fluent/fluent.conf
3 years ago
3 years ago
=== edit
3 years ago
3 years ago
[source,c]
3 years ago
----
<match debug.*>
@type stdout
</match>
3 years ago
<source> // <1>
@type tail
3 years ago
3 years ago
path /var/log/*.log
path_key tailed_path
pos_file /tmp/fluentd--1605454018.pos
3 years ago
pos_file_compaction_interval 30s
refresh_interval 30s
skip_refresh_on_startup
3 years ago
tag stats.node
3 years ago
3 years ago
enable_stat_watcher false
enable_watch_timer true
3 years ago
read_from_head true
follow_inodes true # Without this parameter, file rotation causes log duplication
<parse>
3 years ago
@type none
3 years ago
keep_time_key true
</parse>
</source>
3 years ago
# define the source which will provide log events
3 years ago
<source> // <1>
@type tail // <2>
3 years ago
3 years ago
path /var/log-in/*/* // <3>
3 years ago
path_key tailed_path
3 years ago
pos_file /tmp/fluentd--1605454014.pos // <4>
pos_file_compaction_interval 10s
3 years ago
refresh_interval 30s
skip_refresh_on_startup
3 years ago
tag log.node // <5>
3 years ago
3 years ago
enable_stat_watcher false // <6>
enable_watch_timer true // <7>
3 years ago
read_from_head true
follow_inodes true # Without this parameter, file rotation causes log duplication
<parse>
3 years ago
@type none // <8>
3 years ago
keep_time_key true
</parse>
</source>
3 years ago
## match tag=log.* and write to mongo
3 years ago
<match log.*> // <9>
3 years ago
@type copy
3 years ago
copy_mode deep // <10>
<store ignore_error> // <11>
3 years ago
@type mongo // <12>
3 years ago
3 years ago
connection_string mongodb://mongo.poc-datacollector_datacollector-net:27017/fluentdb // <13>
3 years ago
#database fluentdb
collection test
#host mongo.poc-datacollector_datacollector-net
#port 27017
num_retries 60
3 years ago
capped // <14>
capped_size 100m
3 years ago
<inject>
# key name of timestamp
time_key time
</inject>
<buffer>
retry_wait 50s
3 years ago
flush_mode immediate // <15>
3 years ago
#flush_interval 10s
</buffer>
</store>
<store ignore_error>
@type stdout
</store>
<store ignore_error>
@type file
path /tmp/mylog
<buffer>
timekey 1d
timekey_use_utc true
timekey_wait 10s
</buffer>
</store>
</match>
----
3 years ago
<1> *<source>* directives determine the input sources. The source submits events to the Fluentd routing engine. An event consists of three entities: *tag*, *time* and *record*.
3 years ago
<2> The *tail Input plugin* allows Fluentd to read events from the tail of text files. Its behavior is similar to the tail -F command. xref:doc-dummy_service.adoc#tailmongo[see image: type tai]
<3> The *path(s) to read*. Multiple paths can be specified, separated by comma ','. '*' format can be included to add/remove the watch file dynamically. At the interval of refresh_interval, Fluentd refreshes the list of watch files.
<4> *pos_file* handles multiple positions in one file so no need to have multiple pos_file parameters per source. Don't share *pos_file* between *tail* configurations. It causes unexpected behavior e.g. corrupt pos_file content.
<5> The *tag* of the event.
<6> Enables the additional inotify-based watcher. *Either of enable_watch_timer or enable_stat_watcher must be true*
<7> Enables the additional watch timer. *Either of enable_watch_timer or enable_stat_watcher must be true*
<8> The *none parser plugin* parses the line as-is with the single field. This format is to defer the parsing/structuring of the data.
3 years ago
<9> *<match>* directives determine the output destinations. The match directive looks for events with matching tags and processes them. The most common use of the match directive is to *output events to other systems*.
3 years ago
<10> Chooses how to pass the events to <store> plugins. *deep* copied events to each store plugin. This mode is useful when you modify the nested field after out_copy, e.g. Docker Swarm/Kubernetes related fields.
<11> Specifies the *storage destinations*. The format is the same as the <match> directive. This section is required at least once.
<12> The *mongo Output plugin* writes records into , the document-oriented database system.
3 years ago
<13> The https://docs.mongodb.com/manual/reference/connection-string/#std-label-connections-standard-connection-string-format[MongoDB connection string^] for URI.
3 years ago
<14> This option enables the *capped collection*. This is always recommended. https://docs.mongodb.com/manual/core/capped-collections/[Capped collections^] are fixed-size collections that support high-throughput operations that insert and retrieve documents based on insertion order. Capped collections work in a way similar to circular buffers: once a collection fills its allocated space, it makes room for new documents by overwriting the oldest documents in the collection.
<15> *Flushing* Parameters:
3 years ago
3 years ago
[#tailmongo]
.type tail
3 years ago
image::ROOT:fluent-mongo.png[float=right]
3 years ago
3 years ago
=== restart
3 years ago
3 years ago
3 years ago
To make changes become effective a restart is required
3 years ago
3 years ago
[source,bash]
----
3 years ago
./tools/poc-service-restart-dummy
3 years ago
----
3 years ago
3 years ago