flume开启jmx加入grafana
部署flume_exporter
需要go环境编译
配置go环境
首先下载go安装包Linux:
https://golang.google.cn/dl/
解压、添加环境变量
tar -zxvf go*.tar.gz
添加环境变量
vi /etc/profile
#在最后一行添加
export GOROOT=/你解压的路径/go
export PATH=$PATH:$GOROOT/bin
source环境变量查看go版本
source /etc/profile
go version
Flume_exporter下载地址:
https://github.com/woozhijun/flume_exporter/tags
上传 到 /opt/dtstack/exporters
解压 flume_exporter-0.0.2.tar.gz
# 解压
tar -xvf flume_exporter-0.0.2.tar.gz -C /opt/dtstack/exporters/
# 进入文件目录
cd /opt/dtstack/exporters/flume_exporter-0.0.2
编译flume_exporter-0.0.2
flume_exporter是需要编译的 执行编译命令
cd /opt/dtstack/exporters/flume_exporter-0.0.2
go install
把结果中含有go get “github.com…."的都复制下来,用&&连接多个下载命令
如果下载过程中出现网络错误,go添加国内镜像源
go env -w GO111MODULE=on
go env -w GOPROXY=https://goproxy.cn,direct
下载logrus:
go get github.com/Sirupsen/logrus
下载余下依赖:
go get github.com/prometheus/client_golang/prometheus &&go get github.com/prometheus/client_golang/prometheus/promhttp && go get github.com/prometheus/common/version && go get github.com/woozhijun/flume_exporter/exporter && go get gopkg.in/alecthomas/kingpin.v2
指定编译目录,执行安装:
[root@hd flume_exporter-0.0.2]# export GOPATH=/opt/flume_exporter-0.0.2
[root@hd flume_exporter-0.0.2]# go install
查看生成的文件,统一管理
[root@hd flume_exporter-0.0.2]# mkdir ../flume_exporter
[root@hd flume_exporter-0.0.2]# cp bin/flume_exporter-0.0.2 ../flume_exporter
[root@hd flume_exporter-0.0.2]# cp *.yml ../flume_exporter
[root@hd flume_exporter-0.0.2]# cd ../flume_exporter
注意:
可监控多个flume,但也需在prometheus增加对应的配置参数—config.yml
启动flume_exporter:
nohup /opt/flume_exporter/flume_exporter-0.0.2 --config-file=/opt/flume_exporter/config.yml --metric-file=/opt/flume_exporter/metrics.yml >/opt/flume_exporter/flumexport.log 2>&1 &
启动flume:
nohup /opt/flume/bin/flume-ng agent -c conf -f /opt/flume/conf/flume_hdfs.conf -n a1 -Dflume.root.logger=INFO,console -Dflume.monitoring.type=http -Dflume.monitoring.port=36001 -Dflume.root.logger=INFO,console -javaagent:/opt/dtstack/prometheus_conf/jmx_prometheus_javaagent-0.3.1.jar=9666:/opt/prometheus/flume.yml &
ps
如果需要用flume-ng的jmx后面再加入 -javaagent:/opt/dtstack/prometheus_conf/jmx_prometheus_javaagent-0.3.1.jar=9666:/opt/prometheus/flume.yml
vim /opt/prometheus/flume.yml
startDelaySeconds: 0
hostPort: localhost:36001
ssl: false
lowercaseOutputName: false
lowercaseOutputLabelNames: false
promethues配置flume_exporter
prometheus.yml 添加配置信息:
- job_name: ‘flume-agent'
static_configs:
- targets:
- hd1:9360
metrics_path: /metrics
- job_name: ‘flume-ng'
static_configs:
- targets:
- hd1:9666
metrics_path: /metrics
flume_exporter配置服务方式启动
vim /etc/systemd/system/flume_exporter.service
[Unit]
Description=flume_exporter service
After=network.target
Wants=network.target
[Service]
Type=simple
User=root
Group=root
ExecStart=/opt/flume_exporter/flume_exporter-0.0.2 --config-file=/opt/flume_exporter/config.yml --metric-file=/opt/flume_exporter/metrics.yml
Restart=on-failure
[Install]
WantedBy=multi-user.target
启动flume_exporter
# 重新加载服务的配置文件
systemctl daemon-reload
# 设置开机自启
systemctl enable flume_exporter
# 启动服务
systemctl start flume_exporter
添加模板
导入Grafana Dashboard Flume Exporter Metrics Overview For Prometheus
进入Grafana查看 查看flume监控
参数定义:
字段名称 含义
SOURCE.OpenConnectionCount 打开的连接数
SOURCE.TYPE 组件类型
SOURCE.AppendBatchAcceptedCount 追加到channel中的批数量
SOURCE.AppendBatchAcceptedCount source端刚刚追加的批数量
SOURCE.EventAcceptedCount 成功放入channel的event数量
SOURCE.AppendReceivedCount source追加目前收到的数量
SOURCE.StartTime(StopTIme) 组件开始时间、结束时间
SOURCE.EventReceivedCount source端成功收到的event数量
SOURCE.AppendAcceptedCount source追加目前放入channel的数量
CHANNEL.EventPutSuccessCount 成功放入channel的event数量
CHANNEL.ChannelFillPercentage 通道使用比例
CHANNEL.EventPutAttemptCount 尝试放入将event放入channel的次数
CHANNEL.ChannelSize 目前在channel中的event数量
CHANNEL.EventTakeSuccessCount 从channel中成功取走的event数量
CHANNEL.ChannelCapacity 通道容量
CHANNEL.EventTakeAttemptCount 尝试从channel中取走event的次数
SINK.BatchCompleteCount 完成的批数量
SINK.ConnectionFailedCount 连接失败数
SINK.EventDrainAttemptCount 尝试提交的event数量
SINK.ConnectionCreatedCount 创建连接数
SINK.Type 组件类型
SINK.BatchEmptyCount
SINK.ConnectionClosedCount 关闭连接数量
SINK.EventDrainSuccessCount 成功发送event的数量
SINK.BatchUnderflowCount 正处于批量处理的batch数