hadoop_exporter python版本的安装使用

1.需要使用python pip

 参考https://www.cnblogs.com/rain124/p/6196053.html

 python2.7.5 安装pip

1 先安装setuptools

   下载地址:https://pypi.python.org/pypi/setuptools#downloads

 将下载后的tar文件解压,用CMD模式进入到解压后的文件所在的目录执行命令:python setup.py install

2 安装pip 

 下载地址:https://pypi.python.org/pypi/pip#downloads

   将下载后的tar文件解压,用CMD模式进入到解压后的文件所在的目录执行命令:python setup.py install 

 安装完成

3.安装pip install prometheus_client
4.安装pip install python_consu

2.下载hadoop_exporter

git clone https://github.com/cauwulixuan/hadoop_exporter

3.help

python hadoop_exporter.py -h
usage: hadoop_exporter.py [-h] [-c cluster_name] [-hdfs namenode_jmx_url]
                          [-rm resourcemanager_jmx_url] [-dn datanode_jmx_url]
                          [-jn journalnode_jmx_url] [-mr mapreduce2_jmx_url]
                          [-hbase hbase_jmx_url] [-hive hive_jmx_url]
                          [-p metrics_path] [-host ip_or_hostname] [-P port]

4.为几个exporter创建systemd服务

# cat /etc/systemd/system/nn_exporter.service
[Unit]
Description=namenode_exporter
After=network.target
[Service]
Type=simple
User=prometheus
ExecStart=python /usr/local/prom/exporter/hadoop_exporter/cmd/hdfs_namenode.py -s http://lab1:9135 -hdfs http://lab1:50070/jmx -P 9070
Restart=on-failure
[Install]
WantedBy=multi-user.target


# cat /etc/systemd/system/dn_exporter.service
[Unit]
Description=namenode_exporter
After=network.target
[Service]
Type=simple
User=prometheus
ExecStart=python /usr/local/prom/exporter/hadoop_exporter/cmd/hdfs_datanode.py -s http://lab1:9135 -dn http://lab1:50075/jmx -P 9072
Restart=on-failure
[Install]
WantedBy=multi-user.target


# cat /etc/systemd/system/jn_exporter.service
[Unit]
Description=namenode_exporter
After=network.target
[Service]
Type=simple
User=prometheus
ExecStart=python /usr/local/prom/exporter/hadoop_exporter/cmd/hdfs_journalnode.py -s http://lab1:9135 -jn http://lab1:8480/jmx -P 9071
Restart=on-failure
[Install]
WantedBy=multi-user.target


# cat /etc/systemd/system/rm_exporter.service
[Unit]
Description=namenode_exporter
After=network.target
[Service]
Type=simple
User=prometheus
ExecStart=python /usr/local/prom/exporter/hadoop_exporter/cmd/yarn_resourcemanager.py -s http://lab1:9135 -rm http://lab1:8088/jmx -P 9088
Restart=on-failure
[Install]
WantedBy=multi-user.target


# cat /etc/systemd/system/nm_exporter.service
[Unit]
Description=namenode_exporter
After=network.target
[Service]
Type=simple
User=prometheus
ExecStart=python /usr/local/prom/exporter/hadoop_exporter/cmd/yarn_nodemanager.py -s http://lab1:9135 -nm http://lab1:8042/jmx -P 9042
Restart=on-failure
[Install]
WantedBy=multi-user.target

5.为几个exporter配置prometheus配置文件

复制代码
##hadoop##
  - job_name: 'nn'
    static_configs:
    - targets: ['lab1:9070']
      labels:
          instance: lab1

  - job_name: 'rm'
    static_configs:
    - targets: ['lab1:9088']
      labels:
          instance: lab1

  - job_name: 'dn'
    static_configs:
    - targets: ['lab1:9072']
      labels:
          instance: lab1

  - job_name: 'jn'
    static_configs:
    - targets: ['lab1:9071']
      labels:
          instance: lab1
- job_name: 'nm' static_configs: - targets: ['lab1:9042:'] labels: instance: lab1
 
原文地址:https://www.cnblogs.com/roger888/p/10671411.html