filebeat_OutPut 介绍


title: filebeat Output

date: 2017-06-11 05:22:31

categories: elk

tags: filebeat


Filbeat OutPut

Filebeat Elasticsearch OutPut

configure

output.elasticsearch:
  hosts: ["http://localhost:9200"]
  template.enabled: true
  template.path: "filebeat.template.json"
  template.overwrite: false
  index: "filebeat"
  ssl.certificate_authorities: ["/etc/pki/root/ca.pem"]
  ssl.certificate: "/etc/pki/client/cert.pem"
  ssl.key: "/etc/pki/client/cert.key"

定义ip port add portocalhttps

output.elasticsearch:
  hosts: ["localhost"]
  protocol: "https"
  username: "admin"
  password: "s3cr3t"

  • compression_level

    • gzip 压缩级别 range(1-9)
  • work

    • 发送事件到es的工作数量
  • index

    • The index name to write events to.
    • The default is "filebeat-%{+yyyy.MM.dd}" (for example,"filebeat-2015.04.26").
  • indices

支持条件,基于格式字符串的字段访问和名称映射的索引选择器规则的数组

- index 
    - 要使用的索引格式字符串。 如果使用的字段丢失,则规则失败。 
- mapping 
    - 映射字典为新名字
- default 
    - 默认字符串数值
- when  
    - 选择匹配条件

```
output.elasticsearch:
  hosts: ["http://localhost:9200"]
  index: "logs-%{+yyyy.MM.dd}"
  indices:
    - index: "critical-%{+yyyy.MM.dd}"
      when.contains:
        message: "CRITICAL"
    - index: "error-%{+yyyy.MM.dd}"
      when.contains:
        message: "ERR"

```
  • pipeline

    • 格式字符串指定获取节点写入事件pipeline的id值

        output.elasticsearch:
          hosts: ["http://localhost:9200"]
          pipeline: my_pipeline_id
      
  • pipelines

    filebeat.prospectors:
    - paths: ["/var/log/app/normal/*.log"]
        fields:
        type: "normal"
    - paths: ["/var/log/app/critical/*.log"]
        fields:
        type: "critical"
    
    output.elasticsearch:
    hosts: ["http://localhost:9200"]
    index: "filebeat-%{+yyyy.MM.dd}"
    pipelines:
      - pipeline: critical_pipeline
           when.equals:
              type: "critical"
     - pipeline: normal_pipeline
           when.equals:
              type: "normal"
    
    
  • template

    output.elasticsearch:
      hosts: ["localhost:9200"]
      template.name: "filebeat"
      template.path: "filebeat.template.json"
      template.overwrite: false
  • templates.versions
output.elasticsearch:
  hosts: ["localhost:9200"]
  template.path: "filebeat.template.json"
  template.overwrite: false
  template.versions.2x.path: "filebeat.template-es2x.json

  • max_retries

    • 当发送失败的时候,尝试多少次发送事件
  • bulk_max_size

    • 单个Elasticsearch批量API索引请求中批量的最大事件数 默认值为50
  • timeout

    • The http request timeout in seconds for the Elasticsearch request
    • The default is 90
  • flush_interval

    • 在两个批量API索引请求之间等待新事件的秒数
  • ssl

Filebeat Logstash OutPut

需要logstash服务端安装beat插件 使用lumberjack协议发送事件到logstash

output.logstash:
  hosts: ["localhost:5044"]

  • Metadata Fields
    • @meatedata
      • Filebeat使用@metadata字段将元数据发送到Logstash

      • @metadata字段的内容只存在于Logstash中,不属于从Logstash发送的任何事件的一部分

      • 有关@metadata字段的更多信息,请参阅Logstash文档logstash doucument

          {
              ...
              "@metadata": { 
                "beat": "filebeat", 
                "type": "<event type>" 
              }   
          }
        

logstash to elasticsearch

input {
  beats {
    port => 5044
  }
}

output {
  elasticsearch {
    hosts => ["http://localhost:9200"]
    index => "%{[@metadata][beat]}-%{+YYYY.MM.dd}" 
    document_type => "%{[@metadata][type]}" 
  }
}

  • enabled

  • hosts

  • compression_level

  • worker

  • loadbalance

    output.logstash:
      hosts: ["localhost:5044", "localhost:5045"]
      loadbalance: true
      index: filebeat
    
  • pipelining

    • 异步处理事件,默认关闭
  • index

  • ssl

  • timeout

  • max_retries

  • bulk_max_size

    • The maximum number of events to bulk in a single Logstash request
    • The default is 2048.

kafka OutPut

The Kafka output sends the events to Apache Kafka.

