须知

  1. Logstash会自动为数据添加@version, host, @timestamp等字段
  2. codec => rubydebug 的意思是用于美化输出
  3. type 和 tags 是 logstash 事件中两个特殊的字段。通常来说我们会在输入区段中通过 type 来标记事件类型。tags 则是在数据处理过程中,由具体的插件来添加或者删除的。
  4. 扩容机制- 垂直扩容-增加新的机器代替旧的机器;水平扩容-直接增加机器

    数据Input类型

  • 标准输入【Stdin】

    1. # 输入
    2. input {
    3. stdin {
    4. add_field => {"key" => "value"}
    5. codec => "plain"
    6. tags => ["add"]
    7. type => "std"
    8. }
    9. }
    10. # 输出
    11. {
    12. "message" => "hello world",
    13. "@version" => "1",
    14. "@timestamp" => "2014-08-08T06:48:47.789Z",
    15. "type" => "std",
    16. "tags" => [
    17. [0] "add"
    18. ],
    19. "key" => "value",
    20. "host" => "raochenlindeMacBook-Air.local"
    21. }
  • 读取文件【File】

  • 读取网络数据【TCP】
  • 生成测试数据【Generator】
  • 读取【Syslog数据】
  • 读取【Redis数据】

    数据源为filebeat input,本地日志采集

  • filebeat.yml的配置 ```bash filebeat.prospectors:

  • input_type: log paths:

    日志的来源设置,【恢复数据可以用这种方式?重新写入这个log?】

    • /path/to/file/logstash-tutorial.log output.logstash: hosts: “localhost:5044” ```
  • logstash的pipeline.con文件配置

    1. input {
    2. beats {
    3. port => "5044"
    4. }
    5. }
    6. #filter {
    7. #}
    8. output {
    9. stdout { codec => rubydebug }
    10. }

    数据源为kafka,kafka日志采集

    日志格式处理

    1. input {
    2. beats {
    3. port => "5044"
    4. }
    5. }
    6. filter {
    7. grok {
    8. match => { "message" => "%{COMBINEDAPACHELOG}"}
    9. }
    10. }
    11. output {
    12. stdout { codec => rubydebug }
    13. }

    增加新字段

    和ES索引生命周期的结合