Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How Fluentd deploys logs

2025-02-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces how to deploy the Fluentd log, the article is very detailed, has a certain reference value, interested friends must read it!

Fluentd is used to handle logs generated by other systems, and it itself generates some run-time logs. Let's take a look at Fluentd's own logging mechanism.

Fluentd contains two logging layers: global logs and plug-in-level logs. Logs at each level can be configured separately.

Log level

Fluentd logs contain six levels: fatal, error, warn, info, debug, and trace. The level increases in turn, and the high-level log contains the low-level log. The default is info, so by default, logs include info, warn, error, and fatal logs.

Global log

The Fluentd kernel uses the global log configuration, and if the plug-in does not set its own log configuration item separately, the plug-in also shares the global log configuration entry. It can be set from the command line or from a configuration file.

Command Lin

-v and-vv are used to increase the log level, and-Q and-qq are used to lower the log level.

$fluentd-v... # debug level$ fluentd-vv... # trace level$ fluentd-Q... # warn level$ fluentd-qq... # error leve uses the command line to adjust the log level without changing the configuration file to facilitate debugging.

The configuration file can also configure the global log level in the log_level set in the configuration file.

# equal to-qq option log_level error

Plug-in logs can be set individually for each plug-in through @ log_level, which overrides the global log level.

@ type tail @ log_level debug path / var/log/data.log... @ type http @ log_level fatal in the above clip We set their own log levels for two different input sources.

Log format as described in the first article today, Fluentd logs support both text and json formats, using text by default, which can be set in.

Format json time_format Y-%m-%d if using json format

2017-07-27 06:44:54 + 0900 [info]: # 0 fluentd worker is now running worker=0 this log will be converted to the following output:

{"time": "2017-07-27", "level": "info", "message": "fluentd worker is now running worker=0", "worker_id": 0} writes logs to files Fluentd outputs its logs to stdout by default, and logs can be exported to files with-o.

$fluentd-o / path/to/log_ file if the log is written to a file, Fluentd does not rotate the log by default, that is, logs are constantly written to the specified file, which may cause the log file to be too large. The log rotation function can be enabled through command line parameters.

-- log-rotate-age AGE where AGE is an integer or string, which needs to be used with the rotate-size below. An integer represents the number of rotation files; a string represents the rotation frequency, which can be daily, weekly, or monthly. -log-rotate-size BYTESBYTES is the size of the rotation file. When the number of bytes is reached, the new file will be written. This configuration item controls the rotation of logs when the rotate-age value is an integer. $fluentd-c fluent.conf-log-rotate-age 5-log-rotate-size 104857600

Capture Fluentd logs Fluentd own logs can also be collected. Fluentd uses fluent as the tag of its own logs, which we can use to deal with Fluentd's own logs. # Add hostname for identifying the server @ type record_transformer host "# {Socket.gethostname}"

@ type monitoring_plugin # parameters... One use of this is to monitor the operation of Fluentd.

The above is all the contents of the article "how to deploy the Fluentd log". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report