hbase-exporter/README.md

137 lines
4.6 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]
2021-03-05 00:31:31 +00:00
[--hbase-pseudo-distributed HBASE_PSEUDO_DISTRIBUTED]
--hbase-table HBASE_TABLE
2020-07-01 22:50:02 +00:00
[--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]
2021-03-05 00:31:31 +00:00
If an arg is specified in more than one place, then commandline values
override environment variables which override defaults.
2020-07-01 22:50:02 +00:00
optional arguments:
-h, --help show this help message and exit
--hbase-master HBASE_MASTER
HBase master address, can be specified multiple times
2021-03-05 00:31:31 +00:00
[env var: HBASE_MASTER]
--hbase-pseudo-distributed HBASE_PSEUDO_DISTRIBUTED
Indicated whether HBase is run in pdeudo-distributed
mode [env var: HBASE_PSEUDO_DISTRIBUTED]
--hbase-table HBASE_TABLE
The HBase table for the write test [env var:
HBASE_TABLE]
2020-07-01 22:50:02 +00:00
--hdfs-namenode HDFS_NAMENODE
HDFS namenode address, can be specified multiple times
2021-03-05 00:31:31 +00:00
[env var: HDFS_NAMENODE]
2020-07-01 22:50:02 +00:00
--zookeeper-server-address ZK_SERVER
ZooKeeper server address, can be specified multiple
2021-03-05 00:31:31 +00:00
times [env var: ZK_SERVER]
2020-07-01 22:50:02 +00:00
--zookeeper-use-tls ZK_USE_TLS
2021-03-05 00:31:31 +00:00
Use TLS when connecting to ZooKeeper [env var:
ZK_USE_TLS]
2020-07-01 22:50:02 +00:00
--exporter-port PROM_HTTP_PORT
2021-03-05 00:31:31 +00:00
Listen port for Prometheus export [env var:
PROM_HTTP_PORT]
2020-07-01 22:50:02 +00:00
--export-refresh-rate PROM_EXPORT_INTERVAL_S
2021-03-05 00:31:31 +00:00
Time between metrics are gathered in seconds [env var:
PROM_EXPORT_INTERVAL_S]
2020-07-01 22:50:02 +00:00
--hbck-refresh-rate HBASE_HBCK_INTERVAL_S
Minimum time between two consecutive hbck runs in
2021-03-05 00:31:31 +00:00
seconds [env var: HBASE_HBCK_INTERVAL_S]
2020-07-01 22:50:02 +00:00
--relay-jmx RELAY_JMX
2021-03-05 00:31:31 +00:00
Relay complete JMX data [env var: RELAY_JMX]
2020-07-01 22:50:02 +00:00
```
### 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