In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
How to use Fluentd and MongoDB to build a log collection system, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail, people with this need can come to learn, I hope you can gain something.
Installation
In order to complete the relevant tests, the following components need to be installed:
Fluentd with MongoDB Plugin
MongoDB
Apache (with the Combined Log Format)
The MongoDB plug-in is already included in Fluentd's latest installation package, and you can also use the command
Gem install fluent-plugin-mongo
To install
Debian Package
RPM Package
MongoDB Downloads
Configuration
If you installed Fluentd using the deb/rpm package above, the configuration file is located at: / etc/td-agent/td-agent.conf, otherwise it should be at: / etc/fluentd/fluentd.conf
First, we edit the source in the configuration file to set the log source
Source >
Type tail
Format apache
Path / var/log/apache2/access_log
Tag mongo.apache
/ source >
How to build a log collection system using Fluentd and MongoDB
Where:
① type tail: tail is a built-in input method for Fluentd, which works by constantly fetching new logs from the source file.
② format apache: specifies the use of Fluentd's built-in Apache log parser.
③ path / var/log/apache2/access_log: specify the log file location.
④ tag mongo.apache: specifies that tag,tag is used to classify different logs
Next, edit the output configuration, configure the log collection and store it in MongoDB.
Match mongo.** >
# plugin type
Type mongo
# mongodb db + collection
Database apache
Collection access
# mongodb host + port
Host localhost
Port 27017
# interval
Flush_interval 10s
/ match >
The match tag can be followed by a regular expression to match the tag we specified. Only the logs corresponding to the matching tag will apply the configuration inside. Other items in the configuration are easy to understand, just look at the comments, where flush_interval is used to control how often the log is written to MongoDB.
test
Access the Apache with the ab tool to generate the corresponding access log for collection
$ab-n 100-c 10 http://localhost/
Then we can see the collected logs in MongoDB.
Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.