本次使用javaagent-0.16.0版本
监控hbase基于ambari
1、下载jar包 jmx_prometheus_javaagent-0.16.0
下载链接:https://github.com/prometheus/jmx_exporter/releases
2、jar包放到集群中hbase启动的lib目录下
/usr/hdp/3.1.4.0-315/hbase/lib下
3、配置
所有节点加上JMX exporter的agent,此处用的是ambari,故在页面添加hbase-env
##对每个节点
export HBASE_JMX_BASE="-Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false"
##对master节点,此处端口号是27000
export HBASE_MASTER_OPTS="$HBASE_MASTER_OPTS $HBASE_JMX_BASE -Dcom.sun.management.jmxremote.port=20101 -javaagent:$HBASE_HOME/lib/jmx_prometheus_javaagent-0.16.0.jar=27000:$HBASE_HOME/conf/hbase_jmx_config.yaml"
##对RS节点,此处端口号是27001
export HBASE_REGIONSERVER_OPTS="$HBASE_REGIONSERVER_OPTS $HBASE_JMX_BASE -Dcom.sun.management.jmxremote.port=20102 -javaagent:$HBASE_HOME/lib/jmx_prometheus_javaagent-0.16.0.jar=27001:$HBASE_HOME/conf/hbase_jmx_config.yaml"
4、创建hbase_jmx_config.yaml,在conf目录下
---
lowercaseOutputName: true
lowercaseOutputLabelNames: true
rules:
- pattern: Hadoop<service=HBase, name=RegionServer, sub=Regions> <>Namespace_([^\W_]+)_table_([^\W_]+)_region_([^\W_]+)_metric_(\w+)
name: HBase_metric_$4
labels:
namespace: "$1"
table: "$2"
region: "$3"
- pattern: Hadoop<service=(\w+), name=(\w+), sub=(\w+)><>([\w._]+)
name: hadoop_$1_$4
labels:
"name": "$2"
"sub": "$3"
- pattern: .+
5、重启hbase程序
6、查看监控项metrics
http://192.168.85.103:27001/metrics
7、prometheus配置
1)yaml文件添加配置
- job_name: "hbase"
static_configs:
- targets: ["192.168.85.103:27001"]
2)重启prometheus
nohup ./prometheus --config.file=prometheus.yml &
3)页面访问
http://192.168.85.102:9090/