Logstash:如何使用过滤器来使用S3时,匹配文件名 [英] Logstash: how to use filter to match filename when using s3

查看:619
本文介绍了Logstash:如何使用过滤器来使用S3时,匹配文件名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来logstash。我有存储在AWS S3的一些日志,我能够导入到logstash。我的问题是:是否有可能使用神交过滤器来添加基于文件名的标签?我尝试使用:

I am new to logstash. I have some logs stored in AWS S3 and I am able to import them to logstash. My question is: is it possible to use the grok filter to add tags based on the filenames? I try to use:

grok { 
    match => {"path" => "%{GREEDYDATA}/%{GREEDYDATA:bitcoin}.err.log"}
    add_tag => ["bitcoin_err"]
    }

这是行不通的。我想原因是路径只接受文件的输入。

This is not working. I guess the reason is "path" only working with file inputs.

下面是我的S3桶结构:

Here is the structure of my S3 buckets:

my_buckets
    ----A
        ----2014-07-02
            ----a.log
            ----b.log
    ----B
        ----2014-07-02
            ----a.log
            ----b.log

我使用该输入的conf:

I am using this inputs conf:

s3 {
    bucket => "my_buckets"
    region => "us-west-1"
    credentials => ["XXXXXX","XXXXXXX"]
    }

我要的是,在A / 2014年7月2日/ a.log所有日志消息,他们将有标记[A,A。

What i want is that, for any log messages in "A/2014-07-02/a.log" they will have tag ["A","a"].

A / 2014年7月2日/ b.log:他们将有标记[A,B]

"A/2014-07-02/b.log": they will have tag ["A","b"].

B / 2014年7月2日/ a.log:它们将带有标签[B,一个]

"B/2014-07-02/a.log": they will have tag ["B","a"].

B / 2014年7月2日/ b.log:他们将有标记[B,B]

"B/2014-07-02/b.log": they will have tag ["B","b"].

对不起我的英语......

Sorry about my english....

推荐答案

有一个在S3的输入没有路径。我安装了S3存储我的服务器上,并使用该文件的投入。随着文件的投入,我可以使用过滤器现在匹配的路径。

There is no "path" in S3 inputs. I mount the S3 storage on my server and use the file inputs. With file inputs, I can use the filter to match the path now.

这篇关于Logstash:如何使用过滤器来使用S3时,匹配文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