hbase-exporter/README.md

123 lines
3.8 KiB
Markdown
Raw Normal View History

2019-04-04 13:37:54 +00:00
# hbase-exporter
## An HBase Prometheus Exporter
2020-07-01 22:50:02 +00:00
Collects metrics and relays JMX metrics for consumption by Prometheus
2019-04-04 13:37:54 +00:00
2019-04-10 12:49:46 +00:00
Since some important metrics are missing or empty in JMX, we additionally parse the HBase Master UI
2019-04-04 13:37:54 +00:00
for e.g. 'Stale regions in transition'
2020-07-01 22:50:02 +00:00
The output of the 'hbase hbck' command is parsed to check for inconsistencies in HBase
2019-04-04 13:37:54 +00:00
2020-07-01 22:50:02 +00:00
Marking Hbase unhealthy requires one of the following conditions to be true
- There is at least one stale region in transition
- The 'hbase hbck' command shows HBase inconsistencies
- A write to the predefined table does not succeed
- A ZooKeeper leader can not be determined
2020-06-24 23:06:10 +00:00
2019-04-04 13:37:54 +00:00
2020-11-19 15:11:06 +00:00
### Build/Install Dependencies
2020-07-01 22:50:02 +00:00
For python module requirements see requirements.txt
2019-04-04 13:37:54 +00:00
```sh
2020-11-19 15:11:06 +00:00
$ sudo dnf/pkg install python3
2019-04-04 13:37:54 +00:00
```
2020-11-19 14:30:38 +00:00
As the user executing the exporter (e.g. hdfs):
2019-04-04 13:37:54 +00:00
```sh
2020-11-19 14:30:38 +00:00
$ sudo su - hdfs
$ pip3 install --user -r requirements.txt
2020-06-24 23:06:10 +00:00
```
2020-07-01 22:50:02 +00:00
The protobuf compiler is necessary to build the required bindings for Python
2020-06-24 23:06:10 +00:00
Install the protobuf compiler
```
2020-12-22 22:15:04 +00:00
# FreeBSD
$ sudo pkg install protobuf-c
# Fedora / RHEL / CentOS
$ sudo dnf install protobuf-c protobuf-devel
# Debian / Ubuntu
$ sudo apt install protobuf-compiler libprotobuf-dev
2019-04-04 13:37:54 +00:00
```
2020-06-24 23:06:10 +00:00
2020-11-19 15:11:06 +00:00
#### Build the protobuf bindings
2020-07-01 22:50:02 +00:00
To generate the necessary HBase Python Protobuf bindings, run make
2020-06-24 23:06:10 +00:00
```
$ make
```
2020-11-19 15:11:06 +00:00
#### Install the protobuf bindings
```
$ cp -R hbase-protobuf-python /usr/local/lib
```
2020-07-01 22:50:02 +00:00
### Run
The exporter needs to know about the ZooKeeper servers to connect to, so start
the exporter with e.g.
```
2020-11-20 15:38:48 +00:00
$ PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION="python" \
hbase-exporter --zookeeper-server-address=zk-1.acme.internal \
--zookeeper-server-address=zk-2.acme.internal \
--zookeeper-server-address=zk-3.acme.internal \
--export-refresh-rate=60 \
--hbck-refresh-rate=1200
2020-07-01 22:50:02 +00:00
```
2020-11-19 14:30:38 +00:00
or use the systemd-unit and configure the zookeeper servers and refresh rates via the supplied environment file
2020-07-01 22:50:02 +00:00
Run 'hbase-exporter --help' for all arguments
```
$ hbase-exporter --help
usage: hbase-exporter [-h] [--hbase-master HBASE_MASTER]
[--hdfs-namenode HDFS_NAMENODE]
--zookeeper-server-address ZK_SERVER
[--zookeeper-use-tls ZK_USE_TLS]
[--exporter-port PROM_HTTP_PORT]
[--export-refresh-rate PROM_EXPORT_INTERVAL_S]
[--hbck-refresh-rate HBASE_HBCK_INTERVAL_S]
[--relay-jmx RELAY_JMX] [--logfile LOGFILE]
[--loglevel LOGLEVEL]
optional arguments:
-h, --help show this help message and exit
--hbase-master HBASE_MASTER
HBase master address, can be specified multiple times
--hdfs-namenode HDFS_NAMENODE
HDFS namenode address, can be specified multiple times
--zookeeper-server-address ZK_SERVER
ZooKeeper server address, can be specified multiple
times
--zookeeper-use-tls ZK_USE_TLS
Use TLS when connecting to ZooKeeper
--exporter-port PROM_HTTP_PORT
Listen port for Prometheus export
--export-refresh-rate PROM_EXPORT_INTERVAL_S
Time between metrics are gathered in seconds
--hbck-refresh-rate HBASE_HBCK_INTERVAL_S
Minimum time between two consecutive hbck runs in
seconds
--relay-jmx RELAY_JMX
Relay complete JMX data
--logfile LOGFILE Path to optional logfile
--loglevel LOGLEVEL Loglevel, default: INFO
```
### Deploy
Ansible can be used to build and deploy the hbase-exporter
```
2020-07-14 14:18:52 +00:00
$ ansible-playbook -v -i inventory/env.yml deploy-hbase-exporter.yml -l host
2020-07-01 22:50:02 +00:00
````
2021-03-03 17:22:57 +00:00
### Test
To run the tests
```
$ make test
```
2020-07-14 14:18:52 +00:00
### Debug
2020-07-01 22:50:02 +00:00
To see the log
```
$ sudo journalctl -afn100 -uhbase-exporter
2021-03-03 17:22:57 +00:00