output.kafka:
  # initial brokers for reading cluster metadata
  hosts: ["kafka1:9092", "kafka2:9092", "kafka3:9092"]

  # message topic selection + partitioning
  topic: '%{[type]}'
  partition.round_robin:
    reachable_only: false

  required_acks: 1
  compression: gzip
  max_message_bytes: 1000000

  • enabled

  • hosts

  • version

  • username

  • password

  • topic

  • topics

    • topic
    • mapping
    • default
    • when
  • partition

    • random.group_events
    • round_robin.group_events
    • hash.hash
    • hash.random
  • client_id

  • worker

  • codec

  • metadata

    • refresh_frequency
    • retry.max
    • retry.backoff
  • max_retries

  • bulk_max_size

  • timeout

  • broker_timeout

  • channel_buffer_size

  • keep_alive

  • compression

  • max_message_bytes

  • required_acks

  • flush_interval

  • ssl

Redis OutPut

This output works with Redis 3.2.4.

output.redis:
  hosts: ["localhost"]
  password: "my_password"
  key: "filebeat"
  db: 0
  timeout: 5

  • enabled
  • hosts
  • port
  • index
  • key
    output.redis:
      hosts: ["localhost"]
      key: "%{[fields.list]:fallback}"  
  • keys

    • key

    • mapping

    • default

    • when

        output.redis:
          hosts: ["localhost"]
          key: "default_list"
          keys:
            - key: "info_list"   # send to info_list if `message` field contains INFO
              when.contains:
                message: "INFO"
           - key: "debug_list"  # send to debug_list if `message` field contains DEBUG
             when.contains:
               message: "DEBUG"
           - key: "%{[type]}"
              mapping:
                "http": "frontend_list"
                "nginx": "frontend_list"
                "mysql": "backend_list"
      
  • passport

  • db

  • datatype

用于发布事件的Redis数据类型。如果数据类型为列表,则使用Redis RPUSH命令,并将所有事件添加到列表中,并在键下定义键。 如果使用数据类型通道,则使用Redis PUBLISH命令,这意味着所有事件都被推送到Redis的pub / sub机制。 通道的名称是键下定义的。 默认值为列表。

  • codec
  • worker
  • loadbalance
  • timeout
  • max_retries
  • bulk_max_size
  • ssl
  • proxy_url
  • proxy_use_local_resolver

File OutPut

文件输出将事务转储到每个事务处于JSON格式的文件中。 目前,该输出用于测试,但可以作为Logstash的输入

output.file:
  path: "/tmp/filebeat"
  filename: filebeat
  #rotate_every_kb: 10000
  #number_of_files: 7
  • enables
  • path
    • 定义保存文件的路径
  • filename
    • 定义保存文件的名字
  • rotate_every_kb
    • 定义每个文件达到多少kb就开始切割
  • number_if_files
    • 定义保存几份文件
  • codec

Console OutPut

output.console:
  pretty: true
  • pretty
  • codec
  • enabled
  • bulk_max_size

Codec Output

output.console:
  codec.json:
    pretty: true
output.console:
  codec.format:
    string: '%{[@timestamp]} %{[message]}'

Loggin OutPut

logging.level: warning
logging.to_files: true
logging.to_syslog: false
logging.files:
  path: /var/log/mybeat
  name: mybeat.log
  rotateeverybytes: 10MB 
  keepfiles: 7

Debugging

By default, Filebeat sends all its output to syslog. When you run Filebeat in the foreground, you can use the -e command line flag to redirect the output to standard error instead. For example:

filebeat -e

The default configuration file is filebeat.yml (the location of the file varies by platform). You can use a different configuration file by specifying
the -c flag. For example:

filebeat -e -c myfilebeatconfig.yml

You can increase the verbosity of debug messages by enabling one or more debug selectors. For example, to view the published transactions, you can start Filebeat with the publish selector like this:

filebeat -e -d "publish"

If you want all the debugging output (fair warning, it’s quite a lot), you can use *, like this:

filebeat -e -d "*"

support

https://www.elastic.co/support/matrix#show_compatibility

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 194,457评论 5 459
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 81,837评论 2 371
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 141,696评论 0 319
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 52,183评论 1 263
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 61,057评论 4 355
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 46,105评论 1 272
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 36,520评论 3 381
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 35,211评论 0 253
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 39,482评论 1 290
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 34,574评论 2 309
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 36,353评论 1 326
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 32,213评论 3 312
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 37,576评论 3 298
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 28,897评论 0 17
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 30,174评论 1 250
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 41,489评论 2 341
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 40,683评论 2 335

推荐阅读更多精彩内容