Giter Site home page Giter Site logo

falcon-logdog's Introduction

falcon-logdog

open-falcon日志关键词监控

下载

可以下载2进制包进行安装,也可以clone本库到机器上安装。clone本库的话,请自行编译。control 脚本默认执行的是 falcon-logdog 文件。

配置

配置文件名字为 cfg.json ,而且必须是这个名字。各个字段说明如下:

名字 默认值 必填 说明
metric 统计度量,比如叫做 log
path 要监控的日志目录或者文件,如果是目录则会寻找其中一个匹配的日志文件,如果是文件,则会直接监控这个文件,但是不管如何,启动程序时候路径都要存在
timer 要同步数据间隔时间和上报数据的step值,api接口貌似最小30,保持 60为好
agent agent api url,比如 http://localhost:1988/v1/push
host hostname 命令查看的值 主机名字,根据hostname设定,不要使用localhost,可能导致查询不到数据
prefix 空字符串 要监控的日志文件名字前缀
suffix .log 要监控的日志文件后缀,如果不填则用默认值
keywords 是 keyword对象数组

keyword 对象说明

名字 默认值 必填 说明
exp 正则表达式,tag的value
tag 对应于监控中tag的key

配置热更新

组件支持配置热更新,即不需要重启即可让最新配置生效。注意,配置文件中timer不支持热更新,其余参数都是支持的。同时,如果修改配置文件导致配置错误,新的配置不会生效,会继续使用旧的配置,直到配置内容正确为止。

上报数据

格式如下:

{
	"metrix":"log", 
	"endpoint":"10-10-128-53",
	"timestamp":1470827020,
	"value":5,
	"step":60,
	"counterType":"GAUGE",
	"tags":"tag=exp"
}

其中,tags 格式为 keywords 中 'tag' + '=' + 'FixedExp', FixedExp 是用.替换 exp 之后的并将.去重字符串。

启动脚本

使用 control 脚本来操作: ./control option

option 可以为

  • start 启动
  • stop 停止
  • status 查看运行状态
  • restart 重启
  • tail 类似tail 查看日志

日志操作

  • 如果所监控的文件夹有多个 .log 结尾日志文件,那么只会选择其中一个,可能会选择最后创建的文件(具体还未测试观察)
  • 如果有新的文件创建,且符合上面 prefixsuffix 过滤规则,那么会切换到这个新文件上进行监控。

日志格式

如果有数据要push上去,那么可能会观察到有如下日志产生:

time to push data:  map[key2:{log 10-10-128-53 1470827020 5 60 GAUGE key2=tag2,} key1:{log 10-10-128-53 1470827020 5 60 GAUGE key1=tag,}] 2016-08-10 19:04:40.850295266 +0800 CST

falcon-logdog's People

Contributors

sdvdxl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

falcon-logdog's Issues

采集周期内上报数据丢失的问题

同一个采集周期,被监控日志中只出现一条记录。程序只采集了一条记录,却会向agent提交两条数据。其中一条数据value=1,另一条数据value=0。
以下是app.log:
[09/08/18 15:01:48] [DEBG] event: "/var/log/nginx/access.log": WRITE
[09/08/18 15:01:48] [DEBG] event: "/var/log/nginx/access.log": WRITE
[09/08/18 15:01:55] [DEBG] pushing data: [{"metric":"log","endpoint":"open-falcon","timestamp":1536390115,"value":0,"step":60,"counterType":"GAUGE","tags":"prefix=error,suffix=.log,error.all=."},{"metric":"log","endpoint":"open-falcon","timestamp":1536390115,"value":0,"step":60,"counterType":"GAUGE","tags":"prefix=access,suffix=.log,access.all=."},{"metric":"log","endpoint":"open-falcon","timestamp":1536390105,"value":3,"step":60,"counterType":"GAUGE","tags":"prefix=access,suffix=.log,access.all=."}]
[09/08/18 15:01:55] [DEBG] success
[09/08/18 15:02:55] [DEBG] pushing data: [{"metric":"log","endpoint":"open-falcon","timestamp":1536390175,"value":0,"step":60,"counterType":"GAUGE","tags":"prefix=error,suffix=.log,error.all=."},{"metric":"log","endpoint":"open-falcon","timestamp":1536390175,"value":0,"step":60,"counterType":"GAUGE","tags":"prefix=access,suffix=.log,access.all=."}]
[09/08/18 15:02:55] [DEBG] success

从open-falcon上查询,该周期的数据为0,上报的数据丢失了。
该情况经常是连续出现,之前一段时间还有数据,从一个时间点后就都是0了,但是日志一直有数据。

why?

root@localhost:~/go/src/github.com/falcon-logdog# go build

github.com/go-errors/errors

../go-errors/errors/parse_panic.go:29: undefined: strings.TrimPrefix
../go-errors/errors/parse_panic.go:47: undefined: strings.TrimPrefix

golang.org/x/sys/unix

../../golang.org/x/sys/unix/dev_linux.go:21: Major redeclared in this block
previous declaration at ../../golang.org/x/sys/unix/dev_dragonfly.go:17
../../golang.org/x/sys/unix/dev_linux.go:28: Minor redeclared in this block
previous declaration at ../../golang.org/x/sys/unix/dev_dragonfly.go:22
../../golang.org/x/sys/unix/dev_linux.go:36: Mkdev redeclared in this block
previous declaration at ../../golang.org/x/sys/unix/dev_dragonfly.go:28
../../golang.org/x/sys/unix/syscall_linux.go:60: IoctlSetInt redeclared in this block
previous declaration at ../../golang.org/x/sys/unix/syscall_dragonfly.go:142
../../golang.org/x/sys/unix/syscall_linux.go:64: IoctlSetWinsize redeclared in this block
previous declaration at ../../golang.org/x/sys/unix/syscall_dragonfly.go:146
../../golang.org/x/sys/unix/syscall_linux.go:68: IoctlSetTermios redeclared in this block
previous declaration at ../../golang.org/x/sys/unix/syscall_dragonfly.go:150
../../golang.org/x/sys/unix/syscall_linux.go:74: IoctlGetInt redeclared in this block
previous declaration at ../../golang.org/x/sys/unix/syscall_dragonfly.go:156
../../golang.org/x/sys/unix/syscall_linux.go:80: IoctlGetWinsize redeclared in this block
previous declaration at ../../golang.org/x/sys/unix/syscall_dragonfly.go:162
../../golang.org/x/sys/unix/syscall_linux.go:86: IoctlGetTermios redeclared in this block
previous declaration at ../../golang.org/x/sys/unix/syscall_dragonfly.go:168
../../golang.org/x/sys/unix/syscall_linux.go:232: ImplementsGetwd redeclared in this block
previous declaration at ../../golang.org/x/sys/unix/syscall_dragonfly.go:98
../../golang.org/x/sys/unix/syscall_linux.go:232: too many errors

github.com/sdvdxl/log4go

../sdvdxl/log4go/wrapper.go:208: function ends without a return statement
../sdvdxl/log4go/wrapper.go:232: function ends without a return statement
../sdvdxl/log4go/wrapper.go:256: function ends without a return statement

同一目录下监控多个log

请问下这个问题,什么时候能够修复下呢?
《如果所监控的文件夹有多个 .log 结尾日志文件,那么只会选择其中一个,可能会选择最后创建的文件(具体还未测试观察)》

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.