<filter elb-com> @type geoip geoip_lookup_keys client_ip backend_library geoip2_c geoip_database /fluentd/plugin/GeoLite2-City.mmdb <record> location '[${location.latitude["client_ip"]},${location.longitude["client_ip"]}]' city ${city.names.en["client_ip"]} country_name ${country.names.en["client_ip"]} region_name ${subdivisions.0.names.en["client_ip"]} </record> </filter>
<filter request> @type grep <exclude> key message pattern /.*healthcheck.*|.*prometheusMetrics.*|.*(v1+\/)+(configurations)+(\/+versions).*/ </exclude> </filter>
<filter *> @type record_transformer remove_keys message </filter>
path /log-dir/*-app.log pos_file /log-dir/app.log.pos
多个日志文件的位置记录写入一个位置记录文件,会致使日志位置记录的错误,想的办法:为每一个日志文件单独配置一个位置记录的文件。git
path /log-dir/*-app.log pos_file ${path}.ops
想经过引用的方式来为每一个path建立一个ops,可是结局不生效经过仔细阅读官方文档,发现一个in_tail进程里的ops是能够存放多个pathdocker
我把日志写入docker日志文件,发现fluentd处理读取和处理速度并不慢,猜想多是fluentd传输到ES过程当中的问题。
经过在在match输出上面刷新缓冲区,及时把缓冲区的数据送到ES,express
<match app.*> @type elasticsearch host elasticsearchlog-lb.elasticsearch-log index_name s3-fluentd-idaas type_name s3-fluentd-idaas flush_interval 2s include_timestamp true ssl_verify false </match>
第二个方法就是找到冲突的地方删除掉冲突点(仅仅是个想法)app
id和key都没问题,由于昨天晚上我从S3上拉取下来过,elasticsearch
今天s3的桶里面加上了路径ide
Amazon S3 logstash-idaas/2018/10/20/
容器日志报出的错误测试
error_class=Aws::S3::Errors::NoSuchKey error="The specified key does not exist."
(1)测试没有前缀的时候是否会报错优化
结局:报错少了一些,可是仍是会报错
(2)排错过程:插件
1.我想看看logstash中S3插件是否会给我产生灵感 否 2.我想测试fluentd中是否有插件致使了这个问题 否 经过把原有插件卸载,使用最简插件方案来运行这个配置文件 3.Google搜索看看 否 4.SQS队列里含有各桶的数据,相互之间冲突,新建一个SQS解决这个问题 nice 测试出来的缘由就是SQS处理多个S3桶数据的时候,每一个桶之间的数据会相互杂糅,促使fluentd拉去数据的时候前缀路径冲突,这个时候咱们每个桶分配一个SQS解决这个问题
2018/11/12 上午11:52:552018-11-12 11:52:55 +0800 [error]: #0 unexpected error error_class=Aws::SQS::Errors::NonExistentQueue error="The specified queue does not exist or you do not have access to it
检查队列名字和SQS的权限配置,还有须要检查S3桶的事件通知日志
2018/11/15 下午7:00:222018-11-15 19:00:22 +0800 [warn]: #0 dump an error event: error_class=Fluent::Plugin::ElasticsearchErrorHandler::ElasticsearchError error="400 - Rejected by Elasticsearch" location=nil tag="app.idaas"
经过观看,发现这个问题主要是app.idaas标签产生的,由于这个标签没有filter,后来对app.idaas进行一次filter后,这个警告问题能够大大缓解。
<filter app.idaas> @type parser key_name thread_name reserve_data yes <parse> @type regexp expression /(?<thread_name>[\d\D]+)/ </parse> </filter>
2018/11/16 下午4:16:072018-11-16 16:16:07 +0800 [warn]: #0 Could not push logs to Elasticsearch, resetting connection and trying again. read timeout reached 2018-11-16 16:16:44 +0800 [warn]: #0 buffer flush took longer time than slow_flush_log_threshold: elapsed_time=66.07182049937546 slow_flush_log_threshold=20.0 plugin_id="object:2ac85a0bd4a0"
去除下面buffer中的timekey和timekey_wait
index_name s3-fluentd-request-%Y%m%d <buffer tag,time> timekey 4s timekey_wait 1s </buffer>
fluentd日志处理-安装配置(一)
https://blog.51cto.com/11078047/2316881
Fluentd 日志处理-S3拉取日志处理(二)
https://blog.51cto.com/11078047/2316910
Fluentd日志处理-tail拉取(三)
https://blog.51cto.com/11078047/2316958