open-falcon

官网:https://book.open-falcon.org/zh_0_2/usage/nodata.html

编程API:http://open-falcon.org/falcon-plus/

 

1,agent只要部署到机器上,并且配置好了heartbeat和transfer就自动采集数据了

2,hostsgroup,往组里加机器的时候如果报错,需要检查portal的数据库中host表,看里边是否有相关机器。那host表中的机器从哪里来呢?agent有个heartbeat(hbs)的配置,agent每分钟会发心跳给hbs,把自己的ip、hostname、agent version等信息告诉hbs,hbs负责写入host表。如果host表中没数据,需要检查这条链路是否通畅。

 

3,agent配置文件:

{
    "debug": true, # 控制一些debug信息的输出,生产环境通常设置为false
    "hostname": "", # agent采集了数据发给transfer,endpoint就设置为了hostname,默认通过`hostname`获取,如果配置中配置了hostname,就用配置中的
    "ip": "", # agent与hbs心跳的时候会把自己的ip地址发给hbs,agent会自动探测本机ip,如果不想让agent自动探测,可以手工修改该配置
    "plugin": {
        "enabled": false, # 默认不开启插件机制
        "dir": "./plugin", # 把放置插件脚本的git repo clone到这个目录
        "git": "https://github.com/open-falcon/plugin.git", # 放置插件脚本的git repo地址
        "logs": "./logs" # 插件执行的log,如果插件执行有问题,可以去这个目录看log
    },
    "heartbeat": {
        "enabled": true, # 此处enabled要设置为true
        "addr": "127.0.0.1:6030", # hbs的地址,端口是hbs的rpc端口
        "interval": 60, # 心跳周期,单位是秒
        "timeout": 1000 # 连接hbs的超时时间,单位是毫秒
    },
    "transfer": {
        "enabled": true, # 此处enabled要设置为true
        "addrs": [
            "127.0.0.1:8433",
            "127.0.0.1:8433"
        ], # transfer的地址,端口是transfer的rpc端口, 可以支持写多个transfer的地址,agent会保证HA
        "interval": 60, # 采集周期,单位是秒,即agent一分钟采集一次数据发给transfer
        "timeout": 1000 # 连接transfer的超时时间,单位是毫秒
    },
    "http": {
        "enabled": true, # 是否要监听http端口
        "listen": ":1988" # 如果监听的话,监听的地址,收集到数据通过agent的v1/push接口转发
    },
    "collector": {
        "ifacePrefix": ["eth", "em"] # 默认配置只会采集网卡名称前缀是eth、em的网卡流量,配置为空就会采集所有的,lo的也会采集。可以从/proc/net/dev看到各个网卡的流量信息
    },
    "ignore": { # 默认采集了200多个metric,可以通过ignore设置为不采集
        "cpu.busy": true,
        "mem.swapfree": true
    }
}

接口使用范式:
ts=`date +%s`; curl -X POST -d "[{\"metric\": \"metric.demo\", \"endpoint\": \"qd-open-falcon-judge01.hd\", \"timestamp\": $ts,\"step\": 60,\"value\": 9,\"counterType\": 
\"GAUGE\",\"tags\": \"project=falcon,module=judge\"}]" http://127.0.0.1:1988/v1/push 必要的数据结构: metric: 最核心的字段,代表这个采集项具体度量的是什么, 比如是cpu_idle呢,还是memory_free, 还是qps endpoint: 标明Metric的主体(属主),比如metric是cpu_idle,那么Endpoint就表示这是哪台机器的cpu_idle timestamp: 表示汇报该数据时的unix时间戳,注意是整数,代表的是秒 value: 代表该metric在当前时间点的值,float64 step: 表示该数据采集项的汇报周期,这对于后续的配置监控策略很重要,必须明确指定。 counterType: 只能是COUNTER或者GAUGE二选一,前者表示该数据采集项为计时器类型,后者表示其为原值 (注意大小写) GAUGE:即用户上传什么样的值,就原封不动的存储 COUNTER:指标在存储和展现的时候,会被计算为speed,即(当前值 - 上次值)/ 时间间隔 tags: 一组逗号分割的键值对, 对metric进一步描述和细化, 可以是空字符串. 比如idc=lg,比如service=xbox等,多个tag之间用逗号分割

线上配置:

cat agent/config/cfg.json
{
"debug": false,
"hostname": "",
"ip": "",
"plugin": {
"enabled": false,
"dir": "./plugin",
"git": "https://github.com/open-falcon/plugin.git",
"logs": "./logs"
},
"heartbeat": {
"enabled": true,
"addr": "falcon远端serverip:6030",
"interval": 60,
"timeout": 1000
},
"transfer": {
"enabled": true,
"addrs": [
"falcon 远端serverip:8433"
],
"interval": 60,
"timeout": 1000
},
"http": {
"enabled": false,
"listen": "127.0.0.1:1988",
"backdoor": false
},
"collector": {
"ifacePrefix": ["eth", "em"],
"mountPoint": []
},
"default_tags": {
},
"ignore": {
"cpu.busy": true,
"df.bytes.free": true,
"df.bytes.total": true,
"df.bytes.used": true,
"df.bytes.used.percent": true,
"df.inodes.total": true,
"df.inodes.free": true,
"df.inodes.used": true,
"df.inodes.used.percent": true,
"mem.memtotal": true,
"mem.memused": true,
"mem.memused.percent": true,
"mem.memfree": true,
"mem.swaptotal": true,
"mem.swapused": true,
"mem.swapfree": true
}
}


windows go agent:
https://github.com/freedomkk-qfeng/windows-agent 
posted @ 2022-02-22 17:42  mmgithub123  阅读(126)  评论(0编辑  收藏  举报