【集群监控】JMX exporter+Prometheus+Grafana监控Hadoop集群

下载jmx_exporter的jar包

https://repo1.maven.org/maven2/io/prometheus/jmx/jmx_prometheus_javaagent/0.3.1/jmx_prometheus_javaagent-0.3.1.jar

创建配置文件namenode.yaml(datanode.yaml)放在任意位置,内容为你想要的metrics

 

参考配置:

---
startDelaySeconds: 0
hostPort: master:1234 #master为本机IP(一般可设置为localhost);1234为想设置的jmx端口(可设置为未被占用的端口)
#jmxUrl: service:jmx:rmi:///jndi/rmi://127.0.0.1:1234/jmxrmi
ssl: false
lowercaseOutputName: false
lowercaseOutputLabelNames: false

 

其他参数参考:

NameDescription
startDelaySecondsstart delay before serving requests. Any requests within the delay period will result in an empty metrics set.
hostPortThe host and port to connect to via remote JMX. If neither this nor jmxUrl is specified, will talk to the local JVM.
usernameThe username to be used in remote JMX password authentication.
passwordThe password to be used in remote JMX password authentication.
jmxUrlA full JMX URL to connect to. Should not be specified if hostPort is.
sslWhether JMX connection should be done over SSL. To configure certificates you have to set following system properties:
-Djavax.net.ssl.keyStore=/home/user/.keystore
-Djavax.net.ssl.keyStorePassword=changeit
-Djavax.net.ssl.trustStore=/home/user/.truststore
-Djavax.net.ssl.trustStorePassword=changeit
lowercaseOutputNameLowercase the output metric name. Applies to default format and name. Defaults to false.
lowercaseOutputLabelNamesLowercase the output metric label names. Applies to default format and labels. Defaults to false.
whitelistObjectNamesA list of ObjectNames to query. Defaults to all mBeans.
blacklistObjectNamesA list of ObjectNames to not query. Takes precedence over whitelistObjectNames. Defaults to none.
rulesA list of rules to apply in order, processing stops at the first matching rule. Attributes that aren't matched aren't collected. If not specified, defaults to collecting everything in the default format.
patternRegex pattern to match against each bean attribute. The pattern is not anchored. Capture groups can be used in other options. Defaults to matching everything.
attrNameSnakeCaseConverts the attribute name to snake case. This is seen in the names matched by the pattern and the default format. For example, anAttrName to an_attr_name. Defaults to false.
nameThe metric name to set. Capture groups from the pattern can be used. If not specified, the default format will be used. If it evaluates to empty, processing of this attribute stops with no output.
valueValue for the metric. Static values and capture groups from the pattern can be used. If not specified the scraped mBean value will be used.
valueFactorOptional number that value (or the scraped mBean value if value is not specified) is multiplied by, mainly used to convert mBean values from milliseconds to seconds.
labelsA map of label name to label value pairs. Capture groups from pattern can be used in each. name must be set to use this. Empty names and values are ignored. If not specified and the default format is not being used, no labels are set.
helpHelp text for the metric. Capture groups from pattern can be used. name must be set to use this. Defaults to the mBean attribute decription and the full name of the attribute.
typeThe type of the metric, can be GAUGECOUNTER or UNTYPEDname must be set to use this. Defaults to UNTYPED.

 

修改$HADOOP_HOME/etc/hadoop/hadoop-env.sh 

NameNode节点添加:

export HADOOP_NAMENODE_OPTS="-Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.local.only=false   -Dcom.sun.management.jmxremote.port=1234 $HADOOP_NAMENODE_OPTS "

DataNode节点添加:

export HADOOP_DATANODE_OPTS="-Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.local.only=false   -Dcom.sun.management.jmxremote.port=1235 $HADOOP_DATANODE_OPTS "

提示:

端口1234(1235)要与之前设置的jmx端口保持一致

 

修改

$HADOOP_HOME/bin/hdfs

export HADOOP_NAMENODE_OPTS="$HADOOP_NAMENODE_OPTS -javaagent:/home/hadoop/jmx_prometheus_javaagent-0.3.1.jar=9200:/home/hadoop/namenode.yaml"

 

