目的
trend 用于预聚合
搭建 open-falcon trend
修改版本信息
vim modules/trend/g/g.go
const (
VERSION = "20200818"
TREND_INTERVALS = 3600 //聚合区间为1小时
)
编译
# make trend
go build -o bin/trend/falcon-trend ./modules/trend
创建目录
mkdir /apps/svr/falcon-plus/trend/{bin,config,logs} -p
配置
{
"log_level": "info",
"gauge": true,
"http": {
"enabled": true,
"listen": "0.0.0.0:6991"
},
"rpc": {
"enabled": true,
"listen": "0.0.0.0:6990"
},
"db": {
"dsn": "falcon:falcontest@tcp(ns-yun-020021.133.com:3306)/vip_falcon_aggregator?loc=Local&parseTime=true",
"batch": 200,
"batchInterval": 60,
"concurrent": 1,
"maxIdle": 4
}
}
启动测试
[root@ns-yun-020021 trend]# ./bin/falcon-trend -c config/cfg.json
2020/08/18 15:41:21 cfg.go:75: g.ParseConfig ok, file config/cfg.json
2020/08/18 15:41:21 http.go:38: http.startHttpServer ok, listening 0.0.0.0:6991
2020/08/18 15:41:21 rpc.go:54: rpc.Start ok, listening on 0.0.0.0:6990
2020/08/18 15:41:21 main.go:20: 2094 register signal notify
启动文件
/usr/lib/systemd/system/falcon-trend.service
[Unit]
Description=falcon trend
After=network-online.target
Before=shutdown.target
[Service]
Type=simple
User=apps
Group=apps
LimitNOFILE=65535
ExecStart=/apps/svr/falcon-plus/trend/bin/falcon-trend -c /apps/svr/falcon-plus/trend/config/cfg.json
Restart=always
StandardOutput=journal
启动服务
[root@ns-yun-020021 trend]# systemctl daemon-reload
[root@ns-yun-020021 trend]# systemctl start falcon-trend
[root@ns-yun-020021 trend]# systemctl status falcon-trend
● falcon-trend.service - falcon trend
Loaded: loaded (/usr/lib/systemd/system/falcon-trend.service; static; vendor preset: disabled)
Active: active (running) since Tue 2020-08-18 15:47:06 CST; 8s ago
Main PID: 2168 (falcon-trend)
Memory: 8.5M
CGroup: /system.slice/falcon-trend.service
└─2168 /apps/svr/falcon-plus/trend/bin/falcon-trend -c /apps/svr/falcon-plus/trend/config/cfg.json
Aug 18 15:47:06 ns-yun-020021.vclound.com systemd[1]: Started falcon trend.
Aug 18 15:47:06 ns-yun-020021.vclound.com systemd[1]: Starting falcon trend...
Aug 18 15:47:06 ns-yun-020021.vclound.com falcon-trend[2168]: 2020/08/18 15:47:06 cfg.go:75: g.ParseConfig ok, file /a...json
Aug 18 15:47:06 ns-yun-020021.vclound.com falcon-trend[2168]: 2020/08/18 15:47:06 http.go:38: http.startHttpServer ok, ...6991
Aug 18 15:47:06 ns-yun-020021.vclound.com falcon-trend[2168]: 2020/08/18 15:47:06 rpc.go:54: rpc.Start ok, listening on...6990
Aug 18 15:47:06 ns-yun-020021.vclound.com falcon-trend[2168]: 2020/08/18 15:47:06 main.go:20: 2168 register signal notify
Hint: Some lines were ellipsized, use -l to show in full.