beats 组件的开发

看了一下filebeat源码,提取了主干,但是还是不知道filebeat到底如何加载配置文件,如何采集日志文件,请问我该从哪入手好切入,求大神指导。感激不尽。。。

已邀请:

duanquanyong

赞同来自: KSpeer astaxie

如果只是增加一个processor或者output的话。 只需要注册进去就可以了

package main

import (
    _ "processor/command"
    _ "output/nsq"
    "github.com/elastic/beats/filebeat/cmd"
    "os"
)

func main() {
    if err := cmd.RootCmd.Execute(); err != nil {
        os.Exit(1)
    }
}
package command

import (
    "github.com/elastic/beats/libbeat/processors"
)

func init() {
    processors.RegisterPlugin("command",
        processor.ConfigChecked(New,
            processor.RequireFields("cwd"),
            processor.RequireFields("name"),
            processor.RequireFields("args"),
            processor.AllowedFields("cwd", "name", "args"),
        ))
}

如果不是,看看文档吧 https://www.elastic.co/guide/en/beats/libbeat/current/new-beat.html

mingming5577 - 90后程序媛

赞同来自:

楼上大神,正在filebeat项目里开发一个processor,代码注册了,但是在make后执行filebeat,提示找不到这个processor

func init() {
    processors.RegisterPlugin("add_processor", newProcessor)
}

配置文件: processors:

  • add_processor: timeWindow: 10 fields: ["message"]

启动报错: 2018-11-08T16:36:53.546+0800 ERROR instance/beat.go:824 Exiting: error initializing publisher: error initializing processors: the processor add_processor doesn't exist Exiting: error initializing publisher: error initializing processors: the processor add_processor doesn't exist

要回复问题请先登录注册