export HADOOP_DATANODE_OPTS="$HADOOP_DATANODE_OPTS -javaagent:/home/hadoop/jmx_prometheus_javaagent-0.3.1.jar=9300:/home/hadoop/datanode.yaml"

提示:9200(9300)为jmx_exporter提供metrics数据端口,后续Prometheus从此端口获取数据

 

访问http://master:9200/metrics就能获得需要的metrics数据:

# HELP jvm_buffer_pool_used_bytes Used bytes of a given JVM buffer pool.
# TYPE jvm_buffer_pool_used_bytes gauge
jvm_buffer_pool_used_bytes{pool="direct",} 1181032.0
jvm_buffer_pool_used_bytes{pool="mapped",} 0.0
# HELP jvm_buffer_pool_capacity_bytes Bytes capacity of a given JVM buffer pool.
# TYPE jvm_buffer_pool_capacity_bytes gauge
jvm_buffer_pool_capacity_bytes{pool="direct",} 1181032.0
jvm_buffer_pool_capacity_bytes{pool="mapped",} 0.0
# HELP jvm_buffer_pool_used_buffers Used buffers of a given JVM buffer pool.
...

 

下载Prometheus

https://prometheus.io/download/

解压

修改配置文件 prometheus.yml

添加

  - job_name: hadoop-master

    static_configs:
      - targets: ['localhost:9200']

  - job_name: hadoop-slave1

    static_configs:
      - targets: ['slave1:9300']

 

运行

./prometheus

 

 http://master:9090/targets查看是否添加成功

成功则增加master,slave1

如下图

通过点击http://localhost:9200/metrics可以看到metrics数据

 

下载Grafana

https://grafana.com/grafana/download?platform=linux

 

安装相应版本grafana

启动grafana

systemctl start grafana-server

 

启动后,即可通过http://master:3000/来访问了(默认账号密码是admin/admin)

如下图

 

关联Grafana和Prometheus

点击Data Sources 

 

点击Add data source,填写数据保存

 

添加一个dashboard,如下图进入dashboard导入页面

 

点击Upload .json File,导入模版(可从https://grafana.com/dashboards下载)

 

导入成功后可以看到类似如下效果,完成!

 

 



 

转载于:https://www.cnblogs.com/caizhenghui/p/9132414.html

  • 1
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
对于Prometheus监控Hadoop集群,你可以使用以下方法: 1. 安装Prometheus:首先,你需要在你的监控服务器上安装和配置Prometheus。你可以从Prometheus官方网站下载二进制文件或者使用包管理工具进行安装。 2. 配置Prometheus:在Prometheus的配置文件中,你需要定义Hadoop集群监控目标。你可以使用Prometheus的目标发现功能(如Service Discovery)或者手动配置Hadoop的各个组件的监控指标。 3. 配置Hadoop组件的指标:Hadoop的各个组件(如NameNode、DataNode、ResourceManager、NodeManager等)可以通过JMXJava Management Extensions)暴露出各种监控指标。你需要在Hadoop的配置中启用JMX,并且确保Prometheus能够访问这些指标。 4. 使用Exporter:为了将HadoopJMX指标暴露给Prometheus,你可以使用现有的Exporter工具,如JMX Exporter或者Node Exporter。这些工具可以将JMX指标转换为Prometheus可识别的格式。 5. 配置Prometheus监控规则和报警:一旦Prometheus开始收集Hadoop监控指标,你可以使用PromQL查询语言定义自定义的监控规则和报警。这样,当某些指标达到预设的阈值时,Prometheus将会触发报警。 6. 可视化和报告:除了Prometheus自带的基本监控界面外,你还可以使用Grafana等工具来可视化Hadoop监控数据并生成报告。Grafana可以与Prometheus进行集成,并提供更丰富的图形化展示和报告功能。 请注意,这只是一个大致的过程概述,实际配置和使用过程可能因具体环境和需求而有所不同。你可能需要参考相关文档和资源来完成具体的配置和调整。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值