|
| 1 | +# hadoop_jmx_exporter |
| 2 | + |
| 3 | +Hadoop HDFS & YARN metrics exporter. |
| 4 | + |
| 5 | +# 运行 |
| 6 | + |
| 7 | +``` bash |
| 8 | +➜ hadoop_jmx_exporter git:(master) ✗ pip install -r requirements.txt |
| 9 | +➜ hadoop_exporter git:(master) ✗ python hadoop_jmx_exporter.py --help |
| 10 | +usage: hadoop_jmx_exporter.py [-h] [-c cluster_name] [-hdfs namenode_jmx_url] |
| 11 | + [-rm resourcemanager_jmx_url] |
| 12 | + [-dn datanode_jmx_url] [-jn journalnode_jmx_url] |
| 13 | + [-nm nodemanager_jmx_url] [-p metrics_path] |
| 14 | + [-host ip_or_hostname] [-P port] |
| 15 | + |
| 16 | +hadoop jmx metric prometheus exporter |
| 17 | + |
| 18 | +optional arguments: |
| 19 | + -h, --help show this help message and exit |
| 20 | + -c cluster_name, --cluster cluster_name |
| 21 | + Hadoop cluster labels. (default "yh-cdh") |
| 22 | + -hdfs namenode_jmx_url, --namenode-url namenode_jmx_url |
| 23 | + Hadoop hdfs metrics URL. |
| 24 | + -rm resourcemanager_jmx_url, --resourcemanager-url resourcemanager_jmx_url |
| 25 | + Hadoop resourcemanager metrics URL. |
| 26 | + -dn datanode_jmx_url, --datanode-url datanode_jmx_url |
| 27 | + Hadoop datanode metrics URL. |
| 28 | + -jn journalnode_jmx_url, --journalnode-url journalnode_jmx_url |
| 29 | + Hadoop journalnode metrics URL. |
| 30 | + -nm nodemanager_jmx_url, --nodemanager-url nodemanager_jmx_url |
| 31 | + Hadoop nodemanager metrics URL. |
| 32 | + -p metrics_path, --path metrics_path |
| 33 | + Path under which to expose metrics. (default |
| 34 | + "/metrics") |
| 35 | + -host ip_or_hostname, -ip ip_or_hostname, --address ip_or_hostname, --addr ip_or_hostname |
| 36 | + Polling server on this address. (default "0.0.0.0") |
| 37 | + -P port, --port port Listen to this port. (default "6688") |
| 38 | + |
| 39 | +➜ hadoop_jmx_exporter git:(master) ✗ python hadoop_jmx_exporter.py -c yh-cdh -hdfs http://10.193.40.10:50070/jmx -rm http://10.193.40.2:8088/jmx -dn http://10.193.40.9:50075/jmx -jn http://yh-shhd-cdh05:8480/jmx -nm http://yh-shhd-cdh05:8042/jmx |
| 40 | +Listen at 0.0.0.0:6688 |
| 41 | +hang |
| 42 | +``` |
| 43 | + |
| 44 | +浏览器打开 `http://127.0.0.1:6688/metrics` 查看 metrics。 |
| 45 | + |
| 46 | +# Bugs |
| 47 | + |
| 48 | +如果有 Application 在运行的情况下重启 NodeManager,可能会导致 jmx 返回 |
| 49 | +的结果中,分配的 CPU 和 Memory 为负值,这是个 Bugs,issus:https://issues.apache.org/jira/browse/YARN-6966 |
| 50 | + |
| 51 | +``` code |
| 52 | +/jmx?qry=Hadoop:service=NodeManager,name=NodeManagerMetrics |
| 53 | +
|
| 54 | +"AllocatedGB": -35, |
| 55 | +"AllocatedContainers": -5, |
| 56 | +"AvailableGB": 276, |
| 57 | +"AllocatedVCores": -9, |
| 58 | +``` |
| 59 | + |
| 60 | +# 参考 |
| 61 | + |
| 62 | +1. http://hadoop.apache.org/docs/r2.7.3/hadoop-project-dist/hadoop-common/Metrics.html#namenode |
| 63 | +2. https://docs.cloudera.com/HDPDocuments/Ambari-2.7.5.0/using-ambari-core-services/content/amb_hdfs_users.html |
0 commit comments