logstash 笔记

1、Since filters are evaluated in sequence, make sure that the geoip section is after the grok section of the configuration file and that both the grok and geoip sections are nested within the  filter section.

由于过滤器是按顺序评估的,因此请确保geoip部分位于配置文件的grok部分之后,并且grok和geoip部分都嵌套在filter部分中。
参考:Parsing Logs with Logstash

如果指定多个过滤器,则会按照它们在配置文件中出现的顺序进行应用。

2、Logstash管道可以使用多个输入和输出插件来处理来自不同源的数据,并将数据输出到不同的目标。如下所示是logstash接收来自twitter和beats的输入,并将数据分别输出到elasticsearch集群和file

input {
    twitter {
        consumer_key => "enter_your_consumer_key_here"
        consumer_secret => "enter_your_secret_here"
        keywords => ["cloud"]
        oauth_token => "enter_your_access_token_here"
        oauth_token_secret => "enter_your_access_token_secret_here"
    }
    beats {
        port => "5044"
    }
}
output {
    elasticsearch {
        hosts => ["IP Address 1:port1", "IP Address 2:port2", "IP Address 3"]
    }
    file {
        path => "/path/to/target/file"
    }
}

3、如果事件符合特定条件,则可以将过滤器与条件语句结合使用来对事件执行操作。

4、Codecs 基本上是流过滤器,可以作为输入或输出的一部分进行操作。 Codecs 将消息的传输与序列化过程分开。

Codecs 是用于表示数据的Logstash Codecs 的名称。 Codecs 可用于输入和输出。

输入Codecs 提供了一种在数据输入之前解码数据的便捷方法。 输出Codecs 提供了一种方便的方式,可以在数据离开输出之前对其进行编码。 使用输入或输出Codecs ,无需在Logstash管道中使用单独的过滤器。

5、Logstash有两种类型的配置文件:管道配置文件(用于定义Logstash处理管道)和设置文件(用于指定控制Logstash启动和执行的选项)。

设置文件已在Logstash安装中定义。 Logstash包括以下设置文件:

    logstash.yml :包含Logstash配置标志。 可以在此文件中设置标志,而不是在命令行中传递标志。 在命令行上设置的所有标志都将覆盖logstash.yml文件中的相应设置

    pipelines.yml:包含用于在单个Logstash实例中运行多个管道的框架和说明。

6、

Field References

logstash能够通过名称来引用字段。

访问字段的基本语法是[fieldname]。 如果要引用顶级字段,则可以省略[],使用fieldname。 要引用嵌套字段,请指定该字段的完整路径:[顶级字段] [嵌套字段]。

sprintf format

字段引用格式也用在Logstash的sprintf格式中。 这种格式可以从其他字符串中引用字段值。例如:

output {
  statsd {
    increment => "apache.%{[response][status]}"
  }
}

7、

@timestamp记录的是Logstash提取事件的日期,但是在回填日志(输出)时,@timestamp是该事件产生的日期。
发布了221 篇原创文章 · 获赞 26 · 访问量 11万+

猜你喜欢

转载自blog.csdn.net/qq_28808697/article/details/104589832