在Apache IoTDB 0.13.0版本开始,我们引入了系统监控模块,本文主要介绍了如何在单机版开启系统监控模块,并且使用Prometheus + Grafana完成系统监控的可视化。
相关配置信息
修改配置文件,启动IoTDB
- 首先,进入到
apache-iotdb-0.13.0-all-bin
- 找到监控相关配置文件
conf/iotdb-metric.yml
,修改如下配置,其他配置保持不变:
# whether enable the module
enableMetric: true
- 运行脚本启动IoTDB:
./sbin/start-server.sh
,出现如下提示则为启动成功
- 在浏览器进入
http://localhost:9091/metrics
网址,可以查看到如下的监控项信息:
配置Prometheus进行数据采集
- 下载Prometheus的二进制包到本地,解压后进入对应文件夹:
tar xvfz prometheus-*.tar.gz
cd prometheus-*
- 首先,我们修改Prometheus的配置文件prometheus.yml如下:新增 iotdb 任务收集IoTDB的监控数据:
global:
scrape_interval: 15s
scrape_configs:
- job_name: "prometheus"
static_configs:
- targets: ["localhost:9090"]
- job_name: "iotdb"
static_configs:
- targets: ["localhost:9091"]
- 启动Promethues
./prometheus --config.file=prometheus.yml
- 在浏览器中输入 http://localhost:9090,进入Prometheus
- 查看配置是否成功:我们点击进入Status下的Target界面
- 当我们看到如下图State为Up时表示配置成功并已经联通
使用Grafana进行数据可视化
Grafana启动与配置
- 下载Grafana的二进制包到本地,解压后进入对应文件夹:
tar -zxvf grafana-*.tar.gz
cd grafana-*
- 启动Grafana并进入:
./bin/grafana-server web
-
在浏览器中输入 http://localhost:3000,进入Prometheus
-
首先我们在Configuration中配置Data Source为Prometheus
-
在配置Data Source时注意Prometheus所在的URL,配置好后点击Save & Test 出现Data source is working提示则为配置成功
在Grafana中创建Dashboard进行数据可视化
- 首先创建Dashboard,然后创建Panel
- 之后就可以在面板根据自己的需求对监控相关的数据进行可视化(所有相关的监控指标可以先在job中选择iotdb筛选)
- 选择关注的监控指标可视化完成后,我们就得到了这样的面板:
4. 为了方便使用,我们也已经提供了Dashboard模板,可以前往 官网 下载导入使用。
后续我们还会继续分享Apache IoTDB监控模块,敬请期待